Headless-sdk v2.2.0 — @spwig/sdk 2.2.0

Spwig headless-sdk v2.2.0 updates the platform’s core tools to better handle pricing, subscriptions, and regional settings while aligning with Spwig 1.7.1’s backend improvements. This release focuses on accuracy, flexibility, and smoother integration for merchants, agencies, and developers.

What’s new

  • Enhanced product pricing: Products now show sale-aware prices via effective_price_amount, with clearer visibility into discounts and stock status.
  • Subscription management: New tools let merchants attach reusable payment tokens to subscription lines and initiate setup for recurring payments.
  • Regional and currency support: setRegion() adapts pricing and shipping options based on the shopper’s location, while AVIF image formats improve media performance.
  • Admin refinements: Updated schema, stricter validation for bulk price changes, and clearer order metrics for better reporting.

Why it matters
Merchants gain more precise control over sales displays, subscription workflows, and regional configurations. Developers benefit from updated types and stricter validation, reducing errors. Agencies can build richer checkout experiences with improved data clarity. While some changes require code updates, the update ensures long-term alignment with Spwig’s evolving features.


Release notes

2.2.0 (2026-08-06)

Catches the SDK up to Spwig 1.7.1 (sale-aware pricing, region availability,
AVIF <picture> sources, subscription card→token capture).

:warning: This minor carries breaking changes. By SemVer it would be a major, but
it is released as a minor deliberately, and the breaks below are cheaper to absorb in-house now than to
carry a 3.0.0 boundary for a handful of first-party sites. Read the Breaking and
Migration sections before upgrading.

:warning: Breaking

  • CreatePaymentIntentInput.checkout_session_id is now number, not string.
    The backend keys CheckoutSession by integer PK; the old uuid typing/docs
    were wrong. Pass the numeric session id (you rarely need to pass it at all —
    it defaults to the active cart’s session).
  • Product.compare_at_price_amount changed meaning. It is no longer a stored
    MSRP; it is the struck-through regular price and is null unless the product
    is on sale. Render price from the new effective_price_amount + is_on_sale
    and only strike through compare_at_price_amount when is_on_sale. Same field
    name and type, so this will not raise a compile error — audit price display
    code by hand.
  • Product.is_in_stock now returns true for pre-order / backorder products,
    not only in-stock ones. Gate “buyable” UI on this; use products.availability()
    for the pre-order/backorder distinction.
  • admin AttributeAssignInput reshaped to
    { assignments: [{ attribute_id, value_ids: number[], sort_order? }] } (was
    { attributes: [{ attribute_id, values: string[] }] }). The backend now
    enforces the new shape; the old one was already incorrect.
  • admin BrandingSettingsUpdateInput no longer accepts primary_color —
    the backend never persisted it (silent no-op). It is still returned on the
    read type BrandingSettings (sourced from theme tokens).
  • admin BulkPriceUpdateInput/BulkSaleUpdateInput validation tightened:
    round_to max is now the currency precision (2, was 4); price value must be
    >= 0 (absolute) / >= -100 (percentage); sale sale_value must be > 0
    (0 is rejected).
  • admin AdminOrder.item_count now excludes bundle child lines, so the
    value can differ for orders containing bundles.

Added

  • store.setRegion(country) → POST /api/store/set-region/. Sets the
    shopper’s ship-to region from an ISO-3166 country the store ships to; drives
    Product.ships_to_region / regional stock and may switch the active currency.
    New SetRegionResult type.
  • subscriptions.beginTokenSetup(providerAccountId) →
    POST /api/subscriptions/tokens/begin-setup/. Provider-agnostic setup for a
    reusable subscription payment method; returns a SubscriptionSetupBundle.
  • cart.attachSubscriptionToken(itemId, paymentTokenId) →
    POST /api/cart/items/{id}/attach-subscription-token/. Binds a reusable
    PaymentToken to a subscription line so the first cycle and renewals can be
    charged (card capture is deferred to checkout).
  • Product / ProductList sale + region fields: effective_price_amount,
    is_on_sale, ships_to_region.
  • AVIF <picture> support: new PictureSources type and image_sources
    on ProductImage, ProductVariant, Category (+ banner_image_sources),
    plus primary_image.image_sources. Emitted alongside the existing URL fields.
  • CartItem subscription + sale fields: is_on_sale, regular_total,
    pricing_tier_details, subscription_billing_display, subscription_unit_price.
  • AddToCartInput subscription fields: is_subscription,
    subscription_plan_id, pricing_tier_id, optional payment_token_id
    (attach later via attachSubscriptionToken(); subscription add-to-cart
    requires an authenticated shopper).
  • SearchResult regular_price and is_on_sale; price is now the
    sale-aware display price.
  • admin analytics: SalesComparison gains current_order_count,
    previous_order_count, daily_breakdown; DashboardAnalytics gains
    custom_range.
  • admin MessageReplyResponse type; messages.reply() is now typed with
    it (includes email_error when the reply saved but the email failed to send).
  • SVG store logos are now accepted by admin settings.uploadLogo()
    (sanitised server-side); no request-shape change.

Fixed

  • Regenerated src/generated/schema.ts from the 1.7.1 api-schema.yml
    (3 new endpoints, 4 new component schemas, 14 changed). The committed types
    were a release behind the contract.

Migration

Consumers are Spwig’s own installations. Do the following, in order:

  1. Switch product price rendering to effective_price_amount + is_on_sale;
    treat compare_at_price_amount as the strike-through value (null off-sale).
  2. If you pass checkout_session_id to payments.createIntent(), pass a number.
  3. Update any admin attribute-assign call to the assignments / value_ids
    shape and drop primary_color from branding updates.
  4. Re-check is_in_stock usage where pre-orders should be treated differently.

View the full release on GitHub