feat: prep repo for npm consumption, fix safePushData correctness bugs#1
Merged
yaroslav-tykhovetskyi-apify merged 3 commits intoJul 1, 2026
Merged
Conversation
Package now ships compiled dist/ output (main/types/exports point there) so google-search and google-maps can resolve it via their own tsc builds, instead of raw .ts source. Pulled eslint/prettier/knip/husky config straight from apify-test-tools for consistency across Apify TS repos, and fixed the broken @apify/tsconfig extends (dependency was never installed). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The give-up path (maxAttempts exceeded) always reported errors: [] for dropped items, discarding the last validation errors that were actually tracked elsewhere in the same function. maxAttempts <= 0 also made the reported attempts count lie about how many times pushFn was really called, since the initial push always happens before this option is even consulted. And a malformed/unexpected itemPosition in the error payload crashed on working[i] being undefined instead of being ignored. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adapted from apify-test-tools' workflow set, trimmed to just the code checks and test matrix — no publish/release automation yet, since that needs npm registry access and secrets this repo doesn't have configured. Uses npm ci instead of npm install, which means package-lock.json now has to be committed (it was gitignored before). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Why?
This library is about to be consumed by google-search and google-maps as a real npm dependency, but the repo wasn't ready for that: package.json still pointed main/exports at raw TypeScript source, which doesn't work for those repos since they resolve dependencies through their own tsc build to dist/*.js. Separately, a full read-through of the retry logic turned up a few real correctness issues worth fixing before anyone depends on this.
What?
Package now builds to dist/ and ships compiled JS plus type declarations, with main/types/exports pointing there. Pulled the eslint, prettier, knip, and husky config over from apify-test-tools so this repo follows the same conventions as the rest of our TypeScript projects, and fixed the @apify/tsconfig extends that was referencing a dependency that was never actually installed. Tests now run against the compiled output instead of relying on Node's experimental type-stripping importing .ts files directly.
On the library side, three bugs are fixed. When safePushData gave up after exhausting maxAttempts, dropped items always reported an empty errors array even though the real validation errors were available elsewhere in the function, so callers had no way to know why an item was finally dropped. Passing maxAttempts of zero or a negative number made the reported attempts count lie about how many times pushFn was actually called, since the initial push always happens before that option is even read. And a malformed or unexpected itemPosition in the error payload would crash with a TypeError instead of being safely ignored.
Also added GitHub Actions CI, adapted from apify-test-tools: lint, type-check, build, and a unit test matrix run on every PR and on push to master. Left out the publish and release automation for now, since that needs npm registry access and secrets this repo doesn't have set up yet, and it's not decided whether this ships to the registry or stays a git-URL dependency. package-lock.json is now committed since the CI uses npm ci, which needs it.
Further notes
Added regression tests for all three safePushData fixes. Full npm run ci (typecheck, lint, format check, the pushdata guard, build, and tests) passes clean, and npm pack --dry-run confirms the published tarball only contains the compiled library, not the test suite.