[codex] Add SDK support for Content v4 Answers endpoints#55
Open
basit3407 wants to merge 2 commits into
Open
Conversation
Contributor
size-limit report 📦
|
There was a problem hiding this comment.
Pull request overview
Adds first-class SDK support for the new Content v4 answers endpoints so consumers can call them through both the legacy/root SDK surface and the server runtime facade.
Changes:
- Added
Answer-related API types and a newQuranAnswersSDK wrapper for by-ayah, by-id, and count-within-range endpoints. - Exposed answers through
client.answersandclient.content.v4.answerson the server runtime, with a server-only guard on the public runtime. - Preserved
pageSizequery casing and added tests/mocks for the new answers flows.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/api/test/answers.test.ts |
Adds unit coverage for the new answers SDK methods and one content.v4 alias path. |
packages/api/src/types/api/index.ts |
Re-exports the new answer-related API types. |
packages/api/src/types/api/Answer.ts |
Defines answer/question/count response types for the new endpoints. |
packages/api/src/sdk/client.ts |
Exposes the new answers SDK on the legacy root client. |
packages/api/src/sdk/answers.ts |
Implements the answers SDK wrapper and count-type normalization. |
packages/api/src/runtime/create-public-client.ts |
Adds a public-runtime server-only guard for top-level answers. |
packages/api/src/runtime/create-client.ts |
Wires answers into the server runtime root and content.v4 facade. |
packages/api/src/lib/url.ts |
Preserves camelCase for pageSize during query serialization. |
packages/api/mocks/handlers.ts |
Adds mock handlers for the new answers endpoints used by tests. |
.changeset/v4-answers-sdk.md |
Declares a minor release for the new SDK surface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client.answersandclient.content.v4.answersin the server runtime, with a server-only guard in the public runtime.pageSizequery parameter casing foranswers.byAyah, because this endpoint's API contract uses camelCase there.TAFSIR,CLARIFICATION, etc.Why
While smoke testing the published
@quranjs/apipackage through theqf-user-poc, we realized the recently merged quran/quran.com-api#800 endpoints were live and documented but did not have first-class SDK wrappers yet. The SDK could only reach them through generated raw operations, which meant consumers did not get the typed and ergonomic surface we expect for new Content v4 public APIs.This follows the same process as the previous SDK follow-up: compare the merged API contract, add the missing SDK facade, test it in unit coverage, then install the local SDK build into the PoC and run live/prelive smoke checks before opening the PR.
API Surface
The same calls are also available from the root content client as
client.answers.findByAyah,client.answers.findByQuestionId, andclient.answers.countWithinRange.Validation
pnpm --filter @quranjs/api lintpasses with the existing type-import warning inpackages/api/src/types/quran-client.tsand Node module-type warning foreslint.config.js.pnpm --filter @quranjs/api buildpnpm --filter @quranjs/api exec vitest run --exclude test/operation-catalog-generator.test.jsC:\Code\qf-user-pocasfile:../api-js/packages/apiand verified the PoC displays@quranjs/api@3.2.0 (local file: file:../api-js/packages/api)./sdk/content-answers/prelive: 4 passed, 0 warnings, 0 failed./sdk/content-answers/production: 4 passed, 0 warnings, 0 failed.Docs
Docs PR #147 has been updated with the SDK Answers page and sidebar/runtime references: quran/qf-api-docs#147.