Skip to content

feat: prep repo for npm consumption, fix safePushData correctness bugs#1

Merged
yaroslav-tykhovetskyi-apify merged 3 commits into
masterfrom
prep-package-and-safepushdata-fixes
Jul 1, 2026
Merged

feat: prep repo for npm consumption, fix safePushData correctness bugs#1
yaroslav-tykhovetskyi-apify merged 3 commits into
masterfrom
prep-package-and-safepushdata-fixes

Conversation

@yaroslav-tykhovetskyi-apify

@yaroslav-tykhovetskyi-apify yaroslav-tykhovetskyi-apify commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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.

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>
@yaroslav-tykhovetskyi-apify yaroslav-tykhovetskyi-apify changed the title Prep repo for npm consumption, fix safePushData correctness bugs feat: prep repo for npm consumption, fix safePushData correctness bugs Jul 1, 2026
@yaroslav-tykhovetskyi-apify
yaroslav-tykhovetskyi-apify merged commit 7ed1db2 into master Jul 1, 2026
13 of 14 checks passed
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.

1 participant