docs: design specs for the generated service/operation layer#139
Draft
OmarAlJarrah wants to merge 1 commit into
Draft
docs: design specs for the generated service/operation layer#139OmarAlJarrah wants to merge 1 commit into
OmarAlJarrah wants to merge 1 commit into
Conversation
Add design specs under docs/codegen/ for the typed service layer the future generator will emit on top of sdk-core. These are specifications only — no generator, KotlinPoet, or generated code enters the repo; every snippet is illustrative target output anchored to real sdk-core types. - service-method-tiers.md: two-tier raw/cooked operations over the ResponseHandler / ParsedResponse seam, with error-mapping and deserialization composed at the service layer so the HTTP pipeline stays transport-pure and keeps returning a raw Response. - typed-page-classes.md: list-operation page types whose nextPage() rebuilds a typed params object (params.toBuilder().<cursor>().build()) and drives the stateless Paginator, with RequestRebuilder kept as the bring-your-own path. - operation-overloads.md: curation rules capping each operation at one canonical params-object method plus a small fixed convenience set, leaning on Kotlin default arguments and Tristate instead of a parameter cross-product that would tax explicit-API and apiCheck. - sub-service-tree.md: lazily-instantiated sub-service accessor tree (client.foo().bar()) where the root reuses the raw-response impl to halve the generated type count, with a by-lazy-vs-memoized-supplier note for Java. - README.md: index linking the four specs and how they compose.
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
Adds design specifications under
docs/codegen/for the typed service/operation layer that the future code generator will emit on top ofsdk-core. These are specs only — no generator, no KotlinPoet, no generated source enters the repo. Every Kotlin/Java snippet is illustrative target output, anchored to realsdk-coretypes so the design stays grounded in the runtime that ships today.A new
docs/codegen/README.mdindexes the specs and explains how they compose into one cohesive generated layer.What's included
service-method-tiers.md— Two-tier raw/cooked operations. The raw tier returns a lazyParsedResponse<T>(read status/headers without parsing, or callvalue()to parse exactly once); the cooked tier delegates into the raw tier and returns the typed body. Error-mapping and deserialization compose as a singleResponse -> TResponseHandlerat the service layer, so the HTTP pipeline stays transport-pure and keeps returning a rawResponse. Closeable +use {}+ KDoc, no@MustBeClosedlint.typed-page-classes.md— List-operation page types whosenextPage()rebuilds a typed params object (params.toBuilder().<cursor>(…).build()) and re-invokes the operation, instead of splicing a URL. A generatedPaginationStrategybridges the typed page onto the existing statelessPaginator/Pagecontract; the runtime'sRequestRebuilderis kept as the bring-your-own URL-splice path.operation-overloads.md— Curation rules capping each operation at one canonical params-object method plus a small fixed convenience set, leaning on Kotlin default arguments andTristate<T>rather than a parameter cross-product. Avoids a permanent explicit-API +apiCheckbinary-compat tax. Six deterministic rules so the generator stays mechanical.sub-service-tree.md— Lazily-instantiated sub-service accessor tree (client.foo().bar()) usingby lazyat the root and every interior node. The root reuses the raw-response impl so the cooked tier is derived rather than duplicated, halving the generated type count. Includes aby lazyvs. memoized-supplier note for a possible future Java target.Cross-cutting dependencies (tracked separately)
The specs note two prerequisites not yet in the tree: the OperationParams SPI (typed builder-backed params with
toBuilder()/toRequest()) and the generator itself (perdocs/refs-comparison.md).Closes #55
Closes #56
Closes #58
Closes #59