Framework-agnostic commerce logic primitives for Ecommaps storefront applications.
Use this package for reusable business logic that should not depend on:
- Next.js
- React
- AI SDK
This package is intended for server actions, API routes, workers, and backend services.
pnpm add @ecommaps/storefront-kitresolveVariantSelection(product, input)variantMatchesColorAndSize(product, variant, color, size)
Behavior:
- supports multilingual color/size synonyms
- enforces exact size semantics (prevents wrong size fallback)
- returns
requires_selectionwhen match is ambiguous
normalizeProductCard(product)normalizeCartSummary(cart)
classifyPromotionStatus(promotion, context)promotionStatusLabel(status)
import {
resolveVariantSelection,
normalizeProductCard,
normalizeCartSummary,
classifyPromotionStatus,
} from "@ecommaps/storefront-kit";
const selection = resolveVariantSelection(product, {
variant_id: undefined,
color: "red",
size: "L",
});
const card = normalizeProductCard(product);
const cart = normalizeCartSummary(rawCart);
const promoState = classifyPromotionStatus(
{ code: "DISCOUNT20", min_order_amount: 5000 },
{ enteredCode: "DISCOUNT20", cartTotal: 7000, explicitValidationPassed: true },
);- Runtime: Node.js 20+
- No UI framework dependency
- Semver-stable function contracts