@shoppexio/storefront 1.0.99 → 1.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,27 +1,11 @@
1
+ import * as src from 'src';
1
2
  import { NavigationMenuSlot } from '@shoppex/contracts/navigation';
2
3
  export { NavigationMenuSlot } from '@shoppex/contracts/navigation';
3
4
  import { StorefrontDeliveryType } from '@shoppex/contracts/storefront-delivery-type';
4
- import * as src from 'src';
5
5
  import { createApiClient } from '@shoppex/contracts/api-client';
6
6
  import { CustomerWarrantyClaimWire, CustomerPortalAffiliateCreateLinkWire, CustomerPortalDashboardWire, CustomerPortalPaginatedInvoicesWire, CustomerPortalInvoiceDetailWire, CustomerLoyaltyWire, CustomerLoyaltyRedeemWire, CustomerWarrantyListWire, CustomerPortalNotificationPreferencesWire } from '@shoppex/contracts/customer-account-wire';
7
7
  export { CATALOG_UNIT_PRICE_DECIMAL_PLACES, CATALOG_UNIT_PRICE_FORMAT_OPTIONS, PAYABLE_AMOUNT_DECIMAL_PLACES, roundPayableAmount } from '@shoppex/contracts/catalog-unit-price';
8
8
 
9
- interface CacheStats {
10
- hits: number;
11
- misses: number;
12
- pendingRequests: number;
13
- entries: number;
14
- }
15
- declare function getCacheStats(): CacheStats;
16
- declare function clearCache(): void;
17
- declare function invalidateCache(prefixOrKey: string): void;
18
-
19
- /**
20
- * Formatting Utilities
21
- */
22
- declare function createFormatter(currency?: string, locale?: string): Intl.NumberFormat;
23
- declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
24
-
25
9
  /**
26
10
  * SDK Configuration Types
27
11
  */
@@ -1211,6 +1195,86 @@ interface CartStats {
1211
1195
  total_price_is_estimate: boolean;
1212
1196
  }
1213
1197
 
