@cimplify/sdk 0.6.0 → 0.6.1
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/README.md +5 -0
- package/dist/{ads-B5jcLFpD.d.mts → ads-DRfobDQ9.d.mts} +297 -216
- package/dist/{ads-B5jcLFpD.d.ts → ads-DRfobDQ9.d.ts} +297 -216
- package/dist/index.d.mts +25 -92
- package/dist/index.d.ts +25 -92
- package/dist/index.js +41 -165
- package/dist/index.mjs +42 -163
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PaymentErrorDetails, a as PaymentResponse, b as PaymentStatusResponse, A as ApiError } from './ads-
|
|
2
|
-
export {
|
|
1
|
+
import { P as PaymentErrorDetails, a as PaymentResponse, b as PaymentStatusResponse, A as ApiError } from './ads-DRfobDQ9.mjs';
|
|
2
|
+
export { ab as AUTHORIZATION_TYPE, ag as AUTH_MUTATION, eE as AdConfig, eG as AdContextValue, eF as AdCreative, eC as AdPosition, eB as AdSlot, eD as AdTheme, b0 as AddOn, bL as AddOnDetails, c5 as AddOnGroupDetails, b2 as AddOnOption, c4 as AddOnOptionDetails, b3 as AddOnOptionPrice, b1 as AddOnWithOptions, ca as AddToCartInput, e1 as AddressData, et as AddressInfo, bA as AdjustmentType, co as AmountToPay, bH as AppliedDiscount, ec as AuthResponse, p as AuthService, q as AuthStatus, ev as AuthenticatedData, cY as AuthorizationType, dR as AvailabilityCheck, dS as AvailabilityResult, dz as AvailableSlot, bG as BenefitType, dC as Booking, dt as BookingRequirementOverride, dB as BookingStatus, dD as BookingWithDetails, cI as BufferTimes, bb as Bundle, bf as BundleComponentData, bg as BundleComponentInfo, ba as BundlePriceType, bd as BundleProduct, bQ as BundleSelectionData, bO as BundleSelectionInput, bP as BundleStoredSelection, bc as BundleSummary, be as BundleWithDetails, d4 as Business, di as BusinessHours, d3 as BusinessPreferences, B as BusinessService, dh as BusinessSettings, d2 as BusinessType, df as BusinessWithLocations, a4 as CHECKOUT_MODE, ah as CHECKOUT_MUTATION, a7 as CHECKOUT_STEP, ad as CONTACT_TYPE, dH as CancelBookingInput, cC as CancelOrderInput, cK as CancellationPolicy, bV as Cart, bM as CartAddOn, by as CartChannel, bW as CartItem, c7 as CartItemDetails, l as CartOperations, bx as CartStatus, cc as CartSummary, bX as CartTotals, e as CatalogueQueries, b5 as Category, dj as CategoryInfo, b6 as CategorySummary, s as ChangePasswordInput, dF as CheckSlotAvailabilityInput, ef as CheckoutAddressInfo, eh as CheckoutCustomerInfo, $ as CheckoutFormData, cA as CheckoutInput, X as CheckoutMode, m as CheckoutOperations, Y as CheckoutOrderType, Z as CheckoutPaymentMethod, a0 as CheckoutResult, m as CheckoutService, _ as CheckoutStep, bF as ChosenPrice, C as CimplifyClient, d as CimplifyConfig, z as CimplifyElement, y as CimplifyElements, as as CimplifyError, b7 as Collection, b9 as CollectionProduct, b8 as CollectionSummary, bm as ComponentGroup, bn as ComponentGroupWithComponents, br as ComponentPriceBreakdown, bp as ComponentSelectionInput, bj as ComponentSourceType, bk as Composite, bo as CompositeComponent, bS as CompositePriceBreakdown, bq as CompositePriceResult, bh as CompositePricingMode, bT as CompositeSelectionData, bp as CompositeSelectionInput, bR as CompositeStoredSelection, bl as CompositeWithDetails, a3 as ContactType, dZ as CreateAddressInput, d$ as CreateMobileMoneyInput, an as Currency, dU as Customer, dV as CustomerAddress, dX as CustomerLinkPreferences, dW as CustomerMobileMoney, cH as CustomerServicePreferences, al as DEFAULT_COUNTRY, ak as DEFAULT_CURRENCY, ac as DEVICE_TYPE, dA as DayAvailability, cR as DepositResult, aQ as DepositType, a2 as DeviceType, aP as DigitalProductType, bI as DiscountBreakdown, bJ as DiscountDetails, b_ as DisplayAddOn, b$ as DisplayAddOnOption, bY as DisplayCart, bZ as DisplayCartItem, H as ELEMENT_TYPES, E as EVENT_TYPES, es as ElementAppearance, eA as ElementEventHandler, W as ElementEventType, N as ElementOptions, V as ElementType, ew as ElementsCheckoutData, ex as ElementsCheckoutResult, J as ElementsOptions, e3 as EnrollAndLinkOrderInput, e6 as EnrollAndLinkOrderResult, e0 as EnrollmentData, ax as Err, aq as ErrorCode, ar as ErrorCodeType, cn as FeeBearerType, F as FetchQuoteInput, cl as FulfillmentLink, ck as FulfillmentStatus, cj as FulfillmentType, ej as FxQuote, ei as FxQuoteRequest, ek as FxRateResponse, v as FxService, dE as GetAvailableSlotsInput, o as GetOrdersOptions, G as GetProductsOptions, bi as GroupPricingBehavior, ez as IframeToParentMessage, d0 as InitializePaymentResult, I as InventoryService, dT as InventorySummary, aN as InventoryType, K as KitchenOrderItem, x as KitchenOrderResult, af as LINK_MUTATION, ae as LINK_QUERY, bU as LineConfiguration, cp as LineItem, cg as LineType, dY as LinkData, e5 as LinkEnrollResult, L as LinkService, e7 as LinkSession, e4 as LinkStatusResult, w as LiteBootstrap, u as LiteService, d7 as Location, cU as LocationAppointment, bu as LocationProductPrice, dQ as LocationStock, d5 as LocationTaxBehavior, d6 as LocationTaxOverrides, da as LocationTimeProfile, dg as LocationWithDetails, M as MESSAGE_TYPES, aa as MOBILE_MONEY_PROVIDER, e2 as MobileMoneyData, eg as MobileMoneyDetails, a1 as MobileMoneyProvider, am as Money, aj as ORDER_MUTATION, a5 as ORDER_TYPE, er as ObservabilityHooks, aw as Ok, cq as Order, cf as OrderChannel, cz as OrderFilter, cm as OrderFulfillmentSummary, ct as OrderGroup, cx as OrderGroupDetails, cu as OrderGroupPayment, cs as OrderGroupPaymentState, cw as OrderGroupPaymentSummary, cr as OrderHistory, ch as OrderLineState, ci as OrderLineStatus, cy as OrderPaymentEvent, O as OrderQueries, cv as OrderSplitDetail, cd as OrderStatus, r as OtpResult, a6 as PAYMENT_METHOD, ai as PAYMENT_MUTATION, a8 as PAYMENT_STATE, a9 as PICKUP_TIME_TYPE, ap as Pagination, ao as PaginationParams, ey as ParentToIframeMessage, c$ as Payment, c_ as PaymentMethod, eu as PaymentMethodInfo, cX as PaymentMethodType, cZ as PaymentProcessingState, cW as PaymentProvider, ce as PaymentState, cV as PaymentStatus, ee as PickupTime, ed as PickupTimeType, bt as Price, bB as PriceAdjustment, bE as PriceDecisionPath, bs as PriceEntryType, bD as PricePathTaxInfo, j as PriceQuote, bz as PriceSource, cM as PricingOverrides, aS as Product, b4 as ProductAddOn, bv as ProductAvailability, dO as ProductStock, bw as ProductTimeProfile, aM as ProductType, aU as ProductVariant, aZ as ProductVariantValue, aT as ProductWithDetails, f as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, h as QuoteDynamicBuckets, g as QuoteStatus, i as QuoteUiMessage, R as RefreshQuoteInput, k as RefreshQuoteResult, cD as RefundOrderInput, cG as ReminderMethod, cJ as ReminderSettings, el as RequestContext, eo as RequestErrorEvent, ea as RequestOtpInput, em as RequestStartEvent, en as RequestSuccessEvent, dG as RescheduleBookingInput, cP as ResourceAssignment, dq as ResourceAvailabilityException, dp as ResourceAvailabilityRule, du as ResourceType, av as Result, ep as RetryEvent, e9 as RevokeAllSessionsResult, e8 as RevokeSessionResult, dc as Room, aR as SalesChannel, cN as SchedulingMetadata, cQ as SchedulingResult, t as SchedulingService, S as SearchOptions, bK as SelectedAddOnOption, dv as Service, dl as ServiceAvailabilityException, dI as ServiceAvailabilityParams, dJ as ServiceAvailabilityResult, dk as ServiceAvailabilityRule, dd as ServiceCharge, cL as ServiceNotes, cS as ServiceScheduleRequest, ds as ServiceStaffRequirement, cE as ServiceStatus, dw as ServiceWithStaff, eq as SessionChangeEvent, dx as Staff, cO as StaffAssignment, dn as StaffAvailabilityException, dm as StaffAvailabilityRule, dr as StaffBookingProfile, cF as StaffRole, cT as StaffScheduleItem, dM as Stock, dN as StockLevel, dK as StockOwnershipType, dL as StockStatus, de as StorefrontBootstrap, d1 as SubmitAuthorizationInput, db as Table, T as TableInfo, bC as TaxPathComponent, d8 as TimeRange, d9 as TimeRanges, dy as TimeSlot, c8 as UICart, c0 as UICartBusiness, c2 as UICartCustomer, c1 as UICartLocation, c3 as UICartPricing, c9 as UICartResponse, d_ as UpdateAddressInput, cb as UpdateCartItemInput, cB as UpdateOrderStatusInput, U as UpdateProfileInput, aW as VariantAxis, a$ as VariantAxisSelection, aY as VariantAxisValue, aX as VariantAxisWithValues, bN as VariantDetails, c6 as VariantDetailsDTO, aV as VariantDisplayAttribute, a_ as VariantLocationAvailability, dP as VariantStock, aO as VariantStrategy, eb as VerifyOtpInput, aK as combine, aL as combineObject, c as createCimplifyClient, D as createElements, az as err, aE as flatMap, aI as fromPromise, n as generateIdempotencyKey, aF as getOrElse, at as isCimplifyError, aB as isErr, aA as isOk, au as isRetryableError, aD as mapError, aC as mapResult, ay as ok, aH as toNullable, aJ as tryCatch, aG as unwrap } from './ads-DRfobDQ9.mjs';
|
|
3
3
|
|
|
4
4
|
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
|
5
5
|
type SortOrder = "asc" | "desc";
|
|
@@ -37,7 +37,7 @@ interface TaxComponent {
|
|
|
37
37
|
rate: number;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Complete tax information from a
|
|
40
|
+
* Complete tax information from a pricing response
|
|
41
41
|
*/
|
|
42
42
|
interface TaxInfo {
|
|
43
43
|
/** Total tax rate as percentage */
|
|
@@ -70,42 +70,20 @@ interface PriceInfo {
|
|
|
70
70
|
decision_path?: string;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
interface ParsedPrice {
|
|
77
|
-
/** Original price before markup/discount */
|
|
78
|
-
basePrice: number;
|
|
79
|
-
/** Final price after all adjustments */
|
|
80
|
-
finalPrice: number;
|
|
81
|
-
/** Currency code (e.g., "GHS", "USD") */
|
|
82
|
-
currency: string;
|
|
83
|
-
/** Decision path showing how price was calculated */
|
|
84
|
-
decisionPath: string;
|
|
85
|
-
/** Discount percentage if final < base */
|
|
86
|
-
discountPercentage?: number;
|
|
87
|
-
/** Markup percentage if final > base */
|
|
88
|
-
markupPercentage?: number;
|
|
89
|
-
/** Markup amount if final > base */
|
|
90
|
-
markupAmount?: number;
|
|
91
|
-
/** Tax information extracted from the path */
|
|
92
|
-
taxInfo?: TaxInfo;
|
|
93
|
-
/** Whether the price path is valid and not expired */
|
|
94
|
-
isValid: boolean;
|
|
95
|
-
/** Whether the price path has expired */
|
|
96
|
-
isExpired: boolean;
|
|
97
|
-
/** Unix timestamp when the price expires */
|
|
98
|
-
expiryTimestamp?: number;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Minimal product shape for price utilities
|
|
102
|
-
* Allows extracting price from either price_path or price_info
|
|
73
|
+
* Minimal product shape for price utilities.
|
|
74
|
+
* Uses quote-aware `price_info` and plain numeric fallback fields.
|
|
103
75
|
*/
|
|
104
76
|
interface ProductWithPrice {
|
|
105
|
-
/**
|
|
106
|
-
price_path?: string | null;
|
|
107
|
-
/** Pre-parsed price info */
|
|
77
|
+
/** Pre-parsed price info from backend */
|
|
108
78
|
price_info?: PriceInfo;
|
|
79
|
+
/** Final computed price in plain field form (if provided by API) */
|
|
80
|
+
final_price?: number | string | null;
|
|
81
|
+
/** Base/original price in plain field form */
|
|
82
|
+
base_price?: number | string | null;
|
|
83
|
+
/** Default/indicative price in plain field form */
|
|
84
|
+
default_price?: number | string | null;
|
|
85
|
+
/** Currency in plain field form */
|
|
86
|
+
currency?: string | null;
|
|
109
87
|
}
|
|
110
88
|
/**
|
|
111
89
|
* Options for price formatting functions
|
|
@@ -134,15 +112,13 @@ interface FormatCompactOptions {
|
|
|
134
112
|
* Price Utilities
|
|
135
113
|
*
|
|
136
114
|
* Comprehensive utilities for parsing, formatting, and displaying prices.
|
|
137
|
-
* Handles
|
|
138
|
-
* and product price helpers.
|
|
115
|
+
* Handles quote-aware pricing fields, currency formatting, and product price helpers.
|
|
139
116
|
*
|
|
140
117
|
* @example
|
|
141
118
|
* ```typescript
|
|
142
119
|
* import {
|
|
143
120
|
* formatPrice,
|
|
144
121
|
* formatPriceCompact,
|
|
145
|
-
* parsePricePath,
|
|
146
122
|
* isOnSale,
|
|
147
123
|
* getDiscountPercentage
|
|
148
124
|
* } from '@cimplify/sdk';
|
|
@@ -263,53 +239,10 @@ declare function formatMoney(amount: string | number, currency?: string): string
|
|
|
263
239
|
*/
|
|
264
240
|
declare function parsePrice(value: string | number | undefined | null): number;
|
|
265
241
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* Price paths are HMAC-SHA256 signed and contain:
|
|
269
|
-
* - Base price (original price before markup)
|
|
270
|
-
* - Final price (what customer pays)
|
|
271
|
-
* - Currency
|
|
272
|
-
* - Tax information
|
|
273
|
-
* - Decision path (pricing adjustments trail)
|
|
274
|
-
*
|
|
275
|
-
* Format: "base_price|final_price|currency|tax_info|decision_path§expiry§signature"
|
|
276
|
-
*
|
|
277
|
-
* @param signedPricePath - The signed price path from backend
|
|
278
|
-
* @returns ParsedPrice object with extracted pricing information
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* const parsed = parsePricePath(product.price_path);
|
|
282
|
-
* console.log(parsed.finalPrice); // 29.99
|
|
283
|
-
* console.log(parsed.currency); // "GHS"
|
|
284
|
-
* console.log(parsed.isValid); // true
|
|
285
|
-
* console.log(parsed.taxInfo); // { taxRate: 15, ... }
|
|
286
|
-
*/
|
|
287
|
-
declare function parsePricePath(signedPricePath: string | undefined | null): ParsedPrice;
|
|
288
|
-
/**
|
|
289
|
-
* Convert a ParsedPrice to PriceInfo format
|
|
290
|
-
* Useful for compatibility with components expecting snake_case format
|
|
291
|
-
*
|
|
292
|
-
* @param parsedPrice - The parsed price object
|
|
293
|
-
* @returns PriceInfo object in snake_case format
|
|
294
|
-
*/
|
|
295
|
-
declare function parsedPriceToPriceInfo(parsedPrice: ParsedPrice): PriceInfo;
|
|
296
|
-
/**
|
|
297
|
-
* Extract PriceInfo directly from a signed price path
|
|
298
|
-
* Convenience function that parses and converts in one step
|
|
299
|
-
*
|
|
300
|
-
* @param signedPricePath - The signed price path from backend
|
|
301
|
-
* @returns PriceInfo object ready for use in components
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
* const priceInfo = extractPriceInfo(product.price_path);
|
|
305
|
-
* console.log(priceInfo.final_price); // 29.99
|
|
306
|
-
*/
|
|
307
|
-
declare function extractPriceInfo(signedPricePath: string | undefined | null): PriceInfo;
|
|
308
|
-
/**
|
|
309
|
-
* Get the display price from a product
|
|
310
|
-
* Handles both price_path and pre-parsed price_info
|
|
242
|
+
* Get the display price from a product.
|
|
243
|
+
* Prefers quote-aware price_info, then plain price fields.
|
|
311
244
|
*
|
|
312
|
-
* @param product - Product with
|
|
245
|
+
* @param product - Product with price data
|
|
313
246
|
* @returns The final price to display
|
|
314
247
|
*
|
|
315
248
|
* @example
|
|
@@ -320,14 +253,14 @@ declare function getDisplayPrice(product: ProductWithPrice): number;
|
|
|
320
253
|
/**
|
|
321
254
|
* Get the base price from a product (before markup/discount)
|
|
322
255
|
*
|
|
323
|
-
* @param product - Product with
|
|
256
|
+
* @param product - Product with price data
|
|
324
257
|
* @returns The base price before adjustments
|
|
325
258
|
*/
|
|
326
259
|
declare function getBasePrice(product: ProductWithPrice): number;
|
|
327
260
|
/**
|
|
328
261
|
* Check if a product is on sale (discounted)
|
|
329
262
|
*
|
|
330
|
-
* @param product - Product with
|
|
263
|
+
* @param product - Product with price data
|
|
331
264
|
* @returns True if the final price is less than the base price
|
|
332
265
|
*
|
|
333
266
|
* @example
|
|
@@ -339,7 +272,7 @@ declare function isOnSale(product: ProductWithPrice): boolean;
|
|
|
339
272
|
/**
|
|
340
273
|
* Get the discount percentage for a product on sale
|
|
341
274
|
*
|
|
342
|
-
* @param product - Product with
|
|
275
|
+
* @param product - Product with price data
|
|
343
276
|
* @returns Discount percentage (0-100), or 0 if not on sale
|
|
344
277
|
*
|
|
345
278
|
* @example
|
|
@@ -352,14 +285,14 @@ declare function getDiscountPercentage(product: ProductWithPrice): number;
|
|
|
352
285
|
/**
|
|
353
286
|
* Get the markup percentage for a product
|
|
354
287
|
*
|
|
355
|
-
* @param product - Product with
|
|
288
|
+
* @param product - Product with price data
|
|
356
289
|
* @returns Markup percentage, or 0 if no markup
|
|
357
290
|
*/
|
|
358
291
|
declare function getMarkupPercentage(product: ProductWithPrice): number;
|
|
359
292
|
/**
|
|
360
293
|
* Get the currency for a product
|
|
361
294
|
*
|
|
362
|
-
* @param product - Product with
|
|
295
|
+
* @param product - Product with price data
|
|
363
296
|
* @returns Currency code (default: "GHS")
|
|
364
297
|
*/
|
|
365
298
|
declare function getProductCurrency(product: ProductWithPrice): string;
|
|
@@ -367,7 +300,7 @@ declare function getProductCurrency(product: ProductWithPrice): string;
|
|
|
367
300
|
* Format a product's display price
|
|
368
301
|
* Convenience function combining getDisplayPrice and formatPrice
|
|
369
302
|
*
|
|
370
|
-
* @param product - Product with
|
|
303
|
+
* @param product - Product with price data
|
|
371
304
|
* @param locale - BCP 47 locale string (default: "en-US")
|
|
372
305
|
* @returns Formatted price string
|
|
373
306
|
*
|
|
@@ -438,4 +371,4 @@ interface ApiResponse<T> {
|
|
|
438
371
|
metadata?: ResponseMetadata;
|
|
439
372
|
}
|
|
440
373
|
|
|
441
|
-
export { ApiError, type ApiResponse, CURRENCY_SYMBOLS, type FormatCompactOptions, type FormatPriceOptions, type FrontendContext, MOBILE_MONEY_PROVIDERS, type MutationRequest,
|
|
374
|
+
export { ApiError, type ApiResponse, CURRENCY_SYMBOLS, type FormatCompactOptions, type FormatPriceOptions, type FrontendContext, MOBILE_MONEY_PROVIDERS, type MutationRequest, PaymentErrorDetails, PaymentResponse, PaymentStatusResponse, type PriceInfo, type ProductWithPrice, QueryBuilder, type QueryRequest, type ResponseMetadata, type TaxComponent, type TaxInfo, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, isOnSale, normalizePaymentResponse, normalizeStatusResponse, parsePrice, query };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PaymentErrorDetails, a as PaymentResponse, b as PaymentStatusResponse, A as ApiError } from './ads-
|
|
2
|
-
export {
|
|
1
|
+
import { P as PaymentErrorDetails, a as PaymentResponse, b as PaymentStatusResponse, A as ApiError } from './ads-DRfobDQ9.js';
|
|
2
|
+
export { ab as AUTHORIZATION_TYPE, ag as AUTH_MUTATION, eE as AdConfig, eG as AdContextValue, eF as AdCreative, eC as AdPosition, eB as AdSlot, eD as AdTheme, b0 as AddOn, bL as AddOnDetails, c5 as AddOnGroupDetails, b2 as AddOnOption, c4 as AddOnOptionDetails, b3 as AddOnOptionPrice, b1 as AddOnWithOptions, ca as AddToCartInput, e1 as AddressData, et as AddressInfo, bA as AdjustmentType, co as AmountToPay, bH as AppliedDiscount, ec as AuthResponse, p as AuthService, q as AuthStatus, ev as AuthenticatedData, cY as AuthorizationType, dR as AvailabilityCheck, dS as AvailabilityResult, dz as AvailableSlot, bG as BenefitType, dC as Booking, dt as BookingRequirementOverride, dB as BookingStatus, dD as BookingWithDetails, cI as BufferTimes, bb as Bundle, bf as BundleComponentData, bg as BundleComponentInfo, ba as BundlePriceType, bd as BundleProduct, bQ as BundleSelectionData, bO as BundleSelectionInput, bP as BundleStoredSelection, bc as BundleSummary, be as BundleWithDetails, d4 as Business, di as BusinessHours, d3 as BusinessPreferences, B as BusinessService, dh as BusinessSettings, d2 as BusinessType, df as BusinessWithLocations, a4 as CHECKOUT_MODE, ah as CHECKOUT_MUTATION, a7 as CHECKOUT_STEP, ad as CONTACT_TYPE, dH as CancelBookingInput, cC as CancelOrderInput, cK as CancellationPolicy, bV as Cart, bM as CartAddOn, by as CartChannel, bW as CartItem, c7 as CartItemDetails, l as CartOperations, bx as CartStatus, cc as CartSummary, bX as CartTotals, e as CatalogueQueries, b5 as Category, dj as CategoryInfo, b6 as CategorySummary, s as ChangePasswordInput, dF as CheckSlotAvailabilityInput, ef as CheckoutAddressInfo, eh as CheckoutCustomerInfo, $ as CheckoutFormData, cA as CheckoutInput, X as CheckoutMode, m as CheckoutOperations, Y as CheckoutOrderType, Z as CheckoutPaymentMethod, a0 as CheckoutResult, m as CheckoutService, _ as CheckoutStep, bF as ChosenPrice, C as CimplifyClient, d as CimplifyConfig, z as CimplifyElement, y as CimplifyElements, as as CimplifyError, b7 as Collection, b9 as CollectionProduct, b8 as CollectionSummary, bm as ComponentGroup, bn as ComponentGroupWithComponents, br as ComponentPriceBreakdown, bp as ComponentSelectionInput, bj as ComponentSourceType, bk as Composite, bo as CompositeComponent, bS as CompositePriceBreakdown, bq as CompositePriceResult, bh as CompositePricingMode, bT as CompositeSelectionData, bp as CompositeSelectionInput, bR as CompositeStoredSelection, bl as CompositeWithDetails, a3 as ContactType, dZ as CreateAddressInput, d$ as CreateMobileMoneyInput, an as Currency, dU as Customer, dV as CustomerAddress, dX as CustomerLinkPreferences, dW as CustomerMobileMoney, cH as CustomerServicePreferences, al as DEFAULT_COUNTRY, ak as DEFAULT_CURRENCY, ac as DEVICE_TYPE, dA as DayAvailability, cR as DepositResult, aQ as DepositType, a2 as DeviceType, aP as DigitalProductType, bI as DiscountBreakdown, bJ as DiscountDetails, b_ as DisplayAddOn, b$ as DisplayAddOnOption, bY as DisplayCart, bZ as DisplayCartItem, H as ELEMENT_TYPES, E as EVENT_TYPES, es as ElementAppearance, eA as ElementEventHandler, W as ElementEventType, N as ElementOptions, V as ElementType, ew as ElementsCheckoutData, ex as ElementsCheckoutResult, J as ElementsOptions, e3 as EnrollAndLinkOrderInput, e6 as EnrollAndLinkOrderResult, e0 as EnrollmentData, ax as Err, aq as ErrorCode, ar as ErrorCodeType, cn as FeeBearerType, F as FetchQuoteInput, cl as FulfillmentLink, ck as FulfillmentStatus, cj as FulfillmentType, ej as FxQuote, ei as FxQuoteRequest, ek as FxRateResponse, v as FxService, dE as GetAvailableSlotsInput, o as GetOrdersOptions, G as GetProductsOptions, bi as GroupPricingBehavior, ez as IframeToParentMessage, d0 as InitializePaymentResult, I as InventoryService, dT as InventorySummary, aN as InventoryType, K as KitchenOrderItem, x as KitchenOrderResult, af as LINK_MUTATION, ae as LINK_QUERY, bU as LineConfiguration, cp as LineItem, cg as LineType, dY as LinkData, e5 as LinkEnrollResult, L as LinkService, e7 as LinkSession, e4 as LinkStatusResult, w as LiteBootstrap, u as LiteService, d7 as Location, cU as LocationAppointment, bu as LocationProductPrice, dQ as LocationStock, d5 as LocationTaxBehavior, d6 as LocationTaxOverrides, da as LocationTimeProfile, dg as LocationWithDetails, M as MESSAGE_TYPES, aa as MOBILE_MONEY_PROVIDER, e2 as MobileMoneyData, eg as MobileMoneyDetails, a1 as MobileMoneyProvider, am as Money, aj as ORDER_MUTATION, a5 as ORDER_TYPE, er as ObservabilityHooks, aw as Ok, cq as Order, cf as OrderChannel, cz as OrderFilter, cm as OrderFulfillmentSummary, ct as OrderGroup, cx as OrderGroupDetails, cu as OrderGroupPayment, cs as OrderGroupPaymentState, cw as OrderGroupPaymentSummary, cr as OrderHistory, ch as OrderLineState, ci as OrderLineStatus, cy as OrderPaymentEvent, O as OrderQueries, cv as OrderSplitDetail, cd as OrderStatus, r as OtpResult, a6 as PAYMENT_METHOD, ai as PAYMENT_MUTATION, a8 as PAYMENT_STATE, a9 as PICKUP_TIME_TYPE, ap as Pagination, ao as PaginationParams, ey as ParentToIframeMessage, c$ as Payment, c_ as PaymentMethod, eu as PaymentMethodInfo, cX as PaymentMethodType, cZ as PaymentProcessingState, cW as PaymentProvider, ce as PaymentState, cV as PaymentStatus, ee as PickupTime, ed as PickupTimeType, bt as Price, bB as PriceAdjustment, bE as PriceDecisionPath, bs as PriceEntryType, bD as PricePathTaxInfo, j as PriceQuote, bz as PriceSource, cM as PricingOverrides, aS as Product, b4 as ProductAddOn, bv as ProductAvailability, dO as ProductStock, bw as ProductTimeProfile, aM as ProductType, aU as ProductVariant, aZ as ProductVariantValue, aT as ProductWithDetails, f as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, h as QuoteDynamicBuckets, g as QuoteStatus, i as QuoteUiMessage, R as RefreshQuoteInput, k as RefreshQuoteResult, cD as RefundOrderInput, cG as ReminderMethod, cJ as ReminderSettings, el as RequestContext, eo as RequestErrorEvent, ea as RequestOtpInput, em as RequestStartEvent, en as RequestSuccessEvent, dG as RescheduleBookingInput, cP as ResourceAssignment, dq as ResourceAvailabilityException, dp as ResourceAvailabilityRule, du as ResourceType, av as Result, ep as RetryEvent, e9 as RevokeAllSessionsResult, e8 as RevokeSessionResult, dc as Room, aR as SalesChannel, cN as SchedulingMetadata, cQ as SchedulingResult, t as SchedulingService, S as SearchOptions, bK as SelectedAddOnOption, dv as Service, dl as ServiceAvailabilityException, dI as ServiceAvailabilityParams, dJ as ServiceAvailabilityResult, dk as ServiceAvailabilityRule, dd as ServiceCharge, cL as ServiceNotes, cS as ServiceScheduleRequest, ds as ServiceStaffRequirement, cE as ServiceStatus, dw as ServiceWithStaff, eq as SessionChangeEvent, dx as Staff, cO as StaffAssignment, dn as StaffAvailabilityException, dm as StaffAvailabilityRule, dr as StaffBookingProfile, cF as StaffRole, cT as StaffScheduleItem, dM as Stock, dN as StockLevel, dK as StockOwnershipType, dL as StockStatus, de as StorefrontBootstrap, d1 as SubmitAuthorizationInput, db as Table, T as TableInfo, bC as TaxPathComponent, d8 as TimeRange, d9 as TimeRanges, dy as TimeSlot, c8 as UICart, c0 as UICartBusiness, c2 as UICartCustomer, c1 as UICartLocation, c3 as UICartPricing, c9 as UICartResponse, d_ as UpdateAddressInput, cb as UpdateCartItemInput, cB as UpdateOrderStatusInput, U as UpdateProfileInput, aW as VariantAxis, a$ as VariantAxisSelection, aY as VariantAxisValue, aX as VariantAxisWithValues, bN as VariantDetails, c6 as VariantDetailsDTO, aV as VariantDisplayAttribute, a_ as VariantLocationAvailability, dP as VariantStock, aO as VariantStrategy, eb as VerifyOtpInput, aK as combine, aL as combineObject, c as createCimplifyClient, D as createElements, az as err, aE as flatMap, aI as fromPromise, n as generateIdempotencyKey, aF as getOrElse, at as isCimplifyError, aB as isErr, aA as isOk, au as isRetryableError, aD as mapError, aC as mapResult, ay as ok, aH as toNullable, aJ as tryCatch, aG as unwrap } from './ads-DRfobDQ9.js';
|
|
3
3
|
|
|
4
4
|
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
|
5
5
|
type SortOrder = "asc" | "desc";
|
|
@@ -37,7 +37,7 @@ interface TaxComponent {
|
|
|
37
37
|
rate: number;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Complete tax information from a
|
|
40
|
+
* Complete tax information from a pricing response
|
|
41
41
|
*/
|
|
42
42
|
interface TaxInfo {
|
|
43
43
|
/** Total tax rate as percentage */
|
|
@@ -70,42 +70,20 @@ interface PriceInfo {
|
|
|
70
70
|
decision_path?: string;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
interface ParsedPrice {
|
|
77
|
-
/** Original price before markup/discount */
|
|
78
|
-
basePrice: number;
|
|
79
|
-
/** Final price after all adjustments */
|
|
80
|
-
finalPrice: number;
|
|
81
|
-
/** Currency code (e.g., "GHS", "USD") */
|
|
82
|
-
currency: string;
|
|
83
|
-
/** Decision path showing how price was calculated */
|
|
84
|
-
decisionPath: string;
|
|
85
|
-
/** Discount percentage if final < base */
|
|
86
|
-
discountPercentage?: number;
|
|
87
|
-
/** Markup percentage if final > base */
|
|
88
|
-
markupPercentage?: number;
|
|
89
|
-
/** Markup amount if final > base */
|
|
90
|
-
markupAmount?: number;
|
|
91
|
-
/** Tax information extracted from the path */
|
|
92
|
-
taxInfo?: TaxInfo;
|
|
93
|
-
/** Whether the price path is valid and not expired */
|
|
94
|
-
isValid: boolean;
|
|
95
|
-
/** Whether the price path has expired */
|
|
96
|
-
isExpired: boolean;
|
|
97
|
-
/** Unix timestamp when the price expires */
|
|
98
|
-
expiryTimestamp?: number;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Minimal product shape for price utilities
|
|
102
|
-
* Allows extracting price from either price_path or price_info
|
|
73
|
+
* Minimal product shape for price utilities.
|
|
74
|
+
* Uses quote-aware `price_info` and plain numeric fallback fields.
|
|
103
75
|
*/
|
|
104
76
|
interface ProductWithPrice {
|
|
105
|
-
/**
|
|
106
|
-
price_path?: string | null;
|
|
107
|
-
/** Pre-parsed price info */
|
|
77
|
+
/** Pre-parsed price info from backend */
|
|
108
78
|
price_info?: PriceInfo;
|
|
79
|
+
/** Final computed price in plain field form (if provided by API) */
|
|
80
|
+
final_price?: number | string | null;
|
|
81
|
+
/** Base/original price in plain field form */
|
|
82
|
+
base_price?: number | string | null;
|
|
83
|
+
/** Default/indicative price in plain field form */
|
|
84
|
+
default_price?: number | string | null;
|
|
85
|
+
/** Currency in plain field form */
|
|
86
|
+
currency?: string | null;
|
|
109
87
|
}
|
|
110
88
|
/**
|
|
111
89
|
* Options for price formatting functions
|
|
@@ -134,15 +112,13 @@ interface FormatCompactOptions {
|
|
|
134
112
|
* Price Utilities
|
|
135
113
|
*
|
|
136
114
|
* Comprehensive utilities for parsing, formatting, and displaying prices.
|
|
137
|
-
* Handles
|
|
138
|
-
* and product price helpers.
|
|
115
|
+
* Handles quote-aware pricing fields, currency formatting, and product price helpers.
|
|
139
116
|
*
|
|
140
117
|
* @example
|
|
141
118
|
* ```typescript
|
|
142
119
|
* import {
|
|
143
120
|
* formatPrice,
|
|
144
121
|
* formatPriceCompact,
|
|
145
|
-
* parsePricePath,
|
|
146
122
|
* isOnSale,
|
|
147
123
|
* getDiscountPercentage
|
|
148
124
|
* } from '@cimplify/sdk';
|
|
@@ -263,53 +239,10 @@ declare function formatMoney(amount: string | number, currency?: string): string
|
|
|
263
239
|
*/
|
|
264
240
|
declare function parsePrice(value: string | number | undefined | null): number;
|
|
265
241
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* Price paths are HMAC-SHA256 signed and contain:
|
|
269
|
-
* - Base price (original price before markup)
|
|
270
|
-
* - Final price (what customer pays)
|
|
271
|
-
* - Currency
|
|
272
|
-
* - Tax information
|
|
273
|
-
* - Decision path (pricing adjustments trail)
|
|
274
|
-
*
|
|
275
|
-
* Format: "base_price|final_price|currency|tax_info|decision_path§expiry§signature"
|
|
276
|
-
*
|
|
277
|
-
* @param signedPricePath - The signed price path from backend
|
|
278
|
-
* @returns ParsedPrice object with extracted pricing information
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* const parsed = parsePricePath(product.price_path);
|
|
282
|
-
* console.log(parsed.finalPrice); // 29.99
|
|
283
|
-
* console.log(parsed.currency); // "GHS"
|
|
284
|
-
* console.log(parsed.isValid); // true
|
|
285
|
-
* console.log(parsed.taxInfo); // { taxRate: 15, ... }
|
|
286
|
-
*/
|
|
287
|
-
declare function parsePricePath(signedPricePath: string | undefined | null): ParsedPrice;
|
|
288
|
-
/**
|
|
289
|
-
* Convert a ParsedPrice to PriceInfo format
|
|
290
|
-
* Useful for compatibility with components expecting snake_case format
|
|
291
|
-
*
|
|
292
|
-
* @param parsedPrice - The parsed price object
|
|
293
|
-
* @returns PriceInfo object in snake_case format
|
|
294
|
-
*/
|
|
295
|
-
declare function parsedPriceToPriceInfo(parsedPrice: ParsedPrice): PriceInfo;
|
|
296
|
-
/**
|
|
297
|
-
* Extract PriceInfo directly from a signed price path
|
|
298
|
-
* Convenience function that parses and converts in one step
|
|
299
|
-
*
|
|
300
|
-
* @param signedPricePath - The signed price path from backend
|
|
301
|
-
* @returns PriceInfo object ready for use in components
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
* const priceInfo = extractPriceInfo(product.price_path);
|
|
305
|
-
* console.log(priceInfo.final_price); // 29.99
|
|
306
|
-
*/
|
|
307
|
-
declare function extractPriceInfo(signedPricePath: string | undefined | null): PriceInfo;
|
|
308
|
-
/**
|
|
309
|
-
* Get the display price from a product
|
|
310
|
-
* Handles both price_path and pre-parsed price_info
|
|
242
|
+
* Get the display price from a product.
|
|
243
|
+
* Prefers quote-aware price_info, then plain price fields.
|
|
311
244
|
*
|
|
312
|
-
* @param product - Product with
|
|
245
|
+
* @param product - Product with price data
|
|
313
246
|
* @returns The final price to display
|
|
314
247
|
*
|
|
315
248
|
* @example
|
|
@@ -320,14 +253,14 @@ declare function getDisplayPrice(product: ProductWithPrice): number;
|
|
|
320
253
|
/**
|
|
321
254
|
* Get the base price from a product (before markup/discount)
|
|
322
255
|
*
|
|
323
|
-
* @param product - Product with
|
|
256
|
+
* @param product - Product with price data
|
|
324
257
|
* @returns The base price before adjustments
|
|
325
258
|
*/
|
|
326
259
|
declare function getBasePrice(product: ProductWithPrice): number;
|
|
327
260
|
/**
|
|
328
261
|
* Check if a product is on sale (discounted)
|
|
329
262
|
*
|
|
330
|
-
* @param product - Product with
|
|
263
|
+
* @param product - Product with price data
|
|
331
264
|
* @returns True if the final price is less than the base price
|
|
332
265
|
*
|
|
333
266
|
* @example
|
|
@@ -339,7 +272,7 @@ declare function isOnSale(product: ProductWithPrice): boolean;
|
|
|
339
272
|
/**
|
|
340
273
|
* Get the discount percentage for a product on sale
|
|
341
274
|
*
|
|
342
|
-
* @param product - Product with
|
|
275
|
+
* @param product - Product with price data
|
|
343
276
|
* @returns Discount percentage (0-100), or 0 if not on sale
|
|
344
277
|
*
|
|
345
278
|
* @example
|
|
@@ -352,14 +285,14 @@ declare function getDiscountPercentage(product: ProductWithPrice): number;
|
|
|
352
285
|
/**
|
|
353
286
|
* Get the markup percentage for a product
|
|
354
287
|
*
|
|
355
|
-
* @param product - Product with
|
|
288
|
+
* @param product - Product with price data
|
|
356
289
|
* @returns Markup percentage, or 0 if no markup
|
|
357
290
|
*/
|
|
358
291
|
declare function getMarkupPercentage(product: ProductWithPrice): number;
|
|
359
292
|
/**
|
|
360
293
|
* Get the currency for a product
|
|
361
294
|
*
|
|
362
|
-
* @param product - Product with
|
|
295
|
+
* @param product - Product with price data
|
|
363
296
|
* @returns Currency code (default: "GHS")
|
|
364
297
|
*/
|
|
365
298
|
declare function getProductCurrency(product: ProductWithPrice): string;
|
|
@@ -367,7 +300,7 @@ declare function getProductCurrency(product: ProductWithPrice): string;
|
|
|
367
300
|
* Format a product's display price
|
|
368
301
|
* Convenience function combining getDisplayPrice and formatPrice
|
|
369
302
|
*
|
|
370
|
-
* @param product - Product with
|
|
303
|
+
* @param product - Product with price data
|
|
371
304
|
* @param locale - BCP 47 locale string (default: "en-US")
|
|
372
305
|
* @returns Formatted price string
|
|
373
306
|
*
|
|
@@ -438,4 +371,4 @@ interface ApiResponse<T> {
|
|
|
438
371
|
metadata?: ResponseMetadata;
|
|
439
372
|
}
|
|
440
373
|
|
|
441
|
-
export { ApiError, type ApiResponse, CURRENCY_SYMBOLS, type FormatCompactOptions, type FormatPriceOptions, type FrontendContext, MOBILE_MONEY_PROVIDERS, type MutationRequest,
|
|
374
|
+
export { ApiError, type ApiResponse, CURRENCY_SYMBOLS, type FormatCompactOptions, type FormatPriceOptions, type FrontendContext, MOBILE_MONEY_PROVIDERS, type MutationRequest, PaymentErrorDetails, PaymentResponse, PaymentStatusResponse, type PriceInfo, type ProductWithPrice, QueryBuilder, type QueryRequest, type ResponseMetadata, type TaxComponent, type TaxInfo, categorizePaymentError, detectMobileMoneyProvider, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, isOnSale, normalizePaymentResponse, normalizeStatusResponse, parsePrice, query };
|