Fixes: nodenext type resolution, Bun compatibility, snapshot status polling#29
Open
karaposu wants to merge 3 commits into
Open
Fixes: nodenext type resolution, Bun compatibility, snapshot status polling#29karaposu wants to merge 3 commits into
karaposu wants to merge 3 commits into
Conversation
SnapshotStatusResponseSchema validated the /datasets/v3/progress status field against a fixed list (running|ready|failed|cancelled|error). The API owns this vocabulary and emits values the SDK had not enumerated (e.g. "starting"), so Zod validation threw and killed the polling loop — affecting every async platform scraper. Validate the status field by shape (a non-empty string) instead of membership. pollUntilReady already acts only on terminal states, so unknown lifecycle values flow through and polling continues; malformed responses are still rejected. Also fix an adjacent bug in the same path: "cancelled" was not treated as terminal, so a cancelled snapshot polled until timeout instead of stopping. Adds regression tests for unknown/empty/non-string status and for the cancelled terminal case.
…ta#24) Bun's bundled undici omits the optional `dns` interceptor, so composing the dispatcher chain called `dns()` and threw "dns is not a function", crashing the Transport constructor at client init on Bun. Detect each interceptor by capability (typeof === 'function') and compose only those the runtime provides. On Node this is unchanged (dns + retry present); on Bun `dns` is skipped (undici falls back to the platform resolver, requests still work), and it self-retires if Bun later ships dns.
…resolution
Shipped declarations used extensionless relative imports (e.g. `export { bdclient } from './client'`), which node16/nodenext resolution rejects (TS2834), silently degrading the SDK's public types to `any` for consumers on those modes. They resolved only under moduleResolution:bundler — the mode the declaration build itself used.
Author explicit `.js` on every relative specifier in src/ (551 across 184 files) so tsc emits nodenext-resolvable .d.ts under the existing build; `.js` still resolves to `.ts` under bundler and rollup, so the JS bundle and typecheck are unchanged.
Add scripts/smoke-dist.mjs (wired into `build`): it loads all four entry points in both ESM and CJS from the built dist/ and constructs the client, so a broken emitted specifier fails the build instead of shipping. scripts/add-js-extensions.mjs is the AST codemod that applied the change.
Verified in a nodenext consumer project (skipLibCheck:false): no TS2834, and real types resolve on both the import and require paths.
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.
Three independent fixes:
.json relative imports so shipped.d.tsresolve undernode16/nodenext(was TS2834 / silentany); adds a build-time smoke over the built ESM/CJS outputdns) no longer crashes the Transport constructor; Node unchangedstarting) so the poll loop doesn't throw mid-runVerification: sanity + build + built-package smoke clean; 351/351 unit tests; nodenext verified in a real consumer on both
importandrequire.