@cimplify/sdk 0.6.2 → 0.6.4
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.js +2592 -1709
- package/dist/index.mjs +2592 -1709
- package/dist/react.js +215 -1
- package/dist/react.mjs +217 -4
- package/package.json +5 -1
- package/dist/ads-CXOn6J7P.d.mts +0 -3325
- package/dist/ads-CXOn6J7P.d.ts +0 -3325
- package/dist/index.d.mts +0 -377
- package/dist/index.d.ts +0 -377
- package/dist/react.d.mts +0 -105
- package/dist/react.d.ts +0 -105
package/dist/index.d.ts
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import { P as PaymentErrorDetails, a as PaymentResponse, b as PaymentStatusResponse, A as ApiError } from './ads-CXOn6J7P.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-CXOn6J7P.js';
|
|
3
|
-
|
|
4
|
-
type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith";
|
|
5
|
-
type SortOrder = "asc" | "desc";
|
|
6
|
-
declare class QueryBuilder {
|
|
7
|
-
private entity;
|
|
8
|
-
private filters;
|
|
9
|
-
private modifiers;
|
|
10
|
-
private pathSegments;
|
|
11
|
-
constructor(entity: string);
|
|
12
|
-
path(segment: string): this;
|
|
13
|
-
where(field: string, op: Operator, value: unknown): this;
|
|
14
|
-
and(field: string, op: Operator, value: unknown): this;
|
|
15
|
-
sort(field: string, order?: SortOrder): this;
|
|
16
|
-
limit(n: number): this;
|
|
17
|
-
offset(n: number): this;
|
|
18
|
-
count(): this;
|
|
19
|
-
enriched(): this;
|
|
20
|
-
build(): string;
|
|
21
|
-
toString(): string;
|
|
22
|
-
}
|
|
23
|
-
declare function query(entity: string): QueryBuilder;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Price Types
|
|
27
|
-
*
|
|
28
|
-
* Types for price parsing, formatting, and display utilities.
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Individual tax component (e.g., VAT, NHIL, GETFund)
|
|
32
|
-
*/
|
|
33
|
-
interface TaxComponent {
|
|
34
|
-
/** Tax component name */
|
|
35
|
-
name: string;
|
|
36
|
-
/** Tax rate as percentage (e.g., 15.0 for 15%) */
|
|
37
|
-
rate: number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Complete tax information from a pricing response
|
|
41
|
-
*/
|
|
42
|
-
interface TaxInfo {
|
|
43
|
-
/** Total tax rate as percentage */
|
|
44
|
-
taxRate: number;
|
|
45
|
-
/** Calculated tax amount */
|
|
46
|
-
taxAmount: number;
|
|
47
|
-
/** Whether tax is included in the displayed price */
|
|
48
|
-
isInclusive: boolean;
|
|
49
|
-
/** Individual tax components that make up the total */
|
|
50
|
-
components: TaxComponent[];
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Price information in snake_case format (as returned from backend)
|
|
54
|
-
* Used by components that work with raw API responses
|
|
55
|
-
*/
|
|
56
|
-
interface PriceInfo {
|
|
57
|
-
/** Original price before markup/discount */
|
|
58
|
-
base_price: number;
|
|
59
|
-
/** Final price after all adjustments */
|
|
60
|
-
final_price: number;
|
|
61
|
-
/** Markup percentage if applicable */
|
|
62
|
-
markup_percentage?: number;
|
|
63
|
-
/** Markup amount if applicable */
|
|
64
|
-
markup_amount?: number;
|
|
65
|
-
/** Currency code (e.g., "GHS", "USD") */
|
|
66
|
-
currency?: string;
|
|
67
|
-
/** Tax information */
|
|
68
|
-
tax_info?: TaxInfo;
|
|
69
|
-
/** Decision path showing pricing adjustments */
|
|
70
|
-
decision_path?: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Minimal product shape for price utilities.
|
|
74
|
-
* Uses quote-aware `price_info` and plain numeric fallback fields.
|
|
75
|
-
*/
|
|
76
|
-
interface ProductWithPrice {
|
|
77
|
-
/** Pre-parsed price info from backend */
|
|
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;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Options for price formatting functions
|
|
90
|
-
*/
|
|
91
|
-
interface FormatPriceOptions {
|
|
92
|
-
/** Currency code (default: "GHS") */
|
|
93
|
-
currency?: string;
|
|
94
|
-
/** Locale for Intl.NumberFormat (default: "en-US") */
|
|
95
|
-
locale?: string;
|
|
96
|
-
/** Minimum fraction digits (default: 2) */
|
|
97
|
-
minimumFractionDigits?: number;
|
|
98
|
-
/** Maximum fraction digits (default: 2) */
|
|
99
|
-
maximumFractionDigits?: number;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Options for compact price formatting
|
|
103
|
-
*/
|
|
104
|
-
interface FormatCompactOptions {
|
|
105
|
-
/** Currency code (default: "GHS") */
|
|
106
|
-
currency?: string;
|
|
107
|
-
/** Number of decimal places for compact notation (default: 1) */
|
|
108
|
-
decimals?: number;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Price Utilities
|
|
113
|
-
*
|
|
114
|
-
* Comprehensive utilities for parsing, formatting, and displaying prices.
|
|
115
|
-
* Handles quote-aware pricing fields, currency formatting, and product price helpers.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* import {
|
|
120
|
-
* formatPrice,
|
|
121
|
-
* formatPriceCompact,
|
|
122
|
-
* isOnSale,
|
|
123
|
-
* getDiscountPercentage
|
|
124
|
-
* } from '@cimplify/sdk';
|
|
125
|
-
*
|
|
126
|
-
* // Format prices
|
|
127
|
-
* formatPrice(29.99, 'USD'); // "$29.99"
|
|
128
|
-
* formatPrice(29.99, 'GHS'); // "GH₵29.99"
|
|
129
|
-
* formatPriceCompact(1500000, 'USD'); // "$1.5M"
|
|
130
|
-
*
|
|
131
|
-
* // Check for discounts
|
|
132
|
-
* if (isOnSale(product)) {
|
|
133
|
-
* console.log(`${getDiscountPercentage(product)}% off!`);
|
|
134
|
-
* }
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Currency code to symbol mapping
|
|
140
|
-
* Includes major world currencies and African currencies
|
|
141
|
-
*/
|
|
142
|
-
declare const CURRENCY_SYMBOLS: Record<string, string>;
|
|
143
|
-
/**
|
|
144
|
-
* Get currency symbol for a currency code
|
|
145
|
-
* @param currencyCode - ISO 4217 currency code (e.g., "USD", "GHS")
|
|
146
|
-
* @returns Currency symbol or the code itself if not found
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* getCurrencySymbol('USD') // "$"
|
|
150
|
-
* getCurrencySymbol('GHS') // "GH₵"
|
|
151
|
-
* getCurrencySymbol('XYZ') // "XYZ"
|
|
152
|
-
*/
|
|
153
|
-
declare function getCurrencySymbol(currencyCode: string): string;
|
|
154
|
-
/**
|
|
155
|
-
* Format a number compactly with K/M/B suffixes
|
|
156
|
-
* @param value - Number to format
|
|
157
|
-
* @param decimals - Decimal places (default: 1)
|
|
158
|
-
* @returns Compact string representation
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* formatNumberCompact(1234) // "1.2K"
|
|
162
|
-
* formatNumberCompact(1500000) // "1.5M"
|
|
163
|
-
* formatNumberCompact(2500000000) // "2.5B"
|
|
164
|
-
*/
|
|
165
|
-
declare function formatNumberCompact(value: number, decimals?: number): string;
|
|
166
|
-
/**
|
|
167
|
-
* Format a price with locale-aware currency formatting
|
|
168
|
-
* Uses Intl.NumberFormat for proper localization
|
|
169
|
-
*
|
|
170
|
-
* @param amount - Price amount (number or string)
|
|
171
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
172
|
-
* @param locale - BCP 47 locale string (default: "en-US")
|
|
173
|
-
* @returns Formatted price string
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* formatPrice(29.99, 'USD') // "$29.99"
|
|
177
|
-
* formatPrice(29.99, 'GHS') // "GH₵29.99"
|
|
178
|
-
* formatPrice('29.99', 'EUR') // "€29.99"
|
|
179
|
-
* formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
|
|
180
|
-
*/
|
|
181
|
-
declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
|
|
182
|
-
/**
|
|
183
|
-
* Format a price with +/- sign for adjustments
|
|
184
|
-
* Useful for showing price changes, modifiers, or discounts
|
|
185
|
-
*
|
|
186
|
-
* @param amount - Adjustment amount (positive or negative)
|
|
187
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
188
|
-
* @param locale - BCP 47 locale string (default: "en-US")
|
|
189
|
-
* @returns Formatted adjustment string with sign
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* formatPriceAdjustment(5.00, 'USD') // "+$5.00"
|
|
193
|
-
* formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
|
|
194
|
-
* formatPriceAdjustment(0, 'EUR') // "€0.00"
|
|
195
|
-
*/
|
|
196
|
-
declare function formatPriceAdjustment(amount: number, currency?: string, locale?: string): string;
|
|
197
|
-
/**
|
|
198
|
-
* Format a price compactly for large numbers
|
|
199
|
-
* Uses K/M/B suffixes for thousands, millions, billions
|
|
200
|
-
*
|
|
201
|
-
* @param amount - Price amount (number or string)
|
|
202
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
203
|
-
* @param decimals - Decimal places for compact notation (default: 1)
|
|
204
|
-
* @returns Compact formatted price
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* formatPriceCompact(999, 'USD') // "$999.00"
|
|
208
|
-
* formatPriceCompact(1500, 'GHS') // "GH₵1.5K"
|
|
209
|
-
* formatPriceCompact(2500000, 'USD') // "$2.5M"
|
|
210
|
-
* formatPriceCompact(1200000000, 'EUR') // "€1.2B"
|
|
211
|
-
*/
|
|
212
|
-
declare function formatPriceCompact(amount: number | string, currency?: string, decimals?: number): string;
|
|
213
|
-
/**
|
|
214
|
-
* Simple currency symbol + amount format
|
|
215
|
-
* Lighter alternative to formatPrice without Intl
|
|
216
|
-
*
|
|
217
|
-
* @param amount - Price amount (number or string)
|
|
218
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
219
|
-
* @returns Simple formatted price
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* formatMoney(29.99, 'USD') // "$29.99"
|
|
223
|
-
* formatMoney('15.00', 'GHS') // "GH₵15.00"
|
|
224
|
-
*/
|
|
225
|
-
declare function formatMoney(amount: string | number, currency?: string): string;
|
|
226
|
-
/**
|
|
227
|
-
* Parse a price string or number to a numeric value
|
|
228
|
-
* Handles various input formats gracefully
|
|
229
|
-
*
|
|
230
|
-
* @param value - Value to parse (string, number, or undefined)
|
|
231
|
-
* @returns Parsed numeric value, or 0 if invalid
|
|
232
|
-
*
|
|
233
|
-
* @example
|
|
234
|
-
* parsePrice('29.99') // 29.99
|
|
235
|
-
* parsePrice(29.99) // 29.99
|
|
236
|
-
* parsePrice('$29.99') // 29.99 (strips non-numeric prefix)
|
|
237
|
-
* parsePrice(undefined) // 0
|
|
238
|
-
* parsePrice('invalid') // 0
|
|
239
|
-
*/
|
|
240
|
-
declare function parsePrice(value: string | number | undefined | null): number;
|
|
241
|
-
/**
|
|
242
|
-
* Get the display price from a product.
|
|
243
|
-
* Prefers quote-aware price_info, then plain price fields.
|
|
244
|
-
*
|
|
245
|
-
* @param product - Product with price data
|
|
246
|
-
* @returns The final price to display
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* const price = getDisplayPrice(product);
|
|
250
|
-
* console.log(formatPrice(price, 'GHS')); // "GH₵29.99"
|
|
251
|
-
*/
|
|
252
|
-
declare function getDisplayPrice(product: ProductWithPrice): number;
|
|
253
|
-
/**
|
|
254
|
-
* Get the base price from a product (before markup/discount)
|
|
255
|
-
*
|
|
256
|
-
* @param product - Product with price data
|
|
257
|
-
* @returns The base price before adjustments
|
|
258
|
-
*/
|
|
259
|
-
declare function getBasePrice(product: ProductWithPrice): number;
|
|
260
|
-
/**
|
|
261
|
-
* Check if a product is on sale (discounted)
|
|
262
|
-
*
|
|
263
|
-
* @param product - Product with price data
|
|
264
|
-
* @returns True if the final price is less than the base price
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* if (isOnSale(product)) {
|
|
268
|
-
* return <Badge>Sale!</Badge>;
|
|
269
|
-
* }
|
|
270
|
-
*/
|
|
271
|
-
declare function isOnSale(product: ProductWithPrice): boolean;
|
|
272
|
-
/**
|
|
273
|
-
* Get the discount percentage for a product on sale
|
|
274
|
-
*
|
|
275
|
-
* @param product - Product with price data
|
|
276
|
-
* @returns Discount percentage (0-100), or 0 if not on sale
|
|
277
|
-
*
|
|
278
|
-
* @example
|
|
279
|
-
* const discount = getDiscountPercentage(product);
|
|
280
|
-
* if (discount > 0) {
|
|
281
|
-
* return <Badge>{discount}% OFF</Badge>;
|
|
282
|
-
* }
|
|
283
|
-
*/
|
|
284
|
-
declare function getDiscountPercentage(product: ProductWithPrice): number;
|
|
285
|
-
/**
|
|
286
|
-
* Get the markup percentage for a product
|
|
287
|
-
*
|
|
288
|
-
* @param product - Product with price data
|
|
289
|
-
* @returns Markup percentage, or 0 if no markup
|
|
290
|
-
*/
|
|
291
|
-
declare function getMarkupPercentage(product: ProductWithPrice): number;
|
|
292
|
-
/**
|
|
293
|
-
* Get the currency for a product
|
|
294
|
-
*
|
|
295
|
-
* @param product - Product with price data
|
|
296
|
-
* @returns Currency code (default: "GHS")
|
|
297
|
-
*/
|
|
298
|
-
declare function getProductCurrency(product: ProductWithPrice): string;
|
|
299
|
-
/**
|
|
300
|
-
* Format a product's display price
|
|
301
|
-
* Convenience function combining getDisplayPrice and formatPrice
|
|
302
|
-
*
|
|
303
|
-
* @param product - Product with price data
|
|
304
|
-
* @param locale - BCP 47 locale string (default: "en-US")
|
|
305
|
-
* @returns Formatted price string
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* <span>{formatProductPrice(product)}</span> // "GH₵29.99"
|
|
309
|
-
*/
|
|
310
|
-
declare function formatProductPrice(product: ProductWithPrice, locale?: string): string;
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Categorize payment errors into user-friendly messages
|
|
314
|
-
*/
|
|
315
|
-
declare function categorizePaymentError(error: Error, errorCode?: string): PaymentErrorDetails;
|
|
316
|
-
/**
|
|
317
|
-
* Normalize payment response from different formats into a standard PaymentResponse
|
|
318
|
-
*/
|
|
319
|
-
declare function normalizePaymentResponse(response: unknown): PaymentResponse;
|
|
320
|
-
declare function isPaymentStatusSuccess(status: string | undefined): boolean;
|
|
321
|
-
declare function isPaymentStatusFailure(status: string | undefined): boolean;
|
|
322
|
-
declare function isPaymentStatusRequiresAction(status: string | undefined): boolean;
|
|
323
|
-
/**
|
|
324
|
-
* Normalize payment status response into a standard format
|
|
325
|
-
*/
|
|
326
|
-
declare function normalizeStatusResponse(response: unknown): PaymentStatusResponse;
|
|
327
|
-
/** Mobile money provider display names */
|
|
328
|
-
declare const MOBILE_MONEY_PROVIDERS: {
|
|
329
|
-
readonly mtn: {
|
|
330
|
-
readonly name: "MTN Mobile Money";
|
|
331
|
-
readonly prefix: readonly ["024", "054", "055", "059"];
|
|
332
|
-
};
|
|
333
|
-
readonly vodafone: {
|
|
334
|
-
readonly name: "Vodafone Cash";
|
|
335
|
-
readonly prefix: readonly ["020", "050"];
|
|
336
|
-
};
|
|
337
|
-
readonly airtel: {
|
|
338
|
-
readonly name: "AirtelTigo Money";
|
|
339
|
-
readonly prefix: readonly ["027", "057", "026", "056"];
|
|
340
|
-
};
|
|
341
|
-
};
|
|
342
|
-
/**
|
|
343
|
-
* Detect mobile money provider from phone number
|
|
344
|
-
*/
|
|
345
|
-
declare function detectMobileMoneyProvider(phoneNumber: string): "mtn" | "vodafone" | "airtel" | null;
|
|
346
|
-
|
|
347
|
-
/** Context sent with every request to scope operations to a specific location/branch */
|
|
348
|
-
interface FrontendContext {
|
|
349
|
-
location_id?: string;
|
|
350
|
-
}
|
|
351
|
-
/** Request body for POST /api/q */
|
|
352
|
-
interface QueryRequest {
|
|
353
|
-
query: string;
|
|
354
|
-
variables?: Record<string, unknown>;
|
|
355
|
-
cache_hint?: string;
|
|
356
|
-
context?: FrontendContext;
|
|
357
|
-
}
|
|
358
|
-
/** Request body for POST /api/m */
|
|
359
|
-
interface MutationRequest {
|
|
360
|
-
method: string;
|
|
361
|
-
args: unknown[];
|
|
362
|
-
context?: FrontendContext;
|
|
363
|
-
}
|
|
364
|
-
/** Response metadata */
|
|
365
|
-
interface ResponseMetadata {
|
|
366
|
-
execution_time_ms: number;
|
|
367
|
-
cache_hit: boolean;
|
|
368
|
-
}
|
|
369
|
-
/** Standard API response wrapper */
|
|
370
|
-
interface ApiResponse<T> {
|
|
371
|
-
success: boolean;
|
|
372
|
-
data?: T;
|
|
373
|
-
error?: ApiError;
|
|
374
|
-
metadata?: ResponseMetadata;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
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, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, normalizePaymentResponse, normalizeStatusResponse, parsePrice, query };
|
package/dist/react.d.mts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { eB as AdSlot, eC as AdPosition, eG as AdContextValue, y as CimplifyElements, C as CimplifyClient, J as ElementsOptions, ev as AuthenticatedData, et as AddressInfo, eu as PaymentMethodInfo, ex as ElementsCheckoutResult } from './ads-CXOn6J7P.mjs';
|
|
2
|
-
export { eE as AdConfig } from './ads-CXOn6J7P.mjs';
|
|
3
|
-
import React, { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
interface UserIdentity {
|
|
6
|
-
uid: string;
|
|
7
|
-
isAuthenticated: boolean;
|
|
8
|
-
fingerprint: string;
|
|
9
|
-
signals: DeviceSignals;
|
|
10
|
-
}
|
|
11
|
-
interface DeviceSignals {
|
|
12
|
-
userAgent: string;
|
|
13
|
-
language: string;
|
|
14
|
-
languages: string[];
|
|
15
|
-
platform: string;
|
|
16
|
-
screenWidth: number;
|
|
17
|
-
screenHeight: number;
|
|
18
|
-
colorDepth: number;
|
|
19
|
-
pixelRatio: number;
|
|
20
|
-
timezone: string;
|
|
21
|
-
timezoneOffset: number;
|
|
22
|
-
touchSupport: boolean;
|
|
23
|
-
cookiesEnabled: boolean;
|
|
24
|
-
doNotTrack: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface AdContextValueExtended extends AdContextValue {
|
|
28
|
-
identity: UserIdentity | null;
|
|
29
|
-
apiBase: string;
|
|
30
|
-
}
|
|
31
|
-
declare function useAds(): AdContextValueExtended;
|
|
32
|
-
interface AdProviderProps {
|
|
33
|
-
siteId: string;
|
|
34
|
-
apiBase?: string;
|
|
35
|
-
authenticatedAccountId?: string;
|
|
36
|
-
children: ReactNode;
|
|
37
|
-
}
|
|
38
|
-
declare function AdProvider({ siteId, apiBase, authenticatedAccountId, children, }: AdProviderProps): React.ReactElement;
|
|
39
|
-
interface AdProps {
|
|
40
|
-
slot: AdSlot;
|
|
41
|
-
position?: AdPosition;
|
|
42
|
-
className?: string;
|
|
43
|
-
style?: React.CSSProperties;
|
|
44
|
-
fallback?: ReactNode;
|
|
45
|
-
onImpression?: (adId: string) => void;
|
|
46
|
-
onClick?: (adId: string) => void;
|
|
47
|
-
}
|
|
48
|
-
declare function Ad({ slot, position, className, style, fallback, onImpression, onClick, }: AdProps): React.ReactElement | null;
|
|
49
|
-
|
|
50
|
-
declare function useElements(): CimplifyElements | null;
|
|
51
|
-
declare function useElementsReady(): boolean;
|
|
52
|
-
interface ElementsProviderProps {
|
|
53
|
-
client: CimplifyClient;
|
|
54
|
-
businessId: string;
|
|
55
|
-
options?: ElementsOptions;
|
|
56
|
-
children: ReactNode;
|
|
57
|
-
}
|
|
58
|
-
declare function ElementsProvider({ client, businessId, options, children, }: ElementsProviderProps): React.ReactElement;
|
|
59
|
-
interface BaseElementProps {
|
|
60
|
-
className?: string;
|
|
61
|
-
style?: React.CSSProperties;
|
|
62
|
-
onReady?: () => void;
|
|
63
|
-
onError?: (error: {
|
|
64
|
-
code: string;
|
|
65
|
-
message: string;
|
|
66
|
-
}) => void;
|
|
67
|
-
}
|
|
68
|
-
interface AuthElementProps extends BaseElementProps {
|
|
69
|
-
prefillEmail?: string;
|
|
70
|
-
onAuthenticated?: (data: AuthenticatedData) => void;
|
|
71
|
-
onRequiresOtp?: (data: {
|
|
72
|
-
contactMasked: string;
|
|
73
|
-
}) => void;
|
|
74
|
-
}
|
|
75
|
-
declare function AuthElement({ className, style, prefillEmail, onReady, onAuthenticated, onRequiresOtp, onError, }: AuthElementProps): React.ReactElement | null;
|
|
76
|
-
interface AddressElementProps extends BaseElementProps {
|
|
77
|
-
mode?: "shipping" | "billing";
|
|
78
|
-
onChange?: (data: {
|
|
79
|
-
address: AddressInfo;
|
|
80
|
-
saveToLink: boolean;
|
|
81
|
-
}) => void;
|
|
82
|
-
}
|
|
83
|
-
declare function AddressElement({ className, style, mode, onReady, onChange, onError, }: AddressElementProps): React.ReactElement | null;
|
|
84
|
-
interface PaymentElementProps extends BaseElementProps {
|
|
85
|
-
amount?: number;
|
|
86
|
-
currency?: string;
|
|
87
|
-
onChange?: (data: {
|
|
88
|
-
paymentMethod: PaymentMethodInfo;
|
|
89
|
-
saveToLink: boolean;
|
|
90
|
-
}) => void;
|
|
91
|
-
}
|
|
92
|
-
declare function PaymentElement({ className, style, amount, currency, onReady, onChange, onError, }: PaymentElementProps): React.ReactElement | null;
|
|
93
|
-
declare function useCheckout(): {
|
|
94
|
-
submit: (data: {
|
|
95
|
-
cart_id: string;
|
|
96
|
-
order_type?: "delivery" | "pickup" | "dine_in";
|
|
97
|
-
location_id?: string;
|
|
98
|
-
scheduled_time?: string;
|
|
99
|
-
tip_amount?: number;
|
|
100
|
-
notes?: string;
|
|
101
|
-
}) => Promise<ElementsCheckoutResult>;
|
|
102
|
-
isLoading: boolean;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { Ad, AdPosition, type AdProps, AdProvider, AdSlot, AddressElement, AuthElement, ElementsProvider, PaymentElement, useAds, useCheckout, useElements, useElementsReady };
|
package/dist/react.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { eB as AdSlot, eC as AdPosition, eG as AdContextValue, y as CimplifyElements, C as CimplifyClient, J as ElementsOptions, ev as AuthenticatedData, et as AddressInfo, eu as PaymentMethodInfo, ex as ElementsCheckoutResult } from './ads-CXOn6J7P.js';
|
|
2
|
-
export { eE as AdConfig } from './ads-CXOn6J7P.js';
|
|
3
|
-
import React, { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
interface UserIdentity {
|
|
6
|
-
uid: string;
|
|
7
|
-
isAuthenticated: boolean;
|
|
8
|
-
fingerprint: string;
|
|
9
|
-
signals: DeviceSignals;
|
|
10
|
-
}
|
|
11
|
-
interface DeviceSignals {
|
|
12
|
-
userAgent: string;
|
|
13
|
-
language: string;
|
|
14
|
-
languages: string[];
|
|
15
|
-
platform: string;
|
|
16
|
-
screenWidth: number;
|
|
17
|
-
screenHeight: number;
|
|
18
|
-
colorDepth: number;
|
|
19
|
-
pixelRatio: number;
|
|
20
|
-
timezone: string;
|
|
21
|
-
timezoneOffset: number;
|
|
22
|
-
touchSupport: boolean;
|
|
23
|
-
cookiesEnabled: boolean;
|
|
24
|
-
doNotTrack: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface AdContextValueExtended extends AdContextValue {
|
|
28
|
-
identity: UserIdentity | null;
|
|
29
|
-
apiBase: string;
|
|
30
|
-
}
|
|
31
|
-
declare function useAds(): AdContextValueExtended;
|
|
32
|
-
interface AdProviderProps {
|
|
33
|
-
siteId: string;
|
|
34
|
-
apiBase?: string;
|
|
35
|
-
authenticatedAccountId?: string;
|
|
36
|
-
children: ReactNode;
|
|
37
|
-
}
|
|
38
|
-
declare function AdProvider({ siteId, apiBase, authenticatedAccountId, children, }: AdProviderProps): React.ReactElement;
|
|
39
|
-
interface AdProps {
|
|
40
|
-
slot: AdSlot;
|
|
41
|
-
position?: AdPosition;
|
|
42
|
-
className?: string;
|
|
43
|
-
style?: React.CSSProperties;
|
|
44
|
-
fallback?: ReactNode;
|
|
45
|
-
onImpression?: (adId: string) => void;
|
|
46
|
-
onClick?: (adId: string) => void;
|
|
47
|
-
}
|
|
48
|
-
declare function Ad({ slot, position, className, style, fallback, onImpression, onClick, }: AdProps): React.ReactElement | null;
|
|
49
|
-
|
|
50
|
-
declare function useElements(): CimplifyElements | null;
|
|
51
|
-
declare function useElementsReady(): boolean;
|
|
52
|
-
interface ElementsProviderProps {
|
|
53
|
-
client: CimplifyClient;
|
|
54
|
-
businessId: string;
|
|
55
|
-
options?: ElementsOptions;
|
|
56
|
-
children: ReactNode;
|
|
57
|
-
}
|
|
58
|
-
declare function ElementsProvider({ client, businessId, options, children, }: ElementsProviderProps): React.ReactElement;
|
|
59
|
-
interface BaseElementProps {
|
|
60
|
-
className?: string;
|
|
61
|
-
style?: React.CSSProperties;
|
|
62
|
-
onReady?: () => void;
|
|
63
|
-
onError?: (error: {
|
|
64
|
-
code: string;
|
|
65
|
-
message: string;
|
|
66
|
-
}) => void;
|
|
67
|
-
}
|
|
68
|
-
interface AuthElementProps extends BaseElementProps {
|
|
69
|
-
prefillEmail?: string;
|
|
70
|
-
onAuthenticated?: (data: AuthenticatedData) => void;
|
|
71
|
-
onRequiresOtp?: (data: {
|
|
72
|
-
contactMasked: string;
|
|
73
|
-
}) => void;
|
|
74
|
-
}
|
|
75
|
-
declare function AuthElement({ className, style, prefillEmail, onReady, onAuthenticated, onRequiresOtp, onError, }: AuthElementProps): React.ReactElement | null;
|
|
76
|
-
interface AddressElementProps extends BaseElementProps {
|
|
77
|
-
mode?: "shipping" | "billing";
|
|
78
|
-
onChange?: (data: {
|
|
79
|
-
address: AddressInfo;
|
|
80
|
-
saveToLink: boolean;
|
|
81
|
-
}) => void;
|
|
82
|
-
}
|
|
83
|
-
declare function AddressElement({ className, style, mode, onReady, onChange, onError, }: AddressElementProps): React.ReactElement | null;
|
|
84
|
-
interface PaymentElementProps extends BaseElementProps {
|
|
85
|
-
amount?: number;
|
|
86
|
-
currency?: string;
|
|
87
|
-
onChange?: (data: {
|
|
88
|
-
paymentMethod: PaymentMethodInfo;
|
|
89
|
-
saveToLink: boolean;
|
|
90
|
-
}) => void;
|
|
91
|
-
}
|
|
92
|
-
declare function PaymentElement({ className, style, amount, currency, onReady, onChange, onError, }: PaymentElementProps): React.ReactElement | null;
|
|
93
|
-
declare function useCheckout(): {
|
|
94
|
-
submit: (data: {
|
|
95
|
-
cart_id: string;
|
|
96
|
-
order_type?: "delivery" | "pickup" | "dine_in";
|
|
97
|
-
location_id?: string;
|
|
98
|
-
scheduled_time?: string;
|
|
99
|
-
tip_amount?: number;
|
|
100
|
-
notes?: string;
|
|
101
|
-
}) => Promise<ElementsCheckoutResult>;
|
|
102
|
-
isLoading: boolean;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { Ad, AdPosition, type AdProps, AdProvider, AdSlot, AddressElement, AuthElement, ElementsProvider, PaymentElement, useAds, useCheckout, useElements, useElementsReady };
|