Repository navigation
refactor!: drop the underscore prefix from non-public members - #1059
Merged
Merged
Conversation
BREAKING CHANGE: the protected helpers on the base clients are renamed. `_url` -> `buildUrl`, `_publicUrl` -> `buildPublicUrl`, `_params` -> `buildParams`, `_subResourceOptions` -> `subResourceOptions`, `_toSafeId` -> `toSafeId`, `_listPaginatedFromCallback` -> `listPaginatedFromCallback`, `_get` -> `getResource`, `_update` -> `updateResource`, `_delete` -> `deleteResource`, `_waitForFinish` -> `waitForJobFinish`, `_list` -> `listResources`, `_listPaginated` -> `listResourcesPaginated`, `_create` -> `createResource`, `_getOrCreate` -> `getOrCreateResource`, `_batchAddRequests` -> `addRequestBatch`, `_batchAddRequestsWithRetries` -> `addRequestBatchWithRetries`. Subclasses that call the old names have to switch to the new ones.
Contributor
|
See more at https://github.com/apify/apify-client-js/actions/runs/34817133912#summary-103890084253 |
…e-prefix # Conflicts: # src/resource_clients/dataset.ts
janbuchar
reviewed
Sep 12, 2026
janbuchar
left a comment
Contributor
There was a problem hiding this comment.
Looks reasonable to me, nice job! Maybe we should also make private methods and attributes #private while you're at it?
…e-prefix # Conflicts: # docs/public-api/apify-client.api.md # src/base/api_client.ts # src/base/resource_client.ts # src/base/resource_collection_client.ts # src/http_client.ts # src/resource_clients/actor.ts # src/resource_clients/actor_collection.ts # src/resource_clients/actor_env_var.ts # src/resource_clients/actor_env_var_collection.ts # src/resource_clients/actor_version.ts # src/resource_clients/actor_version_collection.ts # src/resource_clients/build.ts # src/resource_clients/build_collection.ts # src/resource_clients/dataset.ts # src/resource_clients/dataset_collection.ts # src/resource_clients/key_value_store.ts # src/resource_clients/key_value_store_collection.ts # src/resource_clients/log.ts # src/resource_clients/request_queue.ts # src/resource_clients/request_queue_collection.ts # src/resource_clients/run.ts # src/resource_clients/run_collection.ts # src/resource_clients/schedule.ts # src/resource_clients/schedule_collection.ts # src/resource_clients/store_collection.ts # src/resource_clients/task.ts # src/resource_clients/task_collection.ts # src/resource_clients/user.ts # src/resource_clients/webhook.ts # src/resource_clients/webhook_collection.ts # src/resource_clients/webhook_dispatch.ts # src/resource_clients/webhook_dispatch_collection.ts
B4nan
pushed a commit
that referenced
this pull request
Sep 30, 2026
Non-public members in this repo carried a leading underscore on top of the `private` / `protected` keyword. Crawlee v4 dropped that convention and we agreed to follow it here. This renames every such member across `src/`, so none are left. `LoggerActorRedirect._log()` and `_outputWithConsole()` in `src/resource_clients/log.ts` keep their names, since both come from the `Logger` base class in `@apify/log`. The code samples in `CONTRIBUTING.md` and the public API report follow the rename. ## Renamed helpers The protected helpers on the base clients show up in the API report, so subclasses calling the old names have to switch. Where a bare name would collide with a public method, the helper got a suffix. | Old | New | | --- | --- | | `_url` | `buildUrl` | | `_publicUrl` | `buildPublicUrl` | | `_params` | `buildParams` | | `_subResourceOptions` | `subResourceOptions` | | `_toSafeId` | `toSafeId` | | `_listPaginatedFromCallback` | `listPaginatedFromCallback` | | `_get` | `getResource` | | `_update` | `updateResource` | | `_delete` | `deleteResource` | | `_waitForFinish` | `waitForJobFinish` | | `_list` | `listResources` | | `_listPaginated` | `listResourcesPaginated` | | `_create` | `createResource` | | `_getOrCreate` | `getOrCreateResource` | | `_batchAddRequests` | `addRequestBatch` | | `_batchAddRequestsWithRetries` | `addRequestBatchWithRetries` | The names match what #1046 picked for the files it touches, so whichever of the two lands second rebases onto near-identical lines. ## ApifyApiError.clientMethod `clientMethod` scrapes the stack with `\._?([A-Za-z]+)`, and the underscore was what turned an internal frame like `ActorCollectionClient._list` into the public-looking `list`. A public method that returns the promise of a shared helper without awaiting it leaves only the helper's frame on the async stack, so after the rename the field would report `listResources` to users. A `PUBLIC_METHOD_BY_HELPER` map in `apify_api_error.ts` maps helper frames back to the public method, and `test/apify_api_error.test.ts` covers both the Node and the browser build. Closes #1057 *✍️ Drafted by Claude Code*
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.
Non-public members in this repo carried a leading underscore on top of the
private/protectedkeyword. Crawlee v4 dropped that convention and we agreed to follow it here.This renames every such member across
src/, so none are left.LoggerActorRedirect._log()and_outputWithConsole()insrc/resource_clients/log.tskeep their names, since both come from theLoggerbase class in@apify/log. The code samples inCONTRIBUTING.mdand the public API report follow the rename.Renamed helpers
The protected helpers on the base clients show up in the API report, so subclasses calling the old names have to switch. Where a bare name would collide with a public method, the helper got a suffix.
_urlbuildUrl_publicUrlbuildPublicUrl_paramsbuildParams_subResourceOptionssubResourceOptions_toSafeIdtoSafeId_listPaginatedFromCallbacklistPaginatedFromCallback_getgetResource_updateupdateResource_deletedeleteResource_waitForFinishwaitForJobFinish_listlistResources_listPaginatedlistResourcesPaginated_createcreateResource_getOrCreategetOrCreateResource_batchAddRequestsaddRequestBatch_batchAddRequestsWithRetriesaddRequestBatchWithRetriesThe names match what #1046 picked for the files it touches, so whichever of the two lands second rebases onto near-identical lines.
ApifyApiError.clientMethod
clientMethodscrapes the stack with\._?([A-Za-z]+), and the underscore was what turned an internal frame likeActorCollectionClient._listinto the public-lookinglist. A public method that returns the promise of a shared helper without awaiting it leaves only the helper's frame on the async stack, so after the rename the field would reportlistResourcesto users. APUBLIC_METHOD_BY_HELPERmap inapify_api_error.tsmaps helper frames back to the public method, andtest/apify_api_error.test.tscovers both the Node and the browser build.Closes #1057
✍️ Drafted by Claude Code