Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/brave-videos-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@youversion/platform-core': minor
---

Add Content Library video detail, playlists, dedicated video search, and ID-only video hits in unified search. The new video APIs use `ContentLibraryVideo` with opaque string IDs and passage/publisher metadata. Existing `Video`, unified field selections, and hook overrides remain compatible with v3.

Video details, playlists, dedicated video search, and unified search use `/v1` routes. Unified search uses `/v1/search-unified` for every field selection, including `videos`.

Unified search results now include an enumerable `videos` array, including `[]` when no videos are returned. JSON output, exact snapshots, and `keyof SearchUnifiedResponse` gain this key; existing hook overrides may still omit it. Video field selection is available through core `SearchClient`; the existing React hook retains its verse/topic/image selections. Shared hook options should use `SearchUnifiedOptions` or `UseUnifiedSearchProps` rather than derive the wider selection from the core method signature.

An empty `organizationIds` array now searches without publisher filters, matching an omitted option. Search-only bundles exclude playlist validation code. Dedicated video search can return empty pages with continuation tokens; continue until `nextPageToken` is null, rather than stopping on an empty video array. The response has no total result count.

Preserve optional nullable `passage_ids`, `organization_id`, and `references` on video details and dedicated-search resources, alongside earlier `passage_id` responses. Thumbnail URL strings may be absolute, relative, or protocol-relative.

Video queries use the shared 100-grapheme limit. Missing or null `user_intent` and `search_instead_for` fields are tolerated. Video search deliberately rejects HTTP 204 as an undocumented response, unlike Swift and Kotlin, which return an empty page.

The new `VideosClient` consistently uses camelCase options: `acceptLanguage`, `pageSize`, `pageToken`, and `thumbnailSize`. Null video-search and playlist input cursors mean the first page, as when omitted; empty string cursors remain unchanged. Playlist requests default to English for YPE-6461 while honoring explicit language preferences.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
YVP_APP_KEY=""
YVP_API_HOST="api.youversion.com"

# Optional core video live smoke: an organization with populated video playlists.
# YVP_VIDEO_ORGANIZATION_ID=""

# Optional Vite demo overrides
# Defaults to the demo's current origin.
# VITE_YVP_AUTH_REDIRECT_URL="http://localhost:5173"
Expand Down
4 changes: 4 additions & 0 deletions docs/cursor-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ harness-specific app-key override, the demo renders the SDK missing-app-key pane
shows its own Missing Environment Variables warning before mounting the SDK. Live core integration
tests remain skipped.

The optional video live smoke also needs `YVP_VIDEO_ORGANIZATION_ID` in the root
`.env`, identifying an organization with populated video playlists. See
[the video test command](./testing.md#env).

## Running the demo

Start the demo and its workspace dependency watchers with:
Expand Down
103 changes: 103 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,111 @@ Bind on new/edited tests. When touching a file, bend the cases you edit toward t

## Env

To verify playlist-to-video lookup against a deployment, set `YVP_API_HOST` (a hostname such as `api.youversion.com`), an
`YVP_APP_KEY` with access to the video catalog, and `YVP_VIDEO_ORGANIZATION_ID` for an organization
with a populated video playlist. Run `pnpm --filter @youversion/platform-core test:integration src/__tests__/videos.integration.test.ts`.

Missing `YVP_API_HOST` or other env files: read `docs/cursor-cloud.md`.

## Content Library contract and routing

YPE-6573 response validation follows the user-supplied Transformers `compiled.yaml`
snapshot (SHA-256 `e2458ce1008a5d5a1d6151e08b7769e6edf27f36abfdb40d06133b15c0a5475d`).
[Swift PR 302](https://github.com/youversion/platform-sdk-swift/pull/302)
(`bba84a3`) and [Kotlin PR 242](https://github.com/youversion/platform-sdk-kotlin/pull/242)
(`3e39b55`) are comparison references,
not substitutes for that contract. The mocked client tests cover video detail,
playlist-to-detail and unified-search-to-detail lookup, thumbnail renditions,
nullable and absent video metadata, required fields, pagination and HTTP errors.
Video search requires the `videos` and `did_you_mean` arrays. Absent or null
`user_intent` and `search_instead_for` normalize to absent intent and a null
correction, matching sibling SDK tolerance. Its undocumented 204 response still
rejects, while playlist 204 returns an empty page; this deliberate difference is
called out in the changeset. Malformed full video resources reject rather than
being silently dropped.

Review follow-up adds optional nullable `passage_ids` (string array) and
`organization_id` (UUID), as specified in the review's newer `compiled-2.yaml`,
while retaining singular `passage_id` from the original supplied snapshot. That newer
attachment was not available locally; these are additive metadata-preservation
changes, not proof that the deployment serves the complete newer contract.
Optional `references` is also preserved for compatibility with sibling SDKs.
Thumbnail URLs remain strings, preserving absolute, relative and protocol-relative
forms without inventing a base URL. Video queries reuse the existing 100-grapheme
search validator, matching Swift, Kotlin and the other core search methods.

Content Library requests use stable routes:

- Video detail, playlist collection/detail and dedicated video search use `/v1`.
- Unified search always uses `/v1/search-unified`, including when `fields` includes
`videos` or is omitted. Routing does not depend on the selected fields.
- Playlist language defaults to English for YPE-6461; explicit preferences are
honored. Dedicated video search defaults to English per the search API.
- `VideosClient` options use camelCase (`acceptLanguage`, `pageSize`, `pageToken`,
`thumbnailSize`). Wire parameters and collection response cursors keep their
API names. Null input cursors are omitted; empty string cursors are preserved.

The original supplied spec names stable routes for video details, playlists and
unified search. Its dedicated video-search route was `/v1-beta/search-videos`;
the current implementation uses `/v1/search-videos` per the updated routing direction.
The pinned Swift and Kotlin revisions used earlier rollout routes and do not define
the current React routing.
The live smoke remains optional deployment evidence, not a replacement for the
contract tests or a requirement for adding UI. No UI is added by YPE-6573.

### Stable-route checks (2026-11-24)

After switching all Content Library requests to `/v1`, the rebuilt SDK returned
populated dedicated and unified video searches for “Bible,” “Jesus,” and
“What Is The Bible?” The first video ID from each search resolved through
`getVideo`. English playlist pagination completed across nine pages of two
playlists, returning 18 unique playlists. Playlist detail and video detail passed
response validation. Spanish and Portuguese playlists and video details retained
the corresponding language tags.

Media returned by stable video detail remained accessible without an App Key:
the thumbnail, both HLS sources (manifests and sampled media segments, including
initialization data where applicable), and the MP4 preview. Responses allowed
cross-origin access; full player playback was not tested.

The accepted search pagination behavior also occurs on `/v1/search-videos`.
For “Jesus” with `page_size=5`, direct HTTP requests returned 4, 1, 0, and 3
videos on the first four pages. The SDK followed 30 pages, returning 17 unique
videos without duplicates and 20 empty pages; a continuation token remained.
These bounded checks do not establish eventual termination. Consumers must use
the continuation token rather than the result count to decide whether to continue.

### Earlier rollout checks (2026-11-24)

Before the switch to `/v1`, manual requests and the built core SDK at `c748d1f`
verified populated `/v1-beta`
playlist collection/detail and video detail responses. The English BibleProject
catalog returned 18 playlists; pagination completed across nine pages of two
playlists, without duplicate playlist IDs. Spanish and Portuguese requests returned
localized playlists and video details with the corresponding language tags.

Dedicated search and unified search selecting `videos` returned videos for
“Bible,” “Jesus,” and “What Is The Bible?” The first ID from each search resolved
through the video detail client. Detail validation preserved passage and publisher
metadata, and the card thumbnail rendition was applied.

The thumbnail, both HLS playback sources (manifests and sampled media segments,
including initialization data where applicable), and the MP4 preview were accessible
without an App Key. Media responses allowed cross-origin access. Full player
playback was not tested. These manual checks are deployment evidence, not additional
automated test coverage or proof of the complete newer OpenAPI contract.

Dedicated search returned empty pages with continuation tokens for all three
queries. For “Jesus” with `page_size=5`, the first four pages contained 4, 1, 0,
and 3 videos. A bounded SDK check followed 30 pages, returning 17 unique videos
without duplicates and 20 empty pages; another token remained. Direct HTTP requests
reproduced empty pages with tokens independently of SDK parsing. Eventual
termination was not verified, and the response provides no total result count.

We accept this service behavior and retain the current implementation. Consumers
must follow non-null tokens even after empty pages. Any required behavior change
will be handled in a follow-up after clarification or a service contract change.

## Before pushing

Run the full test suite across all packages — a change in one package can break another.
Expand Down
73 changes: 72 additions & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,86 @@ A blank `passage_id` is rejected before the request. Pass a single verse or a
verse range, such as `JHN.3.16` or `JHN.3.16-18`.

Unified search returns one snapshot of top results, not the entire verse result
set. Omit `fields` for all available kinds, or pass a nonempty selection.
set. Omit `fields` for the stable endpoint's default selection, or pass a nonempty
selection. Explicitly include `videos` to request video hits.
`userIntent` accepts `unknown`, `topical`, `text`, or `reference`; response intent
strings remain open-ended.

Unified responses now always include a `videos` array, including stable-route
searches that return `videos: []`. This adds an enumerable property to returned
objects, so JSON output, exact snapshots, and `keyof SearchUnifiedResponse` include
it. The public type keeps the property optional for existing fixtures and hook
overrides.

Explicit video selection is available through core `SearchClient.searchUnified`
with `ContentLibrarySearchOptions`. The existing React `useUnifiedSearch` hook
continues to accept only `verses`, `topics`, and `images`. For options shared with
the hook, use `SearchUnifiedOptions` or `UseUnifiedSearchProps` rather than deriving
the wider core selection from `Parameters<SearchClient['searchUnified']>`.

`SearchClient.searchVideos` accepts `organizationIds` as UUID filters combined with
OR. Omit the option or pass `[]` to search all organizations accessible to the app.

The SDK also accepts `fields: ['images']` and maps image hits to `{ id, passageId }`,
not image URLs. Image selection requires backend support. A production check on
2026-10-20 returned HTTP 400 for `fields: ['images']`; successful verse/topic
responses omitted images, which the SDK returns as `images: []`.

### Video details, playlists, and search

There are two ways to find videos:

- Search by text. Unified search returns video IDs; pass each ID unchanged to
`VideosClient.getVideo`. Dedicated `SearchClient.searchVideos` returns full
video resources, including playback sources, so a second detail request is
usually unnecessary.
- Browse an organization's playlists. `VideosClient.getPlaylists` returns a
collection; `getPlaylist` returns one full playlist, including its ordered
video IDs. Pass those IDs unchanged to `getVideo` for metadata and playback URLs.

These calls require an App Key with access to the video catalog.
Video details, playlist collection/detail, and dedicated video search use
`/v1`. Unified search always uses `/v1/search-unified`, including when `fields`
explicitly includes `videos`.
Unified search returns one unpaginated set of top results.

Dedicated video search supports `pageSize` from 1 to 99. Repeat the query,
organization filters, and language when passing `nextPageToken` as `pageToken`;
`pageSize` may change. An empty video array can still include a continuation token,
and later pages can contain videos. Stop when `nextPageToken` is `null`, not when
`videos` is empty. Empty string tokens are preserved and must be passed unchanged.
No total result count is returned. Live checks reproduced empty pages with tokens
both through the SDK and with direct HTTP requests. We accept this service behavior;
eventual termination was not verified in the bounded live checks.

Playlist collections use `data` and `next_page_token`. Follow that token until
it is `null`. `pageSize` accepts 1 to 99, or `'*'` when `fields` selects one to
three fields. Omitting `fields` requests full playlists; a selected field set can
omit IDs or video IDs, so include the fields needed for subsequent requests.
Playlist collection HTTP 204 or an empty response body returns an empty collection;
malformed nonempty responses and empty detail responses reject.

`VideosClient` uses camelCase options: `acceptLanguage`, `thumbnailSize`,
`pageSize`, and `pageToken`. API query parameters and collection response keys
retain their wire names, such as `page_size` and `next_page_token`. A null input
cursor requests the first page; an empty string cursor is sent unchanged.

Video detail and dedicated search preserve optional nullable `passage_ids`,
`organization_id`, and `references`, plus singular `passage_id` from earlier
responses. Thumbnail URL strings are preserved whether absolute, relative, or
protocol-relative. `getVideo` accepts `thumbnailSize: 'thumb'`, `'card'`, or
`'full'`. Omitting it removes any existing `size` parameter for the full-size
image; dedicated search also removes that parameter. Other query bytes and
fragments are preserved. Relative URLs remain relative; the SDK does not resolve
them against a base URL.
Queries use the same 100-grapheme validator as other search methods. Optional
query intent/correction fields may be absent or null. Unlike the sibling SDKs,
video search intentionally rejects undocumented HTTP 204 responses.

Playlist requests default to English to avoid the missing-language catalog issue
tracked in YPE-6461, while explicit caller preferences are honored. Video details
keep the runtime language default; dedicated video search defaults to English.

### Display Bible HTML

Use `getPassageDisplay` when you need transformed HTML together with current
Expand Down
4 changes: 4 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@
"!dist/search-topics.cjs",
"!dist/search-unified.js",
"!dist/search-unified.cjs",
"!dist/search-videos.js",
"!dist/search-videos.cjs",
"!dist/highlights.js",
"!dist/highlights.cjs",
"!dist/images.js",
"!dist/images.cjs",
"!dist/videos.js",
"!dist/videos.cjs",
"!dist/organizations.js",
"!dist/organizations.cjs",
"!dist/data-exchange.js",
Expand Down
47 changes: 47 additions & 0 deletions packages/core/src/__tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,53 @@ describe('ApiClient contracts', () => {
}
});

it('exposes successful status without changing the legacy body-only result', async () => {
if (process.env.INTEGRATION_TESTS) server.listen();
try {
server.use(
http.get(
'https://test_placeholder.youversion.com/no-content',
() => new HttpResponse(null, { status: 204 }),
),
http.get(
'https://test_placeholder.youversion.com/empty-success',
() => new HttpResponse(null, { status: 200 }),
),
http.get('https://test_placeholder.youversion.com/json-string', () =>
HttpResponse.json(''),
),
);
const client = new ApiClient({
apiHost: 'test_placeholder.youversion.com',
appKey: 'test-app',
});

await expect(client.get('/no-content')).resolves.toBe('');
await expect(client.getWithStatus('/no-content')).resolves.toEqual({
data: '',
emptyBody: true,
status: 204,
});
await expect(client.get('/empty-success')).resolves.toBe('');
await expect(client.getWithStatus('/empty-success')).resolves.toEqual({
data: '',
emptyBody: true,
status: 200,
});
await expect(client.get('/json-string')).resolves.toBe('');
await expect(client.getWithStatus('/json-string')).resolves.toEqual({
data: '',
emptyBody: false,
status: 200,
});
} finally {
if (process.env.INTEGRATION_TESTS) {
server.resetHandlers();
server.close();
}
}
});

it('only exposes numeric status values from unknown failures', () => {
expect(getHttpStatus(Object.assign(new Error('forbidden'), { status: 403 }))).toBe(403);
expect(getHttpStatus({ status: '403' })).toBeUndefined();
Expand Down
Loading
Loading