@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.
Files changed (70) hide show
  1. package/dist/{ads-MkGm5l1T.d.mts → ads-BxbWrwqp.d.mts} +0 -8
  2. package/dist/{ads-MkGm5l1T.d.ts → ads-BxbWrwqp.d.ts} +0 -8
  3. package/dist/advanced.d.mts +2 -2
  4. package/dist/advanced.d.ts +2 -2
  5. package/dist/advanced.js +93 -80
  6. package/dist/advanced.mjs +93 -80
  7. package/dist/cli.js +184 -0
  8. package/dist/{client-BQ1gIg8t.d.mts → client-BSrq89H1.d.mts} +42 -374
  9. package/dist/{client-C3TQtGuy.d.ts → client-xBhdHLq4.d.ts} +42 -374
  10. package/dist/index.d.mts +6 -10
  11. package/dist/index.d.ts +6 -10
  12. package/dist/index.js +98 -126
  13. package/dist/index.mjs +98 -126
  14. package/dist/{payment-CTalZM5l.d.mts → payment-CrNyrc-D.d.mts} +145 -95
  15. package/dist/{payment-CTalZM5l.d.ts → payment-CrNyrc-D.d.ts} +145 -95
  16. package/dist/price-C9Z-hr49.d.mts +21 -0
  17. package/dist/price-RKKoTz-9.d.ts +21 -0
  18. package/dist/react.d.mts +1285 -35
  19. package/dist/react.d.ts +1285 -35
  20. package/dist/react.js +6596 -2598
  21. package/dist/react.mjs +6550 -2600
  22. package/dist/utils.d.mts +55 -2
  23. package/dist/utils.d.ts +55 -2
  24. package/dist/utils.js +23 -20
  25. package/dist/utils.mjs +23 -20
  26. package/package.json +13 -3
  27. package/registry/add-on-selector.json +15 -0
  28. package/registry/availability-badge.json +15 -0
  29. package/registry/booking-card.json +16 -0
  30. package/registry/booking-list.json +16 -0
  31. package/registry/booking-page.json +18 -0
  32. package/registry/bookings-page.json +17 -0
  33. package/registry/bundle-selector.json +15 -0
  34. package/registry/cart-page.json +17 -0
  35. package/registry/cart-summary.json +16 -0
  36. package/registry/catalogue-page.json +18 -0
  37. package/registry/category-filter.json +15 -0
  38. package/registry/category-grid.json +15 -0
  39. package/registry/checkout-page.json +15 -0
  40. package/registry/cn.json +13 -0
  41. package/registry/collection-page.json +16 -0
  42. package/registry/composite-selector.json +15 -0
  43. package/registry/date-slot-picker.json +16 -0
  44. package/registry/deal-banner.json +16 -0
  45. package/registry/deals-page.json +19 -0
  46. package/registry/discount-input.json +16 -0
  47. package/registry/index.json +411 -0
  48. package/registry/order-detail-page.json +16 -0
  49. package/registry/order-history-page.json +17 -0
  50. package/registry/order-history.json +16 -0
  51. package/registry/order-summary.json +16 -0
  52. package/registry/price.json +13 -0
  53. package/registry/product-card.json +17 -0
  54. package/registry/product-customizer.json +20 -0
  55. package/registry/product-grid.json +16 -0
  56. package/registry/product-image-gallery.json +13 -0
  57. package/registry/product-page.json +19 -0
  58. package/registry/product-sheet.json +18 -0
  59. package/registry/quantity-selector.json +13 -0
  60. package/registry/sale-badge.json +16 -0
  61. package/registry/search-input.json +15 -0
  62. package/registry/search-page.json +16 -0
  63. package/registry/service-card.json +16 -0
  64. package/registry/service-grid.json +16 -0
  65. package/registry/slot-picker.json +16 -0
  66. package/registry/staff-picker.json +15 -0
  67. package/registry/store-nav.json +15 -0
  68. package/registry/variant-selector.json +15 -0
  69. package/dist/index-B_25cFc1.d.ts +0 -320
  70. 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 };