@kitenzo/core
v0.2.6 · published
Framework-agnostic SDK. Zero runtime dependencies. Everything here is also re-exported by @kitenzo/react.
npm install @kitenzo/coreDefault API base URL: https://live.bb.eight-cdn.com/api/headless/v1 (override with baseUrl).
Public exports
Section titled “Public exports”These are the exact top-level exports of @kitenzo/core:
| Export | Kind | Purpose |
|---|---|---|
KitenzoClient | class | REST client for the headless API. |
KitenzoError | class | Thrown on non-2xx responses (.status, .response). |
createBundleBuilder | function | Framework-agnostic builder state machine. |
createBundleEmbed | function | Mount the full bundle UI (Mode 1). |
addBundleToCart | function | Build + apply cart lines and _bundles. |
buildCartPayload | function | Return { lines, attributes } for a configured bundle. |
buildCartLines | function | Return just the cart lines. |
calculatePrice | function | Local price calculation (flat + tiered). |
formatMoney | function | Format a number with a Shopify money format. |
computeSectionQuantity | function | Total quantity selected in a section. |
isSectionMet | function | Whether a section meets its min/max. |
Plus all TypeScript types.
KitenzoClient
Section titled “KitenzoClient”new KitenzoClient({ apiKey, apiVersion?, baseUrl? })| Method | Returns | Description |
|---|---|---|
listBundles() | Promise<Bundle[]> | Published bundles (no product data). |
getBundle(id) | Promise<BundleDetail> | One bundle, with products/variants merged in. |
submitBundle(bundle, selections, { countryCode? }) | Promise<SubmitBundleResult> | Validate + configure. |
getSettings() | Promise<ShopSettings> | Shop currency, money format, features. |
See Provider & client for full options and examples.
createBundleBuilder(bundle)
Section titled “createBundleBuilder(bundle)”Returns a state machine with subscribe / getState (drives useSyncExternalStore in React, or vanilla DOM):
Methods: addItem(sectionId, variantId, quantity?), removeItem(sectionId, variantId), updateQuantity(sectionId, variantId, quantity), reset(), nextSection(), prevSection(), goToSection(index), getSectionQuantity(sectionId), getState(), subscribe(listener).
Snapshot (getState()): selections, currentSectionIndex, currentSection, isSectionValid, isValid, isComplete, allItems, errors.
The React hook useBundleBuilder wraps this.
Utilities
Section titled “Utilities”| Function | Signature | Notes |
|---|---|---|
calculatePrice | (bundle, selections, currency?) => PriceResponse | Handles flat + tiered, all operations and operator modes. |
formatMoney | (amount, moneyFormat) => string | Supports {{amount}}, {{amount_no_decimals}}, comma/apostrophe separators, etc. |
computeSectionQuantity | (selections, sectionId) => number | Total quantity in a section. |
isSectionMet | (selections, section) => boolean | Section meets its constraints. |
addBundleToCart / buildCartPayload / buildCartLines | — | See Cart helpers. |
createBundleEmbed | (container, options) => BundleEmbedInstance | See Vanilla embed. |