Skip to content

refactor!: single NewClient constructor with functional options - #17

Merged
Pijukatel merged 8 commits into
masterfrom
claude/upbeat-davinci-8e1h48
Jul 12, 2026
Merged

refactor!: single NewClient constructor with functional options#17
Pijukatel merged 8 commits into
masterfrom
claude/upbeat-davinci-8e1h48

Conversation

@claude

@claude claude Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Syncs the Go client with the reference JS client and hardens the test setup.

Public interface

  • Single NewClient(opts ...Option) constructor; the token is supplied via WithToken (optional, so an unauthenticated client can call token-free endpoints). Removes NewClientWithOptions and the token-only NewClient(token string). Human-requested refactor. Bumps ClientVersion to 0.7.0.
  • Removes KeyValueStoreClient.GetRecords/GetRecordsOptions (bulk records download, not exposed by the reference client — out of scope).
  • Removes UserClient.MonthlyUsageForDate; MonthlyUsage matches the reference's parameterless signature.

Tests & CI

  • Adds TestGetUserByID covering client.User(id).Get().
  • CI now fails when zero tests run or all skip: both the integration and examples steps parse go test -json via .github/scripts/assert-tests-ran.sh.

Examples & docs

  • Examples use a crypto-random Actor name and honor APIFY_API_URL through a shared examples/internal/exampleclient helper.
  • Adds the CI-tested examples/public_build_no_token (fetches a public Actor's default build with no token).
  • Prints dataset Total rather than per-page Count in the README and run_store_actor.
  • Corrects the README dependency note (github.com/andybalholm/brotli is used at runtime for Brotli request-body compression).

claude added 8 commits July 12, 2026 05:39
…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
@Pijukatel
Pijukatel merged commit b760cb8 into master Jul 12, 2026
2 checks passed
@Pijukatel
Pijukatel deleted the claude/upbeat-davinci-8e1h48 branch July 12, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants