Picnic is moving its app from Fusion pages to React Server Components (RSC) pages. 5.0 prepares the library for that: methods return models of what the app shows, and every page is read through one loader, so a page that changes format only changes the library's internals.
Upgrading from 4.x? MIGRATING.md lists every breaking change since 4.12.0 with what to use instead.
Highlights
- Data the way the app shows it: search, product and recipe details, the cookbook lists, the cart, the categories, deliveries with tracking and wallet transactions, read from the same routes and pages as the current app (version 1.251.0).
- Pages in either format:
app.getPage(id)returns{ format: "fusion", page }or{ format: "rsc", content }from one request. A method whose page Picnic moves to a format it doesn't read yet throws anUnexpectedPageFormatErrornaming the page. - Clear names: a type with a plain name (
Cart,Delivery,Product,Recipe) is a camelCase model; a type with aRawprefix is Picnic's JSON as Picnic sends it. Untyped parts areunknowninstead ofany. - New services and errors: checkout has its own service (
client.checkout). Error statuses throw aPicnicApiErrorwith the HTTP status and Picnic's error code, e.g.AUTH_INVALID_CREDfor a wrong password andOTP_NOT_VALIDfor a wrong 2FA code. - Safer custom requests:
sendRequesttakes an options object, and sends the user's auth key only to the API's own host unless you pass{ authenticated: true }. - Removed: methods for routes the current app doesn't use (
cart.addProductsToCart,userOnboarding, the reminders methods), the raw Fusion page getters and the parts deprecated in 4.x.
Not tested against the live API
Checkout and cancelling a delivery need a real order, so they are only covered by unit tests. Everything was tested with an NL account.
What's Changed
- feat!: update to app version 1.251.0 and follow the app's RSC pages by @MRVDH in #66
- feat: read product and recipe details the way the app shows them by @MRVDH in #67
- feat: read the cookbook lists and the cart the way the app shows them by @MRVDH in #68
- feat: product categories, delivery details, tracking and wallet payments by @MRVDH in #69
- feat!: 5.0.0, read pages in either format and return models by @MRVDH in #70
- chore!: remove the deprecated product fields and complete the migration guide by @MRVDH in #71
Full Changelog: v4.12.0...v5.0.0