1.4 KiB
1.4 KiB
packages/core
Scope
- This package owns scraper behavior, parsing, result shapes, shared cookie handling, and shared HTTP utilities.
- Put marketplace-specific logic in
src/scrapers/*.ts. - Put reusable cross-marketplace helpers in
src/utils/*only when at least two callers need them.
Keep Stable
- Cookie loading order is a hard invariant: parameter > env var > file.
- Exported names in
src/index.tsare the package contract forapi-serverandmcp-server. - Keep result field semantics stable across refactors; adapter packages should not need to reinterpret core results.
Editing Rules
- New marketplace behavior belongs here, not in route or protocol layers.
- Isolate marketplace-specific hacks/selectors inside the owning scraper file unless they are genuinely shared.
- If a new helper is scraper-local, keep it local. Do not promote it into
utilsearly. - If you change shared types or exports, check downstream imports in both adapter packages.
- eBay SplashUI challenge handling needs raw
fetchfor manual redirects andgetSetCookie(); usefetchHtmlonly once the flow only needs final HTML.
Tests
- Tests live in
test/*.test.tsand usebun:test. - Mock network and file edges. Do not depend on live cookies, live HTTP, wall clock timing, or external sessions.
- Favor parser/extraction tests with fixture-like inline HTML/JSON over broad end-to-end behavior.
Verify
bun test packages/core/testbun run ci