# Repeatable data export example

This owned fixture uses made-up records and a loopback API. It demonstrates a collector, not a customer app or a live scraping service.

Run with Bun from this folder:

```sh
bun verify.ts
```

The test starts a server on a random 127.0.0.1 port. It saves a JSON checkpoint in a new temporary folder and prints its path. The server stops when the test ends. The checkpoint remains for inspection.

## What it tests

- A page fails after three attempts; earlier records stay saved.
- A new collector loads the checkpoint from disk and resumes at page two.
- Repeated IDs produce one record; the later value replaces the earlier value.
- An empty final page marks the export complete.
- Resuming a complete export makes no new requests.
- A fresh full run produces the same final records.
- A repeated cursor stops the run instead of looping.
- An invalid record stops the run before saving that page.

The collector validates each page before changing its record map. The test saves through a temporary file and rename, keeping the previous checkpoint until the new page is written. This demo uses immediate retries against a controlled server; a deployed collector needs service-specific backoff and rate limits.

## Record schema

| Field | Type | Meaning |
|---|---|---|
| id | string | Stable record identity |
| name | string | Display name |
| priceMinor | nonnegative integer | Price in the currency's minor unit |
| currency | three uppercase letters | Currency code used by this fixture |

Expected final IDs: a, b, c. Their prices are 100, 250 and 300 USD minor units. The duplicate b changes from 200 to 250 on page two.
