Skip to content

chore: point apify-client at the OpenAPI-generated models branch [WIP] - #702

Draft
vdusek wants to merge 1 commit into
v4from
test/apify-client-v3-openapi-models-v4
Draft

chore: point apify-client at the OpenAPI-generated models branch [WIP]#702
vdusek wants to merge 1 commit into
v4from
test/apify-client-v3-openapi-models-v4

Conversation

@vdusek

@vdusek vdusek commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Experiment, not for merge. Points apify-client at the branch of apify/apify-client-js#985 (all output models generated from the OpenAPI spec) to see what the change does to the v4 SDK.

How the dependency is referenced

"apify-client": "github:apify/apify-client-js#feat/openapi-generated-models", the npm equivalent of pip install git+.... Two things make it work:

  • apify-client-js gained a prepare script, so a git checkout builds its own dist/. Without it the install lands with no dist/ while main/types point into it.
  • apify-client is added to onlyBuiltDependencies, since pnpm refuses build scripts for git-hosted packages otherwise.

What broke, and why

Six type errors, from two changes in the generated models:

Change Sites
Storage name and the key-value store's exclusiveStartKey/nextExclusiveStartKey gain null 4
pricingPerEvent.actorChargeEvents and ActorChargeEvent.eventPriceUsd become optional 2

The first group is normalised where the client meets Crawlee, in the backend adapters: the API spells absence as null, Crawlee spells it undefined. The second is handled in ChargingManager; an absent per-event price counts as no charge, which is worth a second opinion.

Notably handledAt and retryCount do not break here. On the v3/master line they do, because the SDK relies on ApifyClient structurally satisfying Crawlee's StorageClient; v4's explicit backend adapters map those fields instead.

Status

tsc (src and tests), build, unit tests, oxlint and oxfmt all pass. Platform e2e is dispatch-only, so it has to be triggered by hand on this branch.

✍️ Drafted by Claude Code

@github-actions

Copy link
Copy Markdown

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-sdk-js/actions/runs/32944382474#summary-98101870613

@vdusek vdusek changed the title chore: point apify-client at the OpenAPI-generated models branch chore: point apify-client at the OpenAPI-generated models branch [WIP] Aug 26, 2026
vdusek added a commit to apify/apify-client-js that referenced this pull request Aug 27, 2026
## Description

- API response types are now generated from the OpenAPI specification
instead of hand-written, using
[openapi-typescript](https://openapi-ts.dev/).
- `pnpm generate:types` downloads the specification into git-ignored
`tmp/` and writes `src/generated/api.ts`. Only the specification version
is committed, in `package.json`.
- Nothing re-exports the generated file: `src/models.ts` declares each
published model on top of a generated schema, and `src/spec_guards.ts`
asserts every deviation at compile time.
- A nightly CI workflow regenerates and opens a pull request if anything
changed.
- It follows the same approach as the Python API client.

## Breaking

- Several types were outright wrong, and many fields gained null or
became optional to match what the API actually returns.
- Two runtime changes: `parseDateFields()` depth 3 -> 4, and the
key-value store's next-key check widens to `!= null`.
- Everything is described in the v3 upgrading guide.

## Downstream

- apify/apify-sdk-js#702 runs the v4 SDK against this branch: six type
errors, all absorbed by v4's backend adapters. Build, typecheck, unit
tests, lint and format pass.
- `handledAt` and `retryCount` break only on the v3 line, where the SDK
relies on structural `StorageClient` compatibility.

## Open

- `notify_on_failure` needs a `SLACK_WEBHOOK_URL` secret this repo does
not have.

*✍️ Drafted by Claude Code*
vdusek added a commit to apify/apify-client-js that referenced this pull request Sep 8, 2026
- API response types are now generated from the OpenAPI specification
instead of hand-written, using
[openapi-typescript](https://openapi-ts.dev/).
- `pnpm generate:types` downloads the specification into git-ignored
`tmp/` and writes `src/generated/api.ts`. Only the specification version
is committed, in `package.json`.
- Nothing re-exports the generated file: `src/models.ts` declares each
published model on top of a generated schema, and `src/spec_guards.ts`
asserts every deviation at compile time.
- A nightly CI workflow regenerates and opens a pull request if anything
changed.
- It follows the same approach as the Python API client.

- Several types were outright wrong, and many fields gained null or
became optional to match what the API actually returns.
- Two runtime changes: `parseDateFields()` depth 3 -> 4, and the
key-value store's next-key check widens to `!= null`.
- Everything is described in the v3 upgrading guide.

- apify/apify-sdk-js#702 runs the v4 SDK against this branch: six type
errors, all absorbed by v4's backend adapters. Build, typecheck, unit
tests, lint and format pass.
- `handledAt` and `retryCount` break only on the v3 line, where the SDK
relies on structural `StorageClient` compatibility.

- `notify_on_failure` needs a `SLACK_WEBHOOK_URL` secret this repo does
not have.

*✍️ Drafted by Claude Code*
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.

2 participants