Skip to content
Kitenzo Headless is currently invite-only. To enable it on your store, email support@kitenzo.com.

@kitenzo/core

v0.2.6 · published

Framework-agnostic SDK. Zero runtime dependencies. Everything here is also re-exported by @kitenzo/react.

Terminal window
npm install @kitenzo/core

Default API base URL: https://live.bb.eight-cdn.com/api/headless/v1 (override with baseUrl).

These are the exact top-level exports of @kitenzo/core:

ExportKindPurpose
KitenzoClientclassREST client for the headless API.
KitenzoErrorclassThrown on non-2xx responses (.status, .response).
createBundleBuilderfunctionFramework-agnostic builder state machine.
createBundleEmbedfunctionMount the full bundle UI (Mode 1).
addBundleToCartfunctionBuild + apply cart lines and _bundles.
buildCartPayloadfunctionReturn { lines, attributes } for a configured bundle.
buildCartLinesfunctionReturn just the cart lines.
calculatePricefunctionLocal price calculation (flat + tiered).
formatMoneyfunctionFormat a number with a Shopify money format.
computeSectionQuantityfunctionTotal quantity selected in a section.
isSectionMetfunctionWhether a section meets its min/max.

Plus all TypeScript types.

new KitenzoClient({ apiKey, apiVersion?, baseUrl? })
MethodReturnsDescription
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.

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.

FunctionSignatureNotes
calculatePrice(bundle, selections, currency?) => PriceResponseHandles flat + tiered, all operations and operator modes.
formatMoney(amount, moneyFormat) => stringSupports {{amount}}, {{amount_no_decimals}}, comma/apostrophe separators, etc.
computeSectionQuantity(selections, sectionId) => numberTotal quantity in a section.
isSectionMet(selections, section) => booleanSection meets its constraints.
addBundleToCart / buildCartPayload / buildCartLinesSee Cart helpers.
createBundleEmbed(container, options) => BundleEmbedInstanceSee Vanilla embed.