refactor!: single NewClient constructor with functional options - #17
Merged
Conversation
…ional options Replace NewClientWithOptions and the token-only NewClient(token string) with a single NewClient(opts ...Option); the token is supplied via WithToken. Update all call sites, examples, docs snippets, and bump ClientVersion to 0.7.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
Note in README and docs/ that omitting WithToken yields an unauthenticated client usable for token-free endpoints (e.g. browsing the public Apify Store); add a compiling anonymous-Store snippet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
GET /v2/store inherits the global security requirement and needs a token, so it is not a valid unauthenticated example. Use fetching a public Actor build by ID (client.Build(id).Get), which the spec marks security: []. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
… build Add examples/public_build_no_token (unauthenticated client -> DefaultBuild of apify/hello-world) plus a Test examples smoke test, and make the docs' no-token guidance actionable via a public Actor ID instead of an unknown build ID. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
…en-free endpoints Add a public_build_no_token row to the Examples table (and clarify the intro so it no longer implies every example needs a token); expand the example's package doc to name both security: [] endpoints it calls. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
The Features list claimed zero third-party dependencies, but go.mod declares github.com/andybalholm/brotli, used at runtime for Brotli request-body compression. Reword to describe the actual footprint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
- Remove out-of-scope KeyValueStoreClient.GetRecords / GetRecordsOptions (no reference JS counterpart) and its docs/test. - Remove UserClient.MonthlyUsageForDate for reference consistency; MonthlyUsage is now parameterless. Keep SetStatusMessage (has a JS counterpart). - Add TestGetUserByID covering client.User(id).Get(). - Fail CI when zero tests run or all skip: parse go test -json via .github/scripts/assert-tests-ran.sh in both integration and examples steps. - Give examples a crypto-random Actor name and honor APIFY_API_URL via a shared examples/internal/exampleclient helper. - Print dataset Total (not per-page Count) in README and run_store_actor. - Align iterator cap-exhaustion/chunk-clamp logic and trim duplicated doc caveat. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
- Print dataset Total in run_and_last_run_storages; clarify storages example
prints per-page Count ("on this page") since the total lags right after a push.
- Add TestIterateKeyValueStoreKeysWithLimit covering the KV keys iterator's
total-item cap path (Limit spanning multiple pages).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BmN5DEZR4vrRA3RhGus9qt
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.
Syncs the Go client with the reference JS client and hardens the test setup.
Public interface
NewClient(opts ...Option)constructor; the token is supplied viaWithToken(optional, so an unauthenticated client can call token-free endpoints). RemovesNewClientWithOptionsand the token-onlyNewClient(token string). Human-requested refactor. BumpsClientVersionto 0.7.0.KeyValueStoreClient.GetRecords/GetRecordsOptions(bulk records download, not exposed by the reference client — out of scope).UserClient.MonthlyUsageForDate;MonthlyUsagematches the reference's parameterless signature.Tests & CI
TestGetUserByIDcoveringclient.User(id).Get().go test -jsonvia.github/scripts/assert-tests-ran.sh.Examples & docs
APIFY_API_URLthrough a sharedexamples/internal/exampleclienthelper.examples/public_build_no_token(fetches a public Actor's default build with no token).Totalrather than per-pageCountin the README andrun_store_actor.github.com/andybalholm/brotliis used at runtime for Brotli request-body compression).