Skip to content

refactor!: drop the underscore prefix from non-public members - #1059

Merged
vdusek merged 8 commits into
v3from
refactor/drop-underscore-prefix
Sep 14, 2026
Merged

vdusek merged 8 commits into
v3from
refactor/drop-underscore-prefix

Conversation

@vdusek

@vdusek vdusek commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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

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.
@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 10, 2026
@vdusek vdusek self-assigned this Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-client-js/actions/runs/34817133912#summary-103890084253

@vdusek
vdusek requested a review from janbuchar September 10, 2026 18:05
@vdusek
vdusek marked this pull request as ready for review September 10, 2026 18:05
@vdusek
vdusek requested a review from szaganek as a code owner September 10, 2026 18:05
…e-prefix

# Conflicts:
#	src/resource_clients/dataset.ts

@janbuchar janbuchar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, nice job! Maybe we should also make private methods and attributes #private while you're at it?

Comment thread src/apify_api_error.ts Resolved
…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
@vdusek
vdusek requested a review from janbuchar September 14, 2026 07:21

@janbuchar janbuchar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vdusek
vdusek merged commit b7d1df9 into v3 Sep 14, 2026
8 checks passed
@vdusek
vdusek deleted the refactor/drop-underscore-prefix branch September 14, 2026 08:56
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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants