github MRVDH/picnic-api v4.0.0

latest releases: v4.1.0, v4.0.1
one month ago

picnic-api v4.0.0 — Changelog

Highlights

v4 is a full rewrite of picnic-api. The monolithic PicnicClient class has been replaced with a domain-based service architecture — 12 focused services, 62+ methods, comprehensive Fusion/PML type coverage, and many new API routes that weren't available before.


⚠️ Breaking Changes

Domain-based API access

All methods have moved from the flat client.method() pattern into domain namespaces:

- client.login(username, password)
+ client.auth.login(username, password)

- client.getShoppingCart()
+ client.cart.getCart()

- client.search("coffee")
+ client.catalog.search("coffee")

- client.getDeliveries()
+ client.delivery.getDeliveries()

- client.getConsentSettings()
+ client.consent.getConsentSettings()

- client.getPaymentProfile()
+ client.payment.getPaymentProfile()

Method renames

v3 v4
getShoppingCart() cart.getCart()
addProductToShoppingCart() cart.addProductToCart()
removeProductFromShoppingCart() cart.removeProductFromCart()
clearShoppingCart() cart.clearCart()
getMgmDetails() Folded into user.getProfileMenu()
getCustomerServiceContactInfo() customerService.getContactInfo()
getCategories() / getLists() Removed (replaced by Fusion page endpoints)
getArticle() Removed (use catalog.getProductDetails())

HttpClient extracted

PicnicClient now extends HttpClient. The base client handles request construction, auth headers, and error handling. The public sendRequest() method remains available for custom/undocumented endpoints.

Types reorganized

The single types/picnic-api.ts file has been replaced by:

  • types/common.ts — Shared types (ApiConfig, CountryCode, ImageSize, Decorator union, etc.)
  • types/fusion.ts — 850+ lines of Fusion/PML page rendering types
  • domains/*/types.ts — Per-domain request/response types

✨ New Domains

📄 content — Content pages

  • getFaqContent() — FAQ page (PML format)
  • getSearchEmptyState() — Search empty state content

🍳 recipe — Recipes & cookbook

  • getRecipesPage() — Browse recipes page
  • getRecipeDetailsPage(recipeId) — Recipe detail page
  • saveRecipe(recipeId) / unsaveRecipe(recipeId) — Save/unsave recipes
  • addProductToRecipe() / removeProductFromRecipe() — Cart mutations with recipe context

👋 userOnboarding — Onboarding flows

  • setHouseholdDetails(details) — Set household info
  • setBusinessDetails(details) — Set business info
  • subscribePush(topics) — Subscribe to push notification topics

🆕 New Routes (on existing domains)

app

  • getBootstrapData() — Tab bar config, feature flags, SDK configs
  • getPage(pageId) — Generic Fusion page renderer for any page ID
  • resolveDeeplink(url) — Resolve deeplinks to in-app targets

auth

  • logout() — Logout and invalidate session
  • generatePhoneVerificationCode(phoneNumber) — Phone verification
  • verifyPhoneNumber(phoneNumber, code) — Confirm phone number

user

  • submitSuggestion(suggestion) — Submit product/feature suggestions
  • registerPushToken(pushToken, platform) — Register device push token
  • checkForUpdates() — App update check

cart

  • removeGroupFromCart(groupId) — Remove an entire product group
  • getMinimumOrderValue() — Get minimum order value for the slot
  • confirmOrder(orderId) — Confirm a checked-out order

catalog

  • getProductDetails(productId) — Structured product data (parsed from Fusion page)
  • getProductDetailsPage(productId) — Raw Fusion product detail page

consent

  • getConsents(topics, strategy) — Filtered consent retrieval
  • getGeneralConsents() / setGeneralConsents() — General consent management

customerService

  • getMessages(displayPositions?) — Popup/notification messages
  • getReminders() / setReminders() — Reminder management
  • getParcels() — External carrier parcel tracking
  • getUnauthenticatedContactInfo(countryCode) — Public API (no auth required)

🛠️ New Utilities

Product detail parser (catalog/helpers.ts)

getProductDetails() wraps the Fusion product detail page and extracts structured data including: name, brand, unit quantity, unit price, display price, max order count, gallery images, description, highlights, allergens, info sections, promotions, bundle options, and similar products.

Includes helpers: stripColorMarkup(), stripMarkdownFormatting(), findById(), extractMarkdowns(), findBundleContainer().


🧩 Fusion/PML Type System

Comprehensive TypeScript types covering Picnic's entire page rendering system:

  • PML primitivesStackComponent, ContainerComponent, ImageComponent, RichTextComponent, IconComponent
  • Fusion components (17) — TOUCHABLE, STEPPER, ACCORDION, MODAL, PRICE, SOCIAL_SHARE, SEARCH_RESULT_ENTITY, and more
  • Action types (7) — OPEN, EVENT, ENDPOINT, CALLBACK, RELOAD, ANALYTICS
  • Page layoutFusionPage, FlowLayout, BlockComponent, SuspenseComponent, StateBoundaryComponent
  • Bootstrap dataBootstrapData, tab configuration, Braze/Datadog SDK configs, feature flags

Don't miss a new picnic-api release

NewReleases is sending notifications on new releases.