@cimplify/sdk 0.9.10 → 0.10.0
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/{ads-MkGm5l1T.d.mts → ads-BxbWrwqp.d.mts} +0 -8
- package/dist/{ads-MkGm5l1T.d.ts → ads-BxbWrwqp.d.ts} +0 -8
- package/dist/advanced.d.mts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +93 -80
- package/dist/advanced.mjs +93 -80
- package/dist/cli.js +184 -0
- package/dist/{client-BQ1gIg8t.d.mts → client-BSrq89H1.d.mts} +42 -374
- package/dist/{client-C3TQtGuy.d.ts → client-xBhdHLq4.d.ts} +42 -374
- package/dist/index.d.mts +6 -10
- package/dist/index.d.ts +6 -10
- package/dist/index.js +98 -126
- package/dist/index.mjs +98 -126
- package/dist/{payment-CTalZM5l.d.mts → payment-CrNyrc-D.d.mts} +145 -95
- package/dist/{payment-CTalZM5l.d.ts → payment-CrNyrc-D.d.ts} +145 -95
- package/dist/price-C9Z-hr49.d.mts +21 -0
- package/dist/price-RKKoTz-9.d.ts +21 -0
- package/dist/react.d.mts +1285 -35
- package/dist/react.d.ts +1285 -35
- package/dist/react.js +6596 -2598
- package/dist/react.mjs +6550 -2600
- package/dist/utils.d.mts +55 -2
- package/dist/utils.d.ts +55 -2
- package/dist/utils.js +23 -20
- package/dist/utils.mjs +23 -20
- package/package.json +13 -3
- package/registry/add-on-selector.json +15 -0
- package/registry/availability-badge.json +15 -0
- package/registry/booking-card.json +16 -0
- package/registry/booking-list.json +16 -0
- package/registry/booking-page.json +18 -0
- package/registry/bookings-page.json +17 -0
- package/registry/bundle-selector.json +15 -0
- package/registry/cart-page.json +17 -0
- package/registry/cart-summary.json +16 -0
- package/registry/catalogue-page.json +18 -0
- package/registry/category-filter.json +15 -0
- package/registry/category-grid.json +15 -0
- package/registry/checkout-page.json +15 -0
- package/registry/cn.json +13 -0
- package/registry/collection-page.json +16 -0
- package/registry/composite-selector.json +15 -0
- package/registry/date-slot-picker.json +16 -0
- package/registry/deal-banner.json +16 -0
- package/registry/deals-page.json +19 -0
- package/registry/discount-input.json +16 -0
- package/registry/index.json +411 -0
- package/registry/order-detail-page.json +16 -0
- package/registry/order-history-page.json +17 -0
- package/registry/order-history.json +16 -0
- package/registry/order-summary.json +16 -0
- package/registry/price.json +13 -0
- package/registry/product-card.json +17 -0
- package/registry/product-customizer.json +20 -0
- package/registry/product-grid.json +16 -0
- package/registry/product-image-gallery.json +13 -0
- package/registry/product-page.json +19 -0
- package/registry/product-sheet.json +18 -0
- package/registry/quantity-selector.json +13 -0
- package/registry/sale-badge.json +16 -0
- package/registry/search-input.json +15 -0
- package/registry/search-page.json +16 -0
- package/registry/service-card.json +16 -0
- package/registry/service-grid.json +16 -0
- package/registry/slot-picker.json +16 -0
- package/registry/staff-picker.json +15 -0
- package/registry/store-nav.json +15 -0
- package/registry/variant-selector.json +15 -0
- package/dist/index-B_25cFc1.d.ts +0 -320
- package/dist/index-Cd0shhZU.d.mts +0 -320
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { av as ChosenPrice, C as CurrencyCode, as as TaxPathComponent, at as PricePathTaxInfo, M as Money, bd as PaymentErrorDetails, bb as PaymentResponse, bc as PaymentStatusResponse } from './payment-CTalZM5l.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Price Types
|
|
5
|
-
*
|
|
6
|
-
* Types for price parsing, formatting, and display utilities.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Individual tax component (e.g., VAT, NHIL, GETFund)
|
|
11
|
-
* @deprecated Use `TaxPathComponent` from `types/cart` instead.
|
|
12
|
-
*/
|
|
13
|
-
type TaxComponent = TaxPathComponent;
|
|
14
|
-
/**
|
|
15
|
-
* Complete tax information from a pricing response
|
|
16
|
-
* @deprecated Use `PricePathTaxInfo` from `types/cart` instead.
|
|
17
|
-
*/
|
|
18
|
-
type TaxInfo = PricePathTaxInfo;
|
|
19
|
-
/**
|
|
20
|
-
* Price information in snake_case format (as returned from backend)
|
|
21
|
-
* Used by components that work with raw API responses
|
|
22
|
-
* @deprecated Use `ChosenPrice` from `types/cart` instead.
|
|
23
|
-
*/
|
|
24
|
-
type PriceInfo = ChosenPrice;
|
|
25
|
-
/**
|
|
26
|
-
* Minimal product shape for price utilities.
|
|
27
|
-
* Uses quote-aware `price_info` and plain numeric fallback fields.
|
|
28
|
-
*/
|
|
29
|
-
interface ProductWithPrice {
|
|
30
|
-
/** Pre-parsed price info from backend */
|
|
31
|
-
price_info?: ChosenPrice;
|
|
32
|
-
/** Final computed price in plain field form (if provided by API) */
|
|
33
|
-
final_price?: number | string | null;
|
|
34
|
-
/** Base/original price in plain field form */
|
|
35
|
-
base_price?: number | string | null;
|
|
36
|
-
/** Default/indicative price in plain field form */
|
|
37
|
-
default_price?: number | string | null;
|
|
38
|
-
/** Currency in plain field form */
|
|
39
|
-
currency?: CurrencyCode | null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Options for price formatting functions
|
|
43
|
-
*/
|
|
44
|
-
interface FormatPriceOptions {
|
|
45
|
-
/** Currency code (default: "GHS") */
|
|
46
|
-
currency?: CurrencyCode;
|
|
47
|
-
/** Locale for Intl.NumberFormat (default: "en-US") */
|
|
48
|
-
locale?: string;
|
|
49
|
-
/** Minimum fraction digits (default: 2) */
|
|
50
|
-
minimumFractionDigits?: number;
|
|
51
|
-
/** Maximum fraction digits (default: 2) */
|
|
52
|
-
maximumFractionDigits?: number;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Options for compact price formatting
|
|
56
|
-
*/
|
|
57
|
-
interface FormatCompactOptions {
|
|
58
|
-
/** Currency code (default: "GHS") */
|
|
59
|
-
currency?: CurrencyCode;
|
|
60
|
-
/** Number of decimal places for compact notation (default: 1) */
|
|
61
|
-
decimals?: number;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Price Utilities
|
|
66
|
-
*
|
|
67
|
-
* Comprehensive utilities for parsing, formatting, and displaying prices.
|
|
68
|
-
* Handles quote-aware pricing fields, currency formatting, and product price helpers.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* import {
|
|
73
|
-
* formatPrice,
|
|
74
|
-
* formatPriceCompact,
|
|
75
|
-
* isOnSale,
|
|
76
|
-
* getDiscountPercentage
|
|
77
|
-
* } from '@cimplify/sdk';
|
|
78
|
-
*
|
|
79
|
-
* // Format prices
|
|
80
|
-
* formatPrice(29.99, 'USD'); // "$29.99"
|
|
81
|
-
* formatPrice(29.99, 'GHS'); // "GH₵29.99"
|
|
82
|
-
* formatPriceCompact(1500000, 'USD'); // "$1.5M"
|
|
83
|
-
*
|
|
84
|
-
* // Check for discounts
|
|
85
|
-
* if (isOnSale(product)) {
|
|
86
|
-
* console.log(`${getDiscountPercentage(product)}% off!`);
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Currency code to symbol mapping
|
|
93
|
-
* Includes major world currencies and African currencies
|
|
94
|
-
*/
|
|
95
|
-
declare const CURRENCY_SYMBOLS: Record<string, string>;
|
|
96
|
-
/**
|
|
97
|
-
* Get currency symbol for a currency code
|
|
98
|
-
* @param currencyCode - ISO 4217 currency code (e.g., "USD", "GHS")
|
|
99
|
-
* @returns Currency symbol or the code itself if not found
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* getCurrencySymbol('USD') // "$"
|
|
103
|
-
* getCurrencySymbol('GHS') // "GH₵"
|
|
104
|
-
* getCurrencySymbol('XYZ') // "XYZ"
|
|
105
|
-
*/
|
|
106
|
-
declare function getCurrencySymbol(currencyCode: CurrencyCode): string;
|
|
107
|
-
/**
|
|
108
|
-
* Format a number compactly with K/M/B suffixes
|
|
109
|
-
* @param value - Number to format
|
|
110
|
-
* @param decimals - Decimal places (default: 1)
|
|
111
|
-
* @returns Compact string representation
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* formatNumberCompact(1234) // "1.2K"
|
|
115
|
-
* formatNumberCompact(1500000) // "1.5M"
|
|
116
|
-
* formatNumberCompact(2500000000) // "2.5B"
|
|
117
|
-
*/
|
|
118
|
-
declare function formatNumberCompact(value: number, decimals?: number): string;
|
|
119
|
-
/**
|
|
120
|
-
* Format a price with locale-aware currency formatting
|
|
121
|
-
* Uses Intl.NumberFormat for proper localization
|
|
122
|
-
*
|
|
123
|
-
* @param amount - Price amount (number or string)
|
|
124
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
125
|
-
* @param locale - BCP 47 locale string (default: "en-US")
|
|
126
|
-
* @returns Formatted price string
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* formatPrice(29.99, 'USD') // "$29.99"
|
|
130
|
-
* formatPrice(29.99, 'GHS') // "GH₵29.99"
|
|
131
|
-
* formatPrice('29.99', 'EUR') // "€29.99"
|
|
132
|
-
* formatPrice(1234.56, 'USD', 'de-DE') // "1.234,56 $"
|
|
133
|
-
*/
|
|
134
|
-
declare function formatPrice(amount: number | Money, currency?: CurrencyCode, locale?: string): string;
|
|
135
|
-
/**
|
|
136
|
-
* Format a price with +/- sign for adjustments
|
|
137
|
-
* Useful for showing price changes, modifiers, or discounts
|
|
138
|
-
*
|
|
139
|
-
* @param amount - Adjustment amount (positive or negative)
|
|
140
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
141
|
-
* @param locale - BCP 47 locale string (default: "en-US")
|
|
142
|
-
* @returns Formatted adjustment string with sign
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* formatPriceAdjustment(5.00, 'USD') // "+$5.00"
|
|
146
|
-
* formatPriceAdjustment(-3.50, 'GHS') // "-GH₵3.50"
|
|
147
|
-
* formatPriceAdjustment(0, 'EUR') // "€0.00"
|
|
148
|
-
*/
|
|
149
|
-
declare function formatPriceAdjustment(amount: number, currency?: CurrencyCode, locale?: string): string;
|
|
150
|
-
/**
|
|
151
|
-
* Format a price compactly for large numbers
|
|
152
|
-
* Uses K/M/B suffixes for thousands, millions, billions
|
|
153
|
-
*
|
|
154
|
-
* @param amount - Price amount (number or string)
|
|
155
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
156
|
-
* @param decimals - Decimal places for compact notation (default: 1)
|
|
157
|
-
* @returns Compact formatted price
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* formatPriceCompact(999, 'USD') // "$999.00"
|
|
161
|
-
* formatPriceCompact(1500, 'GHS') // "GH₵1.5K"
|
|
162
|
-
* formatPriceCompact(2500000, 'USD') // "$2.5M"
|
|
163
|
-
* formatPriceCompact(1200000000, 'EUR') // "€1.2B"
|
|
164
|
-
*/
|
|
165
|
-
declare function formatPriceCompact(amount: number | Money, currency?: CurrencyCode, decimals?: number): string;
|
|
166
|
-
/**
|
|
167
|
-
* Simple currency symbol + amount format
|
|
168
|
-
* Lighter alternative to formatPrice without Intl
|
|
169
|
-
*
|
|
170
|
-
* @param amount - Price amount (number or string)
|
|
171
|
-
* @param currency - ISO 4217 currency code (default: "GHS")
|
|
172
|
-
* @returns Simple formatted price
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* formatMoney(29.99, 'USD') // "$29.99"
|
|
176
|
-
* formatMoney('15.00', 'GHS') // "GH₵15.00"
|
|
177
|
-
*/
|
|
178
|
-
declare function formatMoney(amount: Money | number, currency?: CurrencyCode): string;
|
|
179
|
-
/**
|
|
180
|
-
* Parse a price string or number to a numeric value
|
|
181
|
-
* Handles various input formats gracefully
|
|
182
|
-
*
|
|
183
|
-
* @param value - Value to parse (string, number, or undefined)
|
|
184
|
-
* @returns Parsed numeric value, or 0 if invalid
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* parsePrice('29.99') // 29.99
|
|
188
|
-
* parsePrice(29.99) // 29.99
|
|
189
|
-
* parsePrice('$29.99') // 29.99 (strips non-numeric prefix)
|
|
190
|
-
* parsePrice(undefined) // 0
|
|
191
|
-
* parsePrice('invalid') // 0
|
|
192
|
-
*/
|
|
193
|
-
declare function parsePrice(value: Money | string | number | undefined | null): number;
|
|
194
|
-
/** Check whether tax info exists on the selected price payload. */
|
|
195
|
-
declare function hasTaxInfo(priceInfo: {
|
|
196
|
-
tax_info?: PricePathTaxInfo;
|
|
197
|
-
}): boolean;
|
|
198
|
-
/** Get tax amount from a selected price payload, defaulting to 0 when tax info is absent. */
|
|
199
|
-
declare function getTaxAmount(priceInfo: {
|
|
200
|
-
tax_info?: PricePathTaxInfo;
|
|
201
|
-
}): number;
|
|
202
|
-
/** Check whether the selected price is tax-inclusive. */
|
|
203
|
-
declare function isTaxInclusive(priceInfo: {
|
|
204
|
-
tax_info?: PricePathTaxInfo;
|
|
205
|
-
}): boolean;
|
|
206
|
-
/**
|
|
207
|
-
* Format a final price with tax annotation.
|
|
208
|
-
* Examples: "$10.50 (incl. tax)" or "$10.50 + $1.05 tax"
|
|
209
|
-
*/
|
|
210
|
-
declare function formatPriceWithTax(priceInfo: {
|
|
211
|
-
final_price: Money;
|
|
212
|
-
tax_info?: PricePathTaxInfo;
|
|
213
|
-
}, currency?: CurrencyCode): string;
|
|
214
|
-
/**
|
|
215
|
-
* Get the display price from a product.
|
|
216
|
-
* Prefers quote-aware price_info, then plain price fields.
|
|
217
|
-
*
|
|
218
|
-
* @param product - Product with price data
|
|
219
|
-
* @returns The final price to display
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* const price = getDisplayPrice(product);
|
|
223
|
-
* console.log(formatPrice(price, 'GHS')); // "GH₵29.99"
|
|
224
|
-
*/
|
|
225
|
-
declare function getDisplayPrice(product: ProductWithPrice): number;
|
|
226
|
-
/**
|
|
227
|
-
* Get the base price from a product (before markup/discount)
|
|
228
|
-
*
|
|
229
|
-
* @param product - Product with price data
|
|
230
|
-
* @returns The base price before adjustments
|
|
231
|
-
*/
|
|
232
|
-
declare function getBasePrice(product: ProductWithPrice): number;
|
|
233
|
-
/**
|
|
234
|
-
* Check if a product is on sale (discounted)
|
|
235
|
-
*
|
|
236
|
-
* @param product - Product with price data
|
|
237
|
-
* @returns True if the final price is less than the base price
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* if (isOnSale(product)) {
|
|
241
|
-
* return <Badge>Sale!</Badge>;
|
|
242
|
-
* }
|
|
243
|
-
*/
|
|
244
|
-
declare function isOnSale(product: ProductWithPrice): boolean;
|
|
245
|
-
/**
|
|
246
|
-
* Get the discount percentage for a product on sale
|
|
247
|
-
*
|
|
248
|
-
* @param product - Product with price data
|
|
249
|
-
* @returns Discount percentage (0-100), or 0 if not on sale
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* const discount = getDiscountPercentage(product);
|
|
253
|
-
* if (discount > 0) {
|
|
254
|
-
* return <Badge>{discount}% OFF</Badge>;
|
|
255
|
-
* }
|
|
256
|
-
*/
|
|
257
|
-
declare function getDiscountPercentage(product: ProductWithPrice): number;
|
|
258
|
-
/**
|
|
259
|
-
* Get the markup percentage for a product
|
|
260
|
-
*
|
|
261
|
-
* @param product - Product with price data
|
|
262
|
-
* @returns Markup percentage, or 0 if no markup
|
|
263
|
-
*/
|
|
264
|
-
declare function getMarkupPercentage(product: ProductWithPrice): number;
|
|
265
|
-
/**
|
|
266
|
-
* Get the currency for a product
|
|
267
|
-
*
|
|
268
|
-
* @param product - Product with price data
|
|
269
|
-
* @returns Currency code (default: "GHS")
|
|
270
|
-
*/
|
|
271
|
-
declare function getProductCurrency(product: ProductWithPrice): CurrencyCode;
|
|
272
|
-
/**
|
|
273
|
-
* Format a product's display price
|
|
274
|
-
* Convenience function combining getDisplayPrice and formatPrice
|
|
275
|
-
*
|
|
276
|
-
* @param product - Product with price data
|
|
277
|
-
* @param locale - BCP 47 locale string (default: "en-US")
|
|
278
|
-
* @returns Formatted price string
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* <span>{formatProductPrice(product)}</span> // "GH₵29.99"
|
|
282
|
-
*/
|
|
283
|
-
declare function formatProductPrice(product: ProductWithPrice, locale?: string): string;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Categorize payment errors into user-friendly messages
|
|
287
|
-
*/
|
|
288
|
-
declare function categorizePaymentError(error: Error, errorCode?: string): PaymentErrorDetails;
|
|
289
|
-
/**
|
|
290
|
-
* Normalize payment response from different formats into a standard PaymentResponse
|
|
291
|
-
*/
|
|
292
|
-
declare function normalizePaymentResponse(response: unknown): PaymentResponse;
|
|
293
|
-
declare function isPaymentStatusSuccess(status: string | undefined): boolean;
|
|
294
|
-
declare function isPaymentStatusFailure(status: string | undefined): boolean;
|
|
295
|
-
declare function isPaymentStatusRequiresAction(status: string | undefined): boolean;
|
|
296
|
-
/**
|
|
297
|
-
* Normalize payment status response into a standard format
|
|
298
|
-
*/
|
|
299
|
-
declare function normalizeStatusResponse(response: unknown): PaymentStatusResponse;
|
|
300
|
-
/** Mobile money provider display names */
|
|
301
|
-
declare const MOBILE_MONEY_PROVIDERS: {
|
|
302
|
-
readonly mtn: {
|
|
303
|
-
readonly name: "MTN Mobile Money";
|
|
304
|
-
readonly prefix: readonly ["024", "054", "055", "059"];
|
|
305
|
-
};
|
|
306
|
-
readonly vodafone: {
|
|
307
|
-
readonly name: "Vodafone Cash";
|
|
308
|
-
readonly prefix: readonly ["020", "050"];
|
|
309
|
-
};
|
|
310
|
-
readonly airtel: {
|
|
311
|
-
readonly name: "AirtelTigo Money";
|
|
312
|
-
readonly prefix: readonly ["027", "057", "026", "056"];
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* Detect mobile money provider from phone number
|
|
317
|
-
*/
|
|
318
|
-
declare function detectMobileMoneyProvider(phoneNumber: string): "mtn" | "vodafone" | "airtel" | null;
|
|
319
|
-
|
|
320
|
-
export { type ProductWithPrice as A, type FormatCompactOptions as B, CURRENCY_SYMBOLS as C, type FormatPriceOptions as F, MOBILE_MONEY_PROVIDERS as M, type PriceInfo as P, type TaxComponent as T, formatPriceAdjustment as a, formatPriceCompact as b, formatMoney as c, formatNumberCompact as d, formatProductPrice as e, formatPrice as f, getTaxAmount as g, hasTaxInfo as h, isTaxInclusive as i, formatPriceWithTax as j, getCurrencySymbol as k, getDisplayPrice as l, getBasePrice as m, isOnSale as n, getDiscountPercentage as o, parsePrice as p, getMarkupPercentage as q, getProductCurrency as r, categorizePaymentError as s, normalizePaymentResponse as t, normalizeStatusResponse as u, isPaymentStatusFailure as v, isPaymentStatusRequiresAction as w, isPaymentStatusSuccess as x, detectMobileMoneyProvider as y, type TaxInfo as z };
|