refactor(sdk): replace glob re-export with explicit public API facade - #146
Merged
Conversation
The SDK crate re-exported everything from the generated module via pub use generated_sdk::*, making all generated items public API and turning every regeneration into a potential breaking change. Replace the glob with an explicit facade in sdk/src/lib.rs: - Client plus the progenitor runtime types (ByteStream, ClientInfo, Error, ResponseValue) re-exported by name - types, builder, and prelude kept as namespaced modules - all 37 Client*Ext operation traits listed explicitly The generated_sdk module stays private, so new generated items no longer leak into the public surface implicitly; additions to the API now require an intentional edit to the facade list. No behavior change; pure re-export restructuring. Closes #72
|
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
sdk/src/lib.rspreviously didpub use generated_sdk::*, which made every item in the 100k-line generated module part of the crate's public API. Anycargo xtask generaterun could silently add, remove, or change public items, and consumers could accidentally depend on transitively-exposed internals.This replaces the glob with an explicit facade. The
generated_sdkmodule stays private; only the listed names are exposed.Approach
Full explicit enumeration was practical here because the generated module's top level is small (~45 names) even though the file is huge — the hundreds of request/response types already live under the
typesmodule and the operation builders underbuilder, so those stay namespaced rather than being flattened.Explicitly re-exported:
Client, plus the progenitor runtime types used in operation signatures:ByteStream,ClientInfo,Error,ResponseValuetypes(request/response schemas),builder(operation builders),prelude(Client + all extension traits)Client*Extper-tag operation traits, listed by nameThe existing
pub use progenitor_client;/pub use reqwest;re-exports are unchanged. A doc comment notes that regeneration which adds a new operation tag now requires an intentional edit to the facade list — which is the point of the change.Verification
cargo build --workspace— clean (the CLI binary is the real consumer test; nothing it imports was dropped)cargo build --release— cleancargo fmt --check— cleancargo clippy --workspace -- -D warnings -A dead_code— cleancargo test --workspace— 2095 passed, 0 failed (e2e tests ignored as usual, backend-gated)No behavior change; pure re-export restructuring, so Windows compatibility is unaffected. Scope is confined to
sdk/src/lib.rsand does not touch the lint configuration (kept clear of the #70 work).Closes #72