1198
+ declare function getCartCoupon(): string | null;
1199
+ declare function getCartCouponSource(): CartCodeSource | null;
1200
+ declare function setCartCoupon(coupon: string | null | undefined, source?: CartCodeSource): string | null;
1201
+ declare function clearCartCoupon(): void;
1202
+ declare function getCart(): CartItem[];
1203
+ /** Resolve a cart line_id for product+variant. When multiple configs exist, returns the first line. */
1204
+ declare function resolveCartLineId(productId: string, variantId: string, cart?: CartItem[]): string;
1205
+ declare function getCartItemCount(): number;
1206
+ declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1207
+ declare function setCartItem(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1208
+ /**
1209
+ * Patch one cart line.
1210
+ *
1211
+ * TRI-STATE BOUNDS: `min_quantity`/`max_quantity` accept `null` to DELETE the
1212
+ * stored bound — see {@link CartItemUpdate}. `undefined` (or an absent key)
1213
+ * leaves it alone, which is why a removed ceiling needs its own spelling.
1214
+ *
1215
+ * NO-OP UPDATES DO NOT WRITE. An update that leaves the cart byte-identical
1216
+ * returns without touching storage: no metadata bump, no `version` increment,
1217
+ * and — because the storage write is what other tabs observe — no `storage`
1218
+ * event. Writing anyway made an ineffective heal indistinguishable from a real
1219
+ * cart change, and two tabs healing the same line could hand the event back and
1220
+ * forth indefinitely. Line-shape healing of a legacy stored row is NOT this
1221
+ * function's job: `normalizeCartItems` clamps and repairs on every READ, which
1222
+ * is the chokepoint every access already flows through.
1223
+ */
1224
+ declare function updateCartItem(lineId: string, updates: CartItemUpdate): void;
1225
+ declare function removeFromCart(lineId: string): void;
1226
+ /**
1227
+ * Discards the cart entirely — and with it the proof that describes it.
1228
+ *
1229
+ * PAYMENT PATH. `latestQuoteToken` is evidence about a specific cart, and this
1230
+ * is the one mutation after which that cart does not exist in any form. Held
1231
+ * across the clear, the proof outlives its subject: a caller that clears and
1232
+ * re-adds (Buy Now REPLACES the cart) hands `/from-cart` a token bound to the
1233
+ * previous cart's hash, which is refused as `quote_token_stale` — a hand-off
1234
+ * dead-ended by a proof nobody asked for. And with no re-quote in between there
1235
+ * is nothing to replace it with, so the retry is refused identically.
1236
+ *
1237
+ * Only this path clears it. Every OTHER mutation turns one cart into another
1238
+ * cart, where a proof that no longer matches is the server's to refuse: it
1239
+ * answers `quote_token_stale`, the surfaces re-quote, and the buyer approves the
1240
+ * new total. Dropping the proof there instead would silently remove the approved
1241
+ * -total ceiling from a checkout that raced the re-quote, which is the failure
1242
+ * the token exists to prevent.
1243
+ */
1244
+ declare function clearCart(): void;
1245
+ declare function createCartBackup(): void;
1246
+ declare function restoreCartFromBackup(): boolean;
1247
+ declare function mergeBaskets(items: CartBasketMergeLine[]): CartItem[];
1248
+ declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
1249
+ declare function validateCartIntegrity(): boolean;
1250
+ declare function getCartStats(): CartStats;
1251
+ /** @internal — read by checkout(); exported only across module boundaries. */
1252
+ declare function getLatestQuoteToken(): string | null;
1253
+ declare function quoteCart(coupon?: string, currency?: string): Promise<src.SDKResponse<CartQuote>>;
1254
+
1255
+ /**
1256
+ * SDK Configuration Management
1257
+ */
1258
+
1259
+ declare function getConfig(): ShoppexConfig;
1260
+ declare function isInitialized(): boolean;
1261
+
1262
+ interface CacheStats {
1263
+ hits: number;
1264
+ misses: number;
1265
+ pendingRequests: number;
1266
+ entries: number;
1267
+ }
1268
+ declare function getCacheStats(): CacheStats;
1269
+ declare function clearCache(): void;
1270
+ declare function invalidateCache(prefixOrKey: string): void;
1271
+
1272
+ /**
1273
+ * Formatting Utilities
1274
+ */
1275
+ declare function createFormatter(currency?: string, locale?: string): Intl.NumberFormat;
1276
+ declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
1277
+
1214
1278
  /**
1215
1279
  * Pages Module
1216
1280
  *
@@ -1511,63 +1575,6 @@ declare function buildCheckoutUrl(couponOrOptions?: string | CheckoutOptions, op
1511
1575
  */
1512
1576
  declare function buildCheckoutUrlSync(): never;
1513
1577
 
1514
- declare function getCartCoupon(): string | null;
1515
- declare function getCartCouponSource(): CartCodeSource | null;
1516
- declare function setCartCoupon(coupon: string | null | undefined, source?: CartCodeSource): string | null;
1517
- declare function clearCartCoupon(): void;
1518
- declare function getCart(): CartItem[];
1519
- /** Resolve a cart line_id for product+variant. When multiple configs exist, returns the first line. */
1520
- declare function resolveCartLineId(productId: string, variantId: string, cart?: CartItem[]): string;
1521
- declare function getCartItemCount(): number;
1522
- declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1523
- declare function setCartItem(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1524
- /**
1525
- * Patch one cart line.
1526
- *
1527
- * TRI-STATE BOUNDS: `min_quantity`/`max_quantity` accept `null` to DELETE the
1528
- * stored bound — see {@link CartItemUpdate}. `undefined` (or an absent key)
1529
- * leaves it alone, which is why a removed ceiling needs its own spelling.
1530
- *
1531
- * NO-OP UPDATES DO NOT WRITE. An update that leaves the cart byte-identical
1532
- * returns without touching storage: no metadata bump, no `version` increment,
1533
- * and — because the storage write is what other tabs observe — no `storage`
1534
- * event. Writing anyway made an ineffective heal indistinguishable from a real
1535
- * cart change, and two tabs healing the same line could hand the event back and
1536
- * forth indefinitely. Line-shape healing of a legacy stored row is NOT this
1537
- * function's job: `normalizeCartItems` clamps and repairs on every READ, which
1538
- * is the chokepoint every access already flows through.
1539
- */
1540
- declare function updateCartItem(lineId: string, updates: CartItemUpdate): void;
1541
- declare function removeFromCart(lineId: string): void;
1542
- /**
1543
- * Discards the cart entirely — and with it the proof that describes it.
1544
- *
1545
- * PAYMENT PATH. `latestQuoteToken` is evidence about a specific cart, and this
1546
- * is the one mutation after which that cart does not exist in any form. Held
1547
- * across the clear, the proof outlives its subject: a caller that clears and
1548
- * re-adds (Buy Now REPLACES the cart) hands `/from-cart` a token bound to the
1549
- * previous cart's hash, which is refused as `quote_token_stale` — a hand-off
1550
- * dead-ended by a proof nobody asked for. And with no re-quote in between there
1551
- * is nothing to replace it with, so the retry is refused identically.
1552
- *
1553
- * Only this path clears it. Every OTHER mutation turns one cart into another
1554
- * cart, where a proof that no longer matches is the server's to refuse: it
1555
- * answers `quote_token_stale`, the surfaces re-quote, and the buyer approves the
1556
- * new total. Dropping the proof there instead would silently remove the approved
1557
- * -total ceiling from a checkout that raced the re-quote, which is the failure
1558
- * the token exists to prevent.
1559
- */
1560
- declare function clearCart(): void;
1561
- declare function createCartBackup(): void;
1562
- declare function restoreCartFromBackup(): boolean;
1563
- declare function mergeBaskets(items: CartBasketMergeLine[]): CartItem[];
1564
- declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
1565
- declare function validateCartIntegrity(): boolean;
1566
- declare function getCartStats(): CartStats;
1567
- /** @internal — read by checkout(); exported only across module boundaries. */
1568
- declare function getLatestQuoteToken(): string | null;
1569
- declare function quoteCart(coupon?: string, currency?: string): Promise<src.SDKResponse<CartQuote>>;
1570
-
1571
1578
  /**
1572
1579
  * Products Module
1573
1580
  *
@@ -1629,18 +1636,13 @@ declare function getStoreBannerUrl(): Promise<string | null>;
1629
1636
  type ApiClient = ReturnType<typeof createApiClient>;
1630
1637
  /**
1631
1638
  * Return a typed OpenAPI client bound to the SDK's configured API base URL.
1632
- * The client is cached per base URL and recreated when the SDK is re-initialized
1633
- * against a different host.
1639
+ * The client is cached for the config object it was built from: every init
1640
+ * creates a new config object, so a re-init rebuilds it. Keyed here instead of
1641
+ * reset from `initConfig`, so `core/config.ts` (which every SDK user loads)
1642
+ * does not import this module and its `openapi-fetch` dependency.
1634
1643
  */
1635
1644
  declare function getTypedClient(token?: string): ApiClient;
1636
1645
 
1637
- /**
1638
- * SDK Configuration Management
1639
- */
1640
-
1641
- declare function getConfig(): ShoppexConfig;
1642
- declare function isInitialized(): boolean;
1643
-
1644
1646
  /**
1645
1647
  * SDK Error Classes
1646
1648
  */
@@ -2190,14 +2192,6 @@ declare const shoppex: {
2190
2192
  resellerOrder: typeof resellerOrder;
2191
2193
  resellerWallet: typeof resellerWallet;
2192
2194
  resellerApiKeys: typeof resellerApiKeys;
2193
- init: {
2194
- (storeSlug: string, options?: src.ShoppexInitOptions): void;
2195
- (options: src.ShoppexInitOptions & {
2196
- storeId: string;
2197
- }): void;
2198
- };
2199
- isInitialized: typeof isInitialized;
2200
- getConfig: typeof getConfig;
2201
2195
  client: typeof getTypedClient;
2202
2196
  getStore: typeof getStore;
2203
2197
  getStorefront: typeof getStorefront;
@@ -2208,38 +2202,12 @@ declare const shoppex: {
2208
2202
  getStorefrontProductsPage: typeof getStorefrontProductsPage;
2209
2203
  getProduct: typeof getProduct;
2210
2204
  getCategories: typeof getCategories;
2211
- getCart: typeof getCart;
2212
- getCartItemCount: typeof getCartItemCount;
2213
- getCartCoupon: typeof getCartCoupon;
2214
- getCartCouponSource: typeof getCartCouponSource;
2215
- setCartCoupon: typeof setCartCoupon;
2216
- clearCartCoupon: typeof clearCartCoupon;
2217
- addToCart: typeof addToCart;
2218
- setCartItem: typeof setCartItem;
2219
- updateCartItem: typeof updateCartItem;
2220
- removeFromCart: typeof removeFromCart;
2221
- clearCart: typeof clearCart;
2222
- createCartBackup: typeof createCartBackup;
2223
- restoreCartFromBackup: typeof restoreCartFromBackup;
2224
- mergeBaskets: typeof mergeBaskets;
2225
- moveBasketItem: typeof moveBasketItem;
2226
- getCartStats: typeof getCartStats;
2227
- validateCartIntegrity: typeof validateCartIntegrity;
2228
- quoteCart: typeof quoteCart;
2229
- getLatestQuoteToken: typeof getLatestQuoteToken;
2230
- resolveCartLineId: typeof resolveCartLineId;
2231
2205
  checkout: typeof checkout;
2232
2206
  buildCheckoutUrl: typeof buildCheckoutUrl;
2233
2207
  buildCheckoutUrlSync: typeof buildCheckoutUrlSync;
2234
2208
  getRequestedCheckoutCurrency: typeof getRequestedCheckoutCurrency;
2235
- captureAffiliateFromUrl: typeof captureAffiliateFromUrl;
2236
2209
  validateAffiliateCode: typeof validateAffiliateCode;
2237
2210
  applyAffiliateCode: typeof applyAffiliateCode;
2238
- getAffiliateCode: typeof getAffiliateCode;
2239
- getStoredAffiliate: typeof getStoredAffiliate;
2240
- setAffiliateCode: typeof setAffiliateCode;
2241
- clearAffiliateCode: typeof clearAffiliateCode;
2242
- trackAffiliateEvent: typeof trackAffiliateEvent;
2243
2211
  validateCoupon: typeof validateCoupon;
2244
2212
  getShopReviews: typeof getShopReviews;
2245
2213
  getShopReviewsPage: typeof src.getShopReviewsPage;
@@ -2254,8 +2222,6 @@ declare const shoppex: {
2254
2222
  getMenuBySlot: typeof src.getMenuBySlot;
2255
2223
  getMenuByTitle: typeof src.getMenuByTitle;
2256
2224
  getMenuSlotTitles: typeof src.getMenuSlotTitles;
2257
- trackPageView: typeof src.trackPageView;
2258
- trackCartActivity: typeof src.trackCartActivity;
2259
2225
  getStorefrontOnlineUsers: typeof src.getStorefrontOnlineUsers;
2260
2226
  getStorefrontRecentSales: typeof src.getStorefrontRecentSales;
2261
2227
  touchStorefrontPresence: typeof src.touchStorefrontPresence;
@@ -2268,6 +2234,42 @@ declare const shoppex: {
2268
2234
  fetchPublishedThemeSettings: typeof src.fetchPublishedThemeSettings;
2269
2235
  resolveDefaults: typeof src.resolveDefaults;
2270
2236
  mergeSettings: typeof src.mergeSettings;
2237
+ init: {
2238
+ (storeSlug: string, options?: src.ShoppexInitOptions): void;
2239
+ (options: src.ShoppexInitOptions & {
2240
+ storeId: string;
2241
+ }): void;
2242
+ };
2243
+ isInitialized: typeof isInitialized;
2244
+ getConfig: typeof getConfig;
2245
+ getCart: typeof getCart;
2246
+ getCartItemCount: typeof getCartItemCount;
2247
+ getCartCoupon: typeof getCartCoupon;
2248
+ getCartCouponSource: typeof getCartCouponSource;
2249
+ setCartCoupon: typeof setCartCoupon;
2250
+ clearCartCoupon: typeof clearCartCoupon;
2251
+ addToCart: typeof addToCart;
2252
+ setCartItem: typeof setCartItem;
2253
+ updateCartItem: typeof updateCartItem;
2254
+ removeFromCart: typeof removeFromCart;
2255
+ clearCart: typeof clearCart;
2256
+ createCartBackup: typeof createCartBackup;
2257
+ restoreCartFromBackup: typeof restoreCartFromBackup;
2258
+ mergeBaskets: typeof mergeBaskets;
2259
+ moveBasketItem: typeof moveBasketItem;
2260
+ getCartStats: typeof getCartStats;
2261
+ validateCartIntegrity: typeof validateCartIntegrity;
2262
+ quoteCart: typeof quoteCart;
2263
+ getLatestQuoteToken: typeof getLatestQuoteToken;
2264
+ resolveCartLineId: typeof resolveCartLineId;
2265
+ captureAffiliateFromUrl: typeof captureAffiliateFromUrl;
2266
+ getAffiliateCode: typeof getAffiliateCode;
2267
+ getStoredAffiliate: typeof getStoredAffiliate;
2268
+ setAffiliateCode: typeof setAffiliateCode;
2269
+ clearAffiliateCode: typeof clearAffiliateCode;
2270
+ trackAffiliateEvent: typeof trackAffiliateEvent;
2271
+ trackPageView: typeof src.trackPageView;
2272
+ trackCartActivity: typeof src.trackCartActivity;
2271
2273
  };
2272
2274
 
2273
2275
  export { type AffiliateValidation, ApiError, type ApiResponse, type BlockDefinition, type BlockInstance, type BuyerRewardActivityItem, type BuyerRewards, CURRENCY_UNAVAILABLE_ERROR_CODE, type CartAddOptions, type CartAddon, type CartAppliedDiscount, type CartBasketMergeLine, type CartCodeSource, CartError, type CartItem, type CartItemUpdate, type CartLineIdentityInput, type CartMetadata, type CartPayload, type CartQuote, type CartQuoteLine, type CartStats, type Category, CheckoutCreateError, type CheckoutOptions, type CheckoutResult, type CouponValidation, type CouponValidationOptions, type CursorPagination, type CustomFieldDefinition, type CustomerAffiliateLinkInput, type CustomerEmailPreferencesPatch, type CustomerInvoicePdf, type CustomerNotificationPreferencesPatch, type CustomerProfilePatch, type CustomerSubscriptionCancelOptions, type CustomerTicketPayload, type EligibleBundleDeal, type EligibleBundleDealProduct, type EligibleCartDeal, type Feedback, type Invoice, type InvoiceProduct, type Menu, type MenuItem, NetworkError, NotInitializedError, PRODUCT_FILTER_UNSUPPORTED, type Page, type PageLayout, type PriceVariant, type Product, type ProductAddon, type ProductBundle, type ProductBundleProduct, type ProductCategory, type ProductDescriptionTab, type ProductFaq, type ProductFeedback, type ProductGroup, type ProductImage, type ProductVariant, type PublishedBuilderSettings, type PublishedThemeSettingsPayload, type ResellerCatalogQuery, type ResellerOrderItem, type ResellerOrdersQuery, type ResolvedThemeSettings, type RewardActionType, type RewardGrantStatus, type RewardProgramSummary, type RewardProgramTeaserItem, type RewardReason, type SDKResponse, type SearchOptions, type SectionDefinition, type SettingField, type Shop, type ShopFeedback, type ShopReviewsPage, type ShopReviewsSummary, type ShopTheme, type ShoppexConfig, ShoppexError, type ShoppexInitOptions, type StorefrontAddon, type StorefrontAddonBootstrap, type StorefrontAnnouncementBarAddon, type StorefrontCatalogSearchItem, type StorefrontContactTicketInput, type StorefrontContactTicketResult, type StorefrontCountdownBarAddon, type StorefrontCouponPopupModalAddon, type StorefrontCustomField, type StorefrontData, type StorefrontItem, type StorefrontOnlineUsers, type StorefrontPromoInfoCardAddon, type StorefrontRecentPurchasePopupAddon, type StorefrontRecentSaleEntry, type StorefrontRecentSales, type StorefrontSearchFilterOptions, type StorefrontSocialLinks, type Subscription, type SubscriptionFlags, type SubscriptionInterval, type ThemeBlockManifest, type ThemeConfig, type TrustedChecks, ValidationError, acceptResellerInvite, addFavorite, affiliate, affiliateStats, applyForReseller, buildStorefrontContactMessage, buildStorefrontCustomFieldPayload, buildStorefrontProductLookup, cancelSubscription, claimWarranty, collectProductSearchHaystack, computeCartLineId, createAffiliateLink, createTicket, dashboard, shoppex as default, emailPreferences, enrollAsReseller, ensureCartLineId, favorites, fetchPublishedBuilderSettings, fetchPublishedThemeSettings, filterProductsBySearchQuery, getMenu, getMenuBySlot, getMenuByTitle, getMenuSlotTitles, getMenus, getMergedStorefrontProducts, getShopReviewsPage, getStorefrontGroupProducts, getStorefrontOnlineUsers, getStorefrontRecentSales, groupMatchesSearchQuery, invoicePdf, isProductInStock, isProductOutOfStock, isStorefrontCheckboxCustomFieldValueChecked, isVariantOutOfStock, logout, loyalty, me, mergeSettings, normalizeSearchQuery, normalizeStorefrontCustomFields, notificationPreferences, order, orders, pauseSubscription, productMatchesSearchQuery, quoteResellerOrder, redeemLoyaltyPoints, removeAvatar, removeFavorite, replyToTicket, requestOtp, reseller, resellerApiKeys, resellerCatalog, resellerOrder, resellerOrders, resellerWallet, resetLicenseHwid, resolveDefaults, resolveDisplayStock, resolveStorefrontApiBaseUrl, resolveStorefrontSocialLinks, resolveVariantStockValue, resumeSubscription, revokeAllSessions, revokeSession, searchMergedStorefrontCatalog, searchMergedStorefrontCatalogItems, sessions, shoppex, stripHtmlFromText, submitStorefrontContactTicket, subscriptionBillingHistory, ticket, touchStorefrontPresence, trackCartActivity, trackPageView, undoSubscriptionCancel, updateAvatar, updateEmailPreferences, updateNotificationPreferences, updateProfile, validateStorefrontCustomFieldValue, verifyOtp, warranties };
package/dist/index.d.ts CHANGED
@@ -1,27 +1,11 @@
1
+ import * as src from 'src';
1
2
  import { NavigationMenuSlot } from '@shoppex/contracts/navigation';
2
3
  export { NavigationMenuSlot } from '@shoppex/contracts/navigation';
3
4
  import { StorefrontDeliveryType } from '@shoppex/contracts/storefront-delivery-type';
4
- import * as src from 'src';
5
5
  import { createApiClient } from '@shoppex/contracts/api-client';
6
6
  import { CustomerWarrantyClaimWire, CustomerPortalAffiliateCreateLinkWire, CustomerPortalDashboardWire, CustomerPortalPaginatedInvoicesWire, CustomerPortalInvoiceDetailWire, CustomerLoyaltyWire, CustomerLoyaltyRedeemWire, CustomerWarrantyListWire, CustomerPortalNotificationPreferencesWire } from '@shoppex/contracts/customer-account-wire';
7
7
  export { CATALOG_UNIT_PRICE_DECIMAL_PLACES, CATALOG_UNIT_PRICE_FORMAT_OPTIONS, PAYABLE_AMOUNT_DECIMAL_PLACES, roundPayableAmount } from '@shoppex/contracts/catalog-unit-price';
8
8
 
9
- interface CacheStats {
10
- hits: number;
11
- misses: number;
12
- pendingRequests: number;
13
- entries: number;
14
- }
15
- declare function getCacheStats(): CacheStats;
16
- declare function clearCache(): void;
17
- declare function invalidateCache(prefixOrKey: string): void;
18
-
19
- /**
20
- * Formatting Utilities
21
- */
22
- declare function createFormatter(currency?: string, locale?: string): Intl.NumberFormat;
23
- declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
24
-
25
9
  /**
26
10
  * SDK Configuration Types
27
11
  */
@@ -1211,6 +1195,86 @@ interface CartStats {
1211
1195
  total_price_is_estimate: boolean;
1212
1196
  }
1213
1197
 
1198
+ declare function getCartCoupon(): string | null;
1199
+ declare function getCartCouponSource(): CartCodeSource | null;
1200
+ declare function setCartCoupon(coupon: string | null | undefined, source?: CartCodeSource): string | null;
1201
+ declare function clearCartCoupon(): void;
1202
+ declare function getCart(): CartItem[];
1203
+ /** Resolve a cart line_id for product+variant. When multiple configs exist, returns the first line. */
1204
+ declare function resolveCartLineId(productId: string, variantId: string, cart?: CartItem[]): string;
1205
+ declare function getCartItemCount(): number;
1206
+ declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1207
+ declare function setCartItem(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1208
+ /**
1209
+ * Patch one cart line.
1210
+ *
1211
+ * TRI-STATE BOUNDS: `min_quantity`/`max_quantity` accept `null` to DELETE the
1212
+ * stored bound — see {@link CartItemUpdate}. `undefined` (or an absent key)
1213
+ * leaves it alone, which is why a removed ceiling needs its own spelling.
1214
+ *
1215
+ * NO-OP UPDATES DO NOT WRITE. An update that leaves the cart byte-identical
1216
+ * returns without touching storage: no metadata bump, no `version` increment,
1217
+ * and — because the storage write is what other tabs observe — no `storage`
1218
+ * event. Writing anyway made an ineffective heal indistinguishable from a real
1219
+ * cart change, and two tabs healing the same line could hand the event back and
1220
+ * forth indefinitely. Line-shape healing of a legacy stored row is NOT this
1221
+ * function's job: `normalizeCartItems` clamps and repairs on every READ, which
1222
+ * is the chokepoint every access already flows through.
1223
+ */
1224
+ declare function updateCartItem(lineId: string, updates: CartItemUpdate): void;
1225
+ declare function removeFromCart(lineId: string): void;
1226
+ /**
1227
+ * Discards the cart entirely — and with it the proof that describes it.
1228
+ *
1229
+ * PAYMENT PATH. `latestQuoteToken` is evidence about a specific cart, and this
1230
+ * is the one mutation after which that cart does not exist in any form. Held
1231
+ * across the clear, the proof outlives its subject: a caller that clears and
1232
+ * re-adds (Buy Now REPLACES the cart) hands `/from-cart` a token bound to the
1233
+ * previous cart's hash, which is refused as `quote_token_stale` — a hand-off
1234
+ * dead-ended by a proof nobody asked for. And with no re-quote in between there
1235
+ * is nothing to replace it with, so the retry is refused identically.
1236
+ *
1237
+ * Only this path clears it. Every OTHER mutation turns one cart into another
1238
+ * cart, where a proof that no longer matches is the server's to refuse: it
1239
+ * answers `quote_token_stale`, the surfaces re-quote, and the buyer approves the
1240
+ * new total. Dropping the proof there instead would silently remove the approved
1241
+ * -total ceiling from a checkout that raced the re-quote, which is the failure
1242
+ * the token exists to prevent.
1243
+ */
1244
+ declare function clearCart(): void;
1245
+ declare function createCartBackup(): void;
1246
+ declare function restoreCartFromBackup(): boolean;
1247
+ declare function mergeBaskets(items: CartBasketMergeLine[]): CartItem[];
1248
+ declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
1249
+ declare function validateCartIntegrity(): boolean;
1250
+ declare function getCartStats(): CartStats;
1251
+ /** @internal — read by checkout(); exported only across module boundaries. */
1252
+ declare function getLatestQuoteToken(): string | null;
1253
+ declare function quoteCart(coupon?: string, currency?: string): Promise<src.SDKResponse<CartQuote>>;
1254
+
1255
+ /**
1256
+ * SDK Configuration Management
1257
+ */
1258
+
1259
+ declare function getConfig(): ShoppexConfig;
1260
+ declare function isInitialized(): boolean;
1261
+
1262
+ interface CacheStats {
1263
+ hits: number;
1264
+ misses: number;
1265
+ pendingRequests: number;
1266
+ entries: number;
1267
+ }
1268
+ declare function getCacheStats(): CacheStats;
1269
+ declare function clearCache(): void;
1270
+ declare function invalidateCache(prefixOrKey: string): void;
1271
+
1272
+ /**
1273
+ * Formatting Utilities
1274
+ */
1275
+ declare function createFormatter(currency?: string, locale?: string): Intl.NumberFormat;
1276
+ declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
1277
+
1214
1278
  /**
1215
1279
  * Pages Module
1216
1280
  *
@@ -1511,63 +1575,6 @@ declare function buildCheckoutUrl(couponOrOptions?: string | CheckoutOptions, op
1511
1575
  */
1512
1576
  declare function buildCheckoutUrlSync(): never;
1513
1577
 
1514
- declare function getCartCoupon(): string | null;
1515
- declare function getCartCouponSource(): CartCodeSource | null;
1516
- declare function setCartCoupon(coupon: string | null | undefined, source?: CartCodeSource): string | null;
1517
- declare function clearCartCoupon(): void;
1518
- declare function getCart(): CartItem[];
1519
- /** Resolve a cart line_id for product+variant. When multiple configs exist, returns the first line. */
1520
- declare function resolveCartLineId(productId: string, variantId: string, cart?: CartItem[]): string;
1521
- declare function getCartItemCount(): number;
1522
- declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1523
- declare function setCartItem(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
1524
- /**
1525
- * Patch one cart line.
1526
- *
1527
- * TRI-STATE BOUNDS: `min_quantity`/`max_quantity` accept `null` to DELETE the
1528
- * stored bound — see {@link CartItemUpdate}. `undefined` (or an absent key)
1529
- * leaves it alone, which is why a removed ceiling needs its own spelling.
1530
- *
1531
- * NO-OP UPDATES DO NOT WRITE. An update that leaves the cart byte-identical
1532
- * returns without touching storage: no metadata bump, no `version` increment,
1533
- * and — because the storage write is what other tabs observe — no `storage`
1534
- * event. Writing anyway made an ineffective heal indistinguishable from a real
1535
- * cart change, and two tabs healing the same line could hand the event back and
1536
- * forth indefinitely. Line-shape healing of a legacy stored row is NOT this
1537
- * function's job: `normalizeCartItems` clamps and repairs on every READ, which
1538
- * is the chokepoint every access already flows through.
1539
- */
1540
- declare function updateCartItem(lineId: string, updates: CartItemUpdate): void;
1541
- declare function removeFromCart(lineId: string): void;
1542
- /**
1543
- * Discards the cart entirely — and with it the proof that describes it.
1544
- *
1545
- * PAYMENT PATH. `latestQuoteToken` is evidence about a specific cart, and this
1546
- * is the one mutation after which that cart does not exist in any form. Held
1547
- * across the clear, the proof outlives its subject: a caller that clears and
1548
- * re-adds (Buy Now REPLACES the cart) hands `/from-cart` a token bound to the
1549
- * previous cart's hash, which is refused as `quote_token_stale` — a hand-off
1550
- * dead-ended by a proof nobody asked for. And with no re-quote in between there
1551
- * is nothing to replace it with, so the retry is refused identically.
1552
- *
1553
- * Only this path clears it. Every OTHER mutation turns one cart into another
1554
- * cart, where a proof that no longer matches is the server's to refuse: it
1555
- * answers `quote_token_stale`, the surfaces re-quote, and the buyer approves the
1556
- * new total. Dropping the proof there instead would silently remove the approved
1557
- * -total ceiling from a checkout that raced the re-quote, which is the failure
1558
- * the token exists to prevent.
1559
- */
1560
- declare function clearCart(): void;
1561
- declare function createCartBackup(): void;
1562
- declare function restoreCartFromBackup(): boolean;
1563
- declare function mergeBaskets(items: CartBasketMergeLine[]): CartItem[];
1564
- declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
1565
- declare function validateCartIntegrity(): boolean;
1566
- declare function getCartStats(): CartStats;
1567
- /** @internal — read by checkout(); exported only across module boundaries. */
1568
- declare function getLatestQuoteToken(): string | null;
1569
- declare function quoteCart(coupon?: string, currency?: string): Promise<src.SDKResponse<CartQuote>>;
1570
-
1571
1578
  /**
1572
1579
  * Products Module
1573
1580
  *
@@ -1629,18 +1636,13 @@ declare function getStoreBannerUrl(): Promise<string | null>;
1629
1636
  type ApiClient = ReturnType<typeof createApiClient>;
1630
1637
  /**
1631
1638
  * Return a typed OpenAPI client bound to the SDK's configured API base URL.
1632
- * The client is cached per base URL and recreated when the SDK is re-initialized
1633
- * against a different host.
1639
+ * The client is cached for the config object it was built from: every init
1640
+ * creates a new config object, so a re-init rebuilds it. Keyed here instead of
1641
+ * reset from `initConfig`, so `core/config.ts` (which every SDK user loads)
1642
+ * does not import this module and its `openapi-fetch` dependency.
1634
1643
  */
1635
1644
  declare function getTypedClient(token?: string): ApiClient;
1636
1645
 
1637
- /**
1638
- * SDK Configuration Management
1639
- */
1640
-
1641
- declare function getConfig(): ShoppexConfig;
1642
- declare function isInitialized(): boolean;
1643
-
1644
1646
  /**
1645
1647
  * SDK Error Classes
1646
1648
  */
@@ -2190,14 +2192,6 @@ declare const shoppex: {
2190
2192
  resellerOrder: typeof resellerOrder;
2191
2193
  resellerWallet: typeof resellerWallet;
2192
2194
  resellerApiKeys: typeof resellerApiKeys;
2193
- init: {
2194
- (storeSlug: string, options?: src.ShoppexInitOptions): void;
2195
- (options: src.ShoppexInitOptions & {
2196
- storeId: string;
2197
- }): void;
2198
- };
2199
- isInitialized: typeof isInitialized;
2200
- getConfig: typeof getConfig;
2201
2195
  client: typeof getTypedClient;
2202
2196
  getStore: typeof getStore;
2203
2197
  getStorefront: typeof getStorefront;
@@ -2208,38 +2202,12 @@ declare const shoppex: {
2208
2202
  getStorefrontProductsPage: typeof getStorefrontProductsPage;
2209
2203
  getProduct: typeof getProduct;
2210
2204
  getCategories: typeof getCategories;
2211
- getCart: typeof getCart;
2212
- getCartItemCount: typeof getCartItemCount;
2213
- getCartCoupon: typeof getCartCoupon;
2214
- getCartCouponSource: typeof getCartCouponSource;
2215
- setCartCoupon: typeof setCartCoupon;
2216
- clearCartCoupon: typeof clearCartCoupon;
2217
- addToCart: typeof addToCart;
2218
- setCartItem: typeof setCartItem;
2219
- updateCartItem: typeof updateCartItem;
2220
- removeFromCart: typeof removeFromCart;
2221
- clearCart: typeof clearCart;
2222
- createCartBackup: typeof createCartBackup;
2223
- restoreCartFromBackup: typeof restoreCartFromBackup;
2224
- mergeBaskets: typeof mergeBaskets;
2225
- moveBasketItem: typeof moveBasketItem;
2226
- getCartStats: typeof getCartStats;
2227
- validateCartIntegrity: typeof validateCartIntegrity;
2228
- quoteCart: typeof quoteCart;
2229
- getLatestQuoteToken: typeof getLatestQuoteToken;
2230
- resolveCartLineId: typeof resolveCartLineId;
2231
2205
  checkout: typeof checkout;
2232
2206
  buildCheckoutUrl: typeof buildCheckoutUrl;
2233
2207
  buildCheckoutUrlSync: typeof buildCheckoutUrlSync;
2234
2208
  getRequestedCheckoutCurrency: typeof getRequestedCheckoutCurrency;
2235
- captureAffiliateFromUrl: typeof captureAffiliateFromUrl;
2236
2209
  validateAffiliateCode: typeof validateAffiliateCode;
2237
2210
  applyAffiliateCode: typeof applyAffiliateCode;
2238
- getAffiliateCode: typeof getAffiliateCode;
2239
- getStoredAffiliate: typeof getStoredAffiliate;
2240
- setAffiliateCode: typeof setAffiliateCode;
2241
- clearAffiliateCode: typeof clearAffiliateCode;
2242
- trackAffiliateEvent: typeof trackAffiliateEvent;
2243
2211
  validateCoupon: typeof validateCoupon;
2244
2212
  getShopReviews: typeof getShopReviews;
2245
2213
  getShopReviewsPage: typeof src.getShopReviewsPage;
@@ -2254,8 +2222,6 @@ declare const shoppex: {
2254
2222
  getMenuBySlot: typeof src.getMenuBySlot;
2255
2223
  getMenuByTitle: typeof src.getMenuByTitle;
2256
2224
  getMenuSlotTitles: typeof src.getMenuSlotTitles;
2257
- trackPageView: typeof src.trackPageView;
2258
- trackCartActivity: typeof src.trackCartActivity;
2259
2225
  getStorefrontOnlineUsers: typeof src.getStorefrontOnlineUsers;
2260
2226
  getStorefrontRecentSales: typeof src.getStorefrontRecentSales;
2261
2227
  touchStorefrontPresence: typeof src.touchStorefrontPresence;
@@ -2268,6 +2234,42 @@ declare const shoppex: {
2268
2234
  fetchPublishedThemeSettings: typeof src.fetchPublishedThemeSettings;
2269
2235
  resolveDefaults: typeof src.resolveDefaults;
2270
2236
  mergeSettings: typeof src.mergeSettings;
2237
+ init: {
2238
+ (storeSlug: string, options?: src.ShoppexInitOptions): void;
2239
+ (options: src.ShoppexInitOptions & {
2240
+ storeId: string;
2241
+ }): void;
2242
+ };
2243
+ isInitialized: typeof isInitialized;
2244
+ getConfig: typeof getConfig;
2245
+ getCart: typeof getCart;
2246
+ getCartItemCount: typeof getCartItemCount;
2247
+ getCartCoupon: typeof getCartCoupon;
2248
+ getCartCouponSource: typeof getCartCouponSource;
2249
+ setCartCoupon: typeof setCartCoupon;
2250
+ clearCartCoupon: typeof clearCartCoupon;
2251
+ addToCart: typeof addToCart;
2252
+ setCartItem: typeof setCartItem;
2253
+ updateCartItem: typeof updateCartItem;
2254
+ removeFromCart: typeof removeFromCart;
2255
+ clearCart: typeof clearCart;
2256
+ createCartBackup: typeof createCartBackup;
2257
+ restoreCartFromBackup: typeof restoreCartFromBackup;
2258
+ mergeBaskets: typeof mergeBaskets;
2259
+ moveBasketItem: typeof moveBasketItem;
2260
+ getCartStats: typeof getCartStats;
2261
+ validateCartIntegrity: typeof validateCartIntegrity;
2262
+ quoteCart: typeof quoteCart;
2263
+ getLatestQuoteToken: typeof getLatestQuoteToken;
2264
+ resolveCartLineId: typeof resolveCartLineId;
2265
+ captureAffiliateFromUrl: typeof captureAffiliateFromUrl;
2266
+ getAffiliateCode: typeof getAffiliateCode;
2267
+ getStoredAffiliate: typeof getStoredAffiliate;
2268
+ setAffiliateCode: typeof setAffiliateCode;
2269
+ clearAffiliateCode: typeof clearAffiliateCode;
2270
+ trackAffiliateEvent: typeof trackAffiliateEvent;
2271
+ trackPageView: typeof src.trackPageView;
2272
+ trackCartActivity: typeof src.trackCartActivity;
2271
2273
  };
2272
2274
 
2273
2275
  export { type AffiliateValidation, ApiError, type ApiResponse, type BlockDefinition, type BlockInstance, type BuyerRewardActivityItem, type BuyerRewards, CURRENCY_UNAVAILABLE_ERROR_CODE, type CartAddOptions, type CartAddon, type CartAppliedDiscount, type CartBasketMergeLine, type CartCodeSource, CartError, type CartItem, type CartItemUpdate, type CartLineIdentityInput, type CartMetadata, type CartPayload, type CartQuote, type CartQuoteLine, type CartStats, type Category, CheckoutCreateError, type CheckoutOptions, type CheckoutResult, type CouponValidation, type CouponValidationOptions, type CursorPagination, type CustomFieldDefinition, type CustomerAffiliateLinkInput, type CustomerEmailPreferencesPatch, type CustomerInvoicePdf, type CustomerNotificationPreferencesPatch, type CustomerProfilePatch, type CustomerSubscriptionCancelOptions, type CustomerTicketPayload, type EligibleBundleDeal, type EligibleBundleDealProduct, type EligibleCartDeal, type Feedback, type Invoice, type InvoiceProduct, type Menu, type MenuItem, NetworkError, NotInitializedError, PRODUCT_FILTER_UNSUPPORTED, type Page, type PageLayout, type PriceVariant, type Product, type ProductAddon, type ProductBundle, type ProductBundleProduct, type ProductCategory, type ProductDescriptionTab, type ProductFaq, type ProductFeedback, type ProductGroup, type ProductImage, type ProductVariant, type PublishedBuilderSettings, type PublishedThemeSettingsPayload, type ResellerCatalogQuery, type ResellerOrderItem, type ResellerOrdersQuery, type ResolvedThemeSettings, type RewardActionType, type RewardGrantStatus, type RewardProgramSummary, type RewardProgramTeaserItem, type RewardReason, type SDKResponse, type SearchOptions, type SectionDefinition, type SettingField, type Shop, type ShopFeedback, type ShopReviewsPage, type ShopReviewsSummary, type ShopTheme, type ShoppexConfig, ShoppexError, type ShoppexInitOptions, type StorefrontAddon, type StorefrontAddonBootstrap, type StorefrontAnnouncementBarAddon, type StorefrontCatalogSearchItem, type StorefrontContactTicketInput, type StorefrontContactTicketResult, type StorefrontCountdownBarAddon, type StorefrontCouponPopupModalAddon, type StorefrontCustomField, type StorefrontData, type StorefrontItem, type StorefrontOnlineUsers, type StorefrontPromoInfoCardAddon, type StorefrontRecentPurchasePopupAddon, type StorefrontRecentSaleEntry, type StorefrontRecentSales, type StorefrontSearchFilterOptions, type StorefrontSocialLinks, type Subscription, type SubscriptionFlags, type SubscriptionInterval, type ThemeBlockManifest, type ThemeConfig, type TrustedChecks, ValidationError, acceptResellerInvite, addFavorite, affiliate, affiliateStats, applyForReseller, buildStorefrontContactMessage, buildStorefrontCustomFieldPayload, buildStorefrontProductLookup, cancelSubscription, claimWarranty, collectProductSearchHaystack, computeCartLineId, createAffiliateLink, createTicket, dashboard, shoppex as default, emailPreferences, enrollAsReseller, ensureCartLineId, favorites, fetchPublishedBuilderSettings, fetchPublishedThemeSettings, filterProductsBySearchQuery, getMenu, getMenuBySlot, getMenuByTitle, getMenuSlotTitles, getMenus, getMergedStorefrontProducts, getShopReviewsPage, getStorefrontGroupProducts, getStorefrontOnlineUsers, getStorefrontRecentSales, groupMatchesSearchQuery, invoicePdf, isProductInStock, isProductOutOfStock, isStorefrontCheckboxCustomFieldValueChecked, isVariantOutOfStock, logout, loyalty, me, mergeSettings, normalizeSearchQuery, normalizeStorefrontCustomFields, notificationPreferences, order, orders, pauseSubscription, productMatchesSearchQuery, quoteResellerOrder, redeemLoyaltyPoints, removeAvatar, removeFavorite, replyToTicket, requestOtp, reseller, resellerApiKeys, resellerCatalog, resellerOrder, resellerOrders, resellerWallet, resetLicenseHwid, resolveDefaults, resolveDisplayStock, resolveStorefrontApiBaseUrl, resolveStorefrontSocialLinks, resolveVariantStockValue, resumeSubscription, revokeAllSessions, revokeSession, searchMergedStorefrontCatalog, searchMergedStorefrontCatalogItems, sessions, shoppex, stripHtmlFromText, submitStorefrontContactTicket, subscriptionBillingHistory, ticket, touchStorefrontPresence, trackCartActivity, trackPageView, undoSubscriptionCancel, updateAvatar, updateEmailPreferences, updateNotificationPreferences, updateProfile, validateStorefrontCustomFieldValue, verifyOtp, warranties };