b23-lib 2.0.0 → 2.0.2

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 (150) hide show
  1. package/dist/Auth/index.js +1 -1
  2. package/dist/Auth/index.js.map +1 -1
  3. package/dist/Auth/index.mjs +1 -1
  4. package/dist/Auth/index.mjs.map +1 -1
  5. package/dist/Classes/Address.d.mts +1 -1
  6. package/dist/Classes/Address.d.ts +1 -1
  7. package/dist/Classes/Address.js.map +1 -1
  8. package/dist/Classes/Address.mjs +1 -1
  9. package/dist/Classes/Base.d.mts +5 -5
  10. package/dist/Classes/Base.d.ts +5 -5
  11. package/dist/Classes/Base.js.map +1 -1
  12. package/dist/Classes/Base.mjs +1 -1
  13. package/dist/Classes/Cart.d.mts +27 -12
  14. package/dist/Classes/Cart.d.ts +27 -12
  15. package/dist/Classes/Cart.js +1 -1
  16. package/dist/Classes/Cart.js.map +1 -1
  17. package/dist/Classes/Cart.mjs +1 -1
  18. package/dist/Classes/Cart.mjs.map +1 -1
  19. package/dist/Classes/Common.d.mts +2 -93
  20. package/dist/Classes/Common.d.ts +2 -93
  21. package/dist/Classes/Coupon.d.mts +33 -15
  22. package/dist/Classes/Coupon.d.ts +33 -15
  23. package/dist/Classes/Coupon.js +1 -1
  24. package/dist/Classes/Coupon.js.map +1 -1
  25. package/dist/Classes/Coupon.mjs +1 -1
  26. package/dist/Classes/Customer.d.mts +2 -2
  27. package/dist/Classes/Customer.d.ts +2 -2
  28. package/dist/Classes/Customer.js.map +1 -1
  29. package/dist/Classes/Customer.mjs +1 -1
  30. package/dist/Classes/Customer.mjs.map +1 -1
  31. package/dist/Classes/CustomerAddress.d.mts +1 -1
  32. package/dist/Classes/CustomerAddress.d.ts +1 -1
  33. package/dist/Classes/CustomerAddress.js.map +1 -1
  34. package/dist/Classes/CustomerAddress.mjs +1 -1
  35. package/dist/Classes/Enum.d.mts +43 -2
  36. package/dist/Classes/Enum.d.ts +43 -2
  37. package/dist/Classes/Enum.js +1 -1
  38. package/dist/Classes/Enum.js.map +1 -1
  39. package/dist/Classes/Enum.mjs +1 -1
  40. package/dist/Classes/Error.d.mts +59 -0
  41. package/dist/Classes/Error.d.ts +59 -0
  42. package/dist/Classes/Error.js +2 -0
  43. package/dist/Classes/Error.js.map +1 -0
  44. package/dist/Classes/Error.mjs +2 -0
  45. package/dist/Classes/Error.mjs.map +1 -0
  46. package/dist/Classes/ImageInfo.js +1 -1
  47. package/dist/Classes/ImageInfo.js.map +1 -1
  48. package/dist/Classes/ImageInfo.mjs +1 -1
  49. package/dist/Classes/Inventory.d.mts +25 -6
  50. package/dist/Classes/Inventory.d.ts +25 -6
  51. package/dist/Classes/Inventory.js +1 -1
  52. package/dist/Classes/Inventory.js.map +1 -1
  53. package/dist/Classes/Inventory.mjs +1 -1
  54. package/dist/Classes/Inventory.mjs.map +1 -1
  55. package/dist/Classes/LineItem.d.mts +140 -58
  56. package/dist/Classes/LineItem.d.ts +140 -58
  57. package/dist/Classes/LineItem.js +1 -1
  58. package/dist/Classes/LineItem.js.map +1 -1
  59. package/dist/Classes/LineItem.mjs +1 -1
  60. package/dist/Classes/Order.d.mts +7 -51
  61. package/dist/Classes/Order.d.ts +7 -51
  62. package/dist/Classes/Order.js +1 -1
  63. package/dist/Classes/Order.js.map +1 -1
  64. package/dist/Classes/Order.mjs +1 -1
  65. package/dist/Classes/Order.mjs.map +1 -1
  66. package/dist/Classes/Payment.d.mts +4 -4
  67. package/dist/Classes/Payment.d.ts +4 -4
  68. package/dist/Classes/Payment.js.map +1 -1
  69. package/dist/Classes/Payment.mjs +1 -1
  70. package/dist/Classes/Payment.mjs.map +1 -1
  71. package/dist/Classes/Price.d.mts +1 -82
  72. package/dist/Classes/Price.d.ts +1 -82
  73. package/dist/Classes/Price.js +1 -1
  74. package/dist/Classes/Price.js.map +1 -1
  75. package/dist/Classes/Price.mjs +1 -1
  76. package/dist/Classes/Product.d.mts +101 -87
  77. package/dist/Classes/Product.d.ts +101 -87
  78. package/dist/Classes/Product.js +1 -1
  79. package/dist/Classes/Product.js.map +1 -1
  80. package/dist/Classes/Product.mjs +1 -1
  81. package/dist/Classes/Product.mjs.map +1 -1
  82. package/dist/Classes/ShoppingContainer.d.mts +79 -63
  83. package/dist/Classes/ShoppingContainer.d.ts +79 -63
  84. package/dist/Classes/ShoppingContainer.js +1 -1
  85. package/dist/Classes/ShoppingContainer.js.map +1 -1
  86. package/dist/Classes/ShoppingContainer.mjs +1 -1
  87. package/dist/Classes/TaxRule.d.mts +63 -0
  88. package/dist/Classes/TaxRule.d.ts +63 -0
  89. package/dist/Classes/TaxRule.js +2 -0
  90. package/dist/Classes/TaxRule.js.map +1 -0
  91. package/dist/Classes/TaxRule.mjs +2 -0
  92. package/dist/Classes/TaxRule.mjs.map +1 -0
  93. package/dist/Classes/TieredPrice.d.mts +75 -0
  94. package/dist/Classes/TieredPrice.d.ts +75 -0
  95. package/dist/Classes/TieredPrice.js +2 -0
  96. package/dist/Classes/TieredPrice.js.map +1 -0
  97. package/dist/Classes/TieredPrice.mjs +2 -0
  98. package/dist/Classes/TieredPrice.mjs.map +1 -0
  99. package/dist/Common-D-UoxwM0.d.ts +210 -0
  100. package/dist/Common-FbQ5-3QN.d.mts +210 -0
  101. package/dist/chunk-54RUAXYE.mjs +2 -0
  102. package/dist/chunk-54RUAXYE.mjs.map +1 -0
  103. package/dist/{chunk-ATUUYYQT.mjs → chunk-55SOBG62.mjs} +2 -2
  104. package/dist/chunk-55SOBG62.mjs.map +1 -0
  105. package/dist/{chunk-H5GPM4LA.mjs → chunk-5KD2EW7O.mjs} +2 -2
  106. package/dist/{chunk-H5GPM4LA.mjs.map → chunk-5KD2EW7O.mjs.map} +1 -1
  107. package/dist/chunk-72DR3HF2.mjs +2 -0
  108. package/dist/chunk-72DR3HF2.mjs.map +1 -0
  109. package/dist/chunk-AMIRIUMH.mjs +2 -0
  110. package/dist/chunk-AMIRIUMH.mjs.map +1 -0
  111. package/dist/chunk-ISS46WVH.mjs +2 -0
  112. package/dist/chunk-ISS46WVH.mjs.map +1 -0
  113. package/dist/chunk-KWH7GE23.mjs +2 -0
  114. package/dist/chunk-KWH7GE23.mjs.map +1 -0
  115. package/dist/chunk-LXJGGXF3.mjs +2 -0
  116. package/dist/chunk-LXJGGXF3.mjs.map +1 -0
  117. package/dist/chunk-M4BZMGTB.mjs +2 -0
  118. package/dist/chunk-M4BZMGTB.mjs.map +1 -0
  119. package/dist/chunk-NJKSUUOB.mjs +2 -0
  120. package/dist/chunk-NJKSUUOB.mjs.map +1 -0
  121. package/dist/chunk-NUTKOIGY.mjs +2 -0
  122. package/dist/chunk-NUTKOIGY.mjs.map +1 -0
  123. package/dist/chunk-QLLM365R.mjs +2 -0
  124. package/dist/chunk-QLLM365R.mjs.map +1 -0
  125. package/dist/chunk-SFTIM3X7.mjs +2 -0
  126. package/dist/chunk-SFTIM3X7.mjs.map +1 -0
  127. package/dist/index.d.mts +44 -4
  128. package/dist/index.d.ts +44 -4
  129. package/dist/index.js +2 -2
  130. package/dist/index.js.map +1 -1
  131. package/dist/index.mjs +2 -2
  132. package/dist/index.mjs.map +1 -1
  133. package/package.json +1 -1
  134. package/dist/chunk-6PDP4ETM.mjs +0 -2
  135. package/dist/chunk-6PDP4ETM.mjs.map +0 -1
  136. package/dist/chunk-ATUUYYQT.mjs.map +0 -1
  137. package/dist/chunk-CKUUUEWT.mjs +0 -2
  138. package/dist/chunk-CKUUUEWT.mjs.map +0 -1
  139. package/dist/chunk-DKI6BDWK.mjs +0 -2
  140. package/dist/chunk-DKI6BDWK.mjs.map +0 -1
  141. package/dist/chunk-K3AXPTGG.mjs +0 -2
  142. package/dist/chunk-K3AXPTGG.mjs.map +0 -1
  143. package/dist/chunk-LMMJSJTO.mjs +0 -2
  144. package/dist/chunk-LMMJSJTO.mjs.map +0 -1
  145. package/dist/chunk-RWBNLNQ6.mjs +0 -2
  146. package/dist/chunk-RWBNLNQ6.mjs.map +0 -1
  147. package/dist/chunk-V4H3X4PI.mjs +0 -2
  148. package/dist/chunk-V4H3X4PI.mjs.map +0 -1
  149. package/dist/chunk-WOMA746Z.mjs +0 -2
  150. package/dist/chunk-WOMA746Z.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/Enum.ts","../../src/Classes/Error.ts","../../src/Classes/Price.ts","../../src/Classes/TieredPrice.ts"],"names":["CurrencySymbolMap","CurrencyLocaleMap","InvalidTaxCategoryError","message","InvalidMinQuantityError","InvalidTieredPriceError","InvalidQuantityError","NoApplicableTierError","quantity","InvalidPriceAmountError","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","PriceModel","_PriceModel","data","priceModel","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","options","locale","valueToFormat","fractionDigits","formattingOptions","error","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier","TieredPriceModel","baseUnitPrice","tiers","tier","a","b","t","hasDifferentCurrency","hasIrregularPricing","index","basePriceExceedsFirstTier","i","lowestTierPrice","basePrice"],"mappings":"aAsCO,IAAMA,CAAoB,CAAA,CAC9B,GAAiC,CAAA,QACpC,CAEaC,CAAAA,CAAAA,CAAoB,CAC9B,GAAA,CAAiC,OACpC,CAAA,CCYO,IAAMC,CAAAA,CAAN,cAAsC,KAAM,CAC/C,WAAA,CAAYC,CAAkB,CAAA,4BAAA,CAA8B,CACxD,KAAA,CAAM,CAAuBA,oBAAAA,EAAAA,CAAO,CAAE,CAAA,CAAA,CACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,EAEaC,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAYD,CAAAA,CAAAA,CAAkB,6CAA+C,CAAA,CACzE,KAAM,CAAA,CAAA,oBAAA,EAAuBA,CAAO,CAAA,CAAE,CACtC,CAAA,IAAA,CAAK,IAAO,CAAA,0BAChB,CACJ,CAAA,CAEaE,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAYF,CAAAA,CAAAA,CAAiB,CACzB,K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AC,CAAA,CAAE,WAC5B,CAAA,OAAO,IAAK,CAAA,KAAA,CAAMA,CAAC,CAAA,CAIvB,MAAM,IAAIzC,CAAsBC,CAAAA,CAAQ,CAC1C,CAKA,cAAyB,EAAA,CACvB,OAAO,IAAA,CAAK,KAAM,CAAA,CAAC,GAAG,WAAe,EAAA,CACvC,CAKA,qBAAA,EAAgC,CAC9B,GAAI,CAAC,IAAA,CAAK,KAAM,CAAA,MAAA,CAAQ,OAAO,CAAA,CAE/B,IAAMyC,CAAAA,CAAkB,IAAK,CAAA,KAAA,CAAM,KAAK,KAAM,CAAA,MAAA,CAAS,CAAC,CAAA,CAAE,SAAU,CAAA,SAAA,EAC9DC,CAAAA,CAAAA,CAAY,IAAK,CAAA,aAAA,CAAc,SAAU,EAAA,CAE/C,OAASA,CAAAA,CAAAA,CAAYD,CAAmBC,EAAAA,CAAAA,CAAa,GACvD,CACF","file":"TieredPrice.js","sourcesContent":["/**\r\n * Represents the countries where the application operates or products are available.\r\n */\r\nexport enum OperationalCountry {\r\n /** India */ IN = 'IN',\r\n}\r\n \r\nexport enum OperationalCountryCurrency {\r\n /** India */ INR = 'INR',\r\n}\r\n\r\nexport enum OperationalLocale {\r\n /** India */ 'en-IN' = 'en-IN',\r\n /** India ( Kannada) */ 'kn-IN' = 'kn-IN'\r\n}\r\n\r\nexport enum OperationalLanguage {\r\n en = 'en',\r\n kn = 'kn'\r\n}\r\n\r\nexport const LocaleLanguageMap: Record<OperationalLocale, OperationalLanguage> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalLanguage.en,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalLanguage.kn,\r\n}\r\n\r\nexport const LocaleCountryMap: Record<OperationalLocale, OperationalCountry> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalCountry.IN,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalCountry.IN,\r\n}\r\n\r\n/**\r\n * Defines the supported ISO 4217 currency codes as an enumeration.\r\n */\r\nexport const CountryCurrencyMap = {\r\n /** India */ [OperationalCountry.IN]: OperationalCountryCurrency.INR,\r\n};\r\n\r\nexport const CurrencySymbolMap = {\r\n [OperationalCountryCurrency.INR]: '₹',\r\n}\r\n\r\nexport const CurrencyLocaleMap = {\r\n [OperationalCountryCurrency.INR]: OperationalLocale[\"en-IN\"],\r\n}\r\n\r\n/**\r\n * Defines standard gender categories for product targeting.\r\n */\r\nexport enum GenderCategory {\r\n MALE = 'Male',\r\n FEMALE = 'Female',\r\n UNISEX = 'Unisex',\r\n KIDS = 'Kids',\r\n BOY = 'Boy',\r\n GIRL = 'Girl',\r\n GENERAL = 'General',\r\n}\r\n\r\nexport enum ImageCategory {\r\n PRIMARY = 'PRIMARY',\r\n GALLERY = 'GALLERY'\r\n}\r\n\r\nexport enum TaxCategory {\r\n APPAREL = 'apparel',\r\n EXEMPT = 'exempt'\r\n}\r\n\r\nexport enum TaxSystem {\r\n GST = 'GST',\r\n}\r\n\r\n/**\r\n * LineItemState\r\n * \r\n * INITIAL: Item added to order, not yet processed.\r\n * PROCESSING: Item is being prepared for shipment.\r\n * SHIPPED: Item dispatched to customer.\r\n * DELIVERED: Item delivered to customer.\r\n * CANCELLED: Item cancelled before shipment or delivery.\r\n * RETURN_REQUESTED: Customer requests to return item.\r\n * RETURNED: Item received back from customer.\r\n * REFUND_INITIATED: Refund initiated for item.\r\n * REFUNDED: Refund processed for item.\r\n * ON_HOLD: Item is paused due to payment, inventory, or other issues.\r\n */\r\nexport enum LineItemState {\r\n INITIAL = \"INITIAL\",\r\n PROCESSING = \"PROCESSING\",\r\n SHIPPED = \"SHIPPED\",\r\n DELIVERED = \"DELIVERED\",\r\n CANCELLED = \"CANCELLED\",\r\n RETURN_REQUESTED = \"RETURN_REQUESTED\",\r\n RETURNED = \"RETURNED\",\r\n REFUND_INITIATED = \"REFUND_INITIATED\",\r\n REFUNDED = \"REFUNDED\",\r\n ON_HOLD = \"ON_HOLD\",\r\n}","export class LineItemNotFoundError extends Error {\r\n constructor(lineItemId: string) {\r\n super(`Line item with ID '${lineItemId}' not found in the cart.`);\r\n this.name = 'LineItemNotFoundError';\r\n }\r\n}\r\n\r\nexport class DuplicateSizeError extends Error {\r\n constructor(size: string) {\r\n super(`Duplicate size found: ${size}`);\r\n this.name = 'DuplicateSizeError';\r\n }\r\n}\r\n\r\nexport class ProductMismatchError extends Error {\r\n constructor(message: string = \"Product and selection attributes do not match.\") {\r\n super(`ProductMismatch: ${message}`);\r\n this.name = 'ProductMismatchError';\r\n }\r\n}\r\n\r\nexport class ProductInactiveError extends Error {\r\n constructor(message: string = \"Product is not active.\") {\r\n super(`ProductInactive: ${message}`);\r\n this.name = 'ProductInactiveError';\r\n }\r\n}\r\n\r\nexport class SelectionAttributeParseError extends Error {\r\n constructor(message: string = \"Failed to parse selection attributes key.\") {\r\n super(`SelectionAttributeParseError: ${message}`);\r\n this.name = 'SelectionAttributeParseError';\r\n }\r\n}\r\n\r\nexport class SizeMismatchError extends Error {\r\n constructor(message: string = \"Size does not match.\") {\r\n super(`SizeMismatch: ${message}`);\r\n this.name = 'SizeMismatchError';\r\n }\r\n}\r\n\r\nexport class PricingNotFoundError extends Error {\r\n constructor(message: string = \"Pricing details not available for the product\") {\r\n super(`NotFound: ${message}`);\r\n this.name = 'PricingNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxRuleError extends Error {\r\n constructor(message: string = \"Tax rule category mismatch.\") {\r\n super(`InvalidTaxRule: ${message}`);\r\n this.name = 'InvalidTaxRuleError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxCategoryError extends Error {\r\n constructor(message: string = \"Tax category is not valid.\") {\r\n super(`InvalidTaxCategory: ${message}`);\r\n this.name = 'InvalidTaxCategoryError';\r\n }\r\n}\r\n\r\nexport class InvalidMinQuantityError extends Error {\r\n constructor(message: string = \"Minimum quantity must be greater than zero.\") {\r\n super(`InvalidMinQuantity: ${message}`);\r\n this.name = 'InvalidMinQuantityError';\r\n }\r\n}\r\n\r\nexport class InvalidTieredPriceError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidTieredPrice: ${message}`);\r\n this.name = 'InvalidTieredPriceError';\r\n }\r\n}\r\n\r\nexport class InvalidQuantityError extends Error {\r\n constructor(message: string = \"Quantity must be greater than zero.\") {\r\n super(`InvalidQuantity: ${message}`);\r\n this.name = 'InvalidQuantityError';\r\n }\r\n}\r\n\r\nexport class NoApplicableTierError extends Error {\r\n constructor(quantity: number) {\r\n super(`NoApplicableTier: Quantity ${quantity} does not meet the minimum purchase requirement.`);\r\n this.name = 'NoApplicableTierError';\r\n }\r\n}\r\n\r\nexport class TaxSlabNotFoundError extends Error {\r\n constructor(message: string = \"No applicable tax slab or multiple slabs found for the given unit price.\") {\r\n super(`TaxSlabNotFound: ${message}`);\r\n this.name = 'TaxSlabNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidPriceAmountError extends Error {\r\n constructor(message: string = \"Amount cannot be negative.\") {\r\n super(`InvalidAmount: ${message}`);\r\n this.name = 'InvalidPriceAmountError';\r\n }\r\n}\r\n\r\nexport class InvalidCurrencyCodeError extends Error {\r\n constructor(message: string = \"Currency code is required.\") {\r\n super(`InvalidCurrency: ${message}`);\r\n this.name = 'InvalidCurrencyCodeError';\r\n }\r\n}\r\n\r\nexport class CurrencyMismatchError extends Error {\r\n constructor(message: string = \"Cannot perform operation on prices with different currencies.\") {\r\n super(`CurrencyMismatch: ${message}`);\r\n this.name = 'CurrencyMismatchError';\r\n }\r\n}\r\n\r\nexport class InvalidArgumentError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidArgument: ${message}`);\r\n this.name = 'InvalidArgumentError';\r\n }\r\n}\r\n\r\nexport class InvalidImageSourceError extends Error {\r\n constructor(message: string = \"Invalid image source configuration.\") {\r\n super(`InvalidImageSource: ${message}`);\r\n this.name = 'InvalidImageSourceError';\r\n }\r\n}","import { CurrencyCode } from \"./Common\";\r\nimport { CurrencyLocaleMap, CurrencySymbolMap, OperationalCountryCurrency } from \"./Enum\";\r\nimport {\r\n InvalidPriceAmountError,\r\n InvalidCurrencyCodeError,\r\n CurrencyMismatchError,\r\n InvalidArgumentError\r\n} from \"./Error\";\r\n\r\nexport type PriceAttributes = {\r\n amount: number;\r\n currency: CurrencyCode;\r\n}\r\n\r\nexport type PriceData = PriceAttributes;\r\n\r\nexport default class PriceModel {\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param amount - The initial price value.\r\n * @param currency - The currency code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(data: PriceAttributes) {\r\n if (data.amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative.\");\r\n }\r\n\r\n if (!data.currency) {\r\n throw new InvalidCurrencyCodeError(\"Currency code is required.\");\r\n }\r\n\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n }\r\n\r\n /**\r\n * Gets the currency associated with this price instance.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Returns the raw numeric price value.\r\n */\r\n public getAmount(): number {\r\n return this.amount;\r\n }\r\n\r\n /**\r\n *\r\n * @returns PriceData\r\n */\r\n public getDetails(): PriceData {\r\n return {\r\n amount: this.amount,\r\n currency: this.currency\r\n }\r\n }\r\n\r\n /**\r\n * Compares this price with another {@link PriceModel} instance.\r\n *\r\n * The comparison is performed using the numeric price value and is only valid\r\n * when both prices are expressed in the same currency.\r\n *\r\n * ### Comparison result:\r\n * - Returns a **negative number** if this price is **less than** `priceModel`\r\n * - Returns **zero** if both prices are **equal**\r\n * - Returns a **positive number** if this price is **greater than** `priceModel`\r\n *\r\n * @param priceModel - The {@link PriceModel} instance to compare against.\r\n *\r\n * @returns\r\n * A signed number representing the comparison result:\r\n * - `< 0` → this price is lower\r\n * - `0` → prices are equal\r\n * - `> 0` → this price is higher\r\n *\r\n * @throws {Error}\r\n * Throws an error if:\r\n * - `priceModel` is not an instance of {@link PriceModel}\r\n * - The currencies of the two prices do not match\r\n *\r\n * @example\r\n * ```ts\r\n * const a = new PriceModel(\"USD\", 100);\r\n * const b = new PriceModel(\"USD\", 150);\r\n *\r\n * a.compareTo(b); // -50\r\n * b.compareTo(a); // 50\r\n * a.compareTo(a); // 0\r\n * ```\r\n */\r\n public compareTo(priceModel: PriceModel): number {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return this.amount - priceModel.getAmount();\r\n }\r\n\r\n public add(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot add prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount + priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public subtract(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot subtract prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount - priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public multiply(factor: number | PriceModel): PriceModel {\r\n if (factor instanceof PriceModel) {\r\n if (this.currency !== factor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot multiply prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount * factor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof factor === \"number\" && factor >= 0) {\r\n return new PriceModel({\r\n amount: this.amount * factor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a non-negative number.\");\r\n }\r\n\r\n public divide(divisor: number | PriceModel): PriceModel {\r\n if (divisor instanceof PriceModel) {\r\n if (this.currency !== divisor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot divide prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount / divisor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof divisor === \"number\" && divisor > 0) {\r\n return new PriceModel({\r\n amount: this.amount / divisor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a positive number.\");\r\n }\r\n\r\n public min(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((minPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (minPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return minPrice.compareTo(currentPrice) < 0 ? minPrice : currentPrice;\r\n });\r\n }\r\n\r\n public max(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((maxPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (maxPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return maxPrice.compareTo(currentPrice) > 0 ? maxPrice : currentPrice;\r\n });\r\n }\r\n\r\n /**\r\n * Gets a zero value PriceModel for the same currency.\r\n * @returns A PriceModel instance representing zero in the same currency.\r\n */\r\n public zero(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: 0\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the price is zero.\r\n * @returns True if the price is zero, false otherwise.\r\n */\r\n public isZero(): boolean {\r\n return this.amount === 0;\r\n }\r\n\r\n\r\n public round(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: this.getRoundedAmount()\r\n });\r\n }\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedAmount(): number {\r\n return PriceModel.getRoundedAmount(this.amount, this.currency);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price stored in this instance.\r\n * Uses the static `PriceModel.getFormattedString` method for the actual formatting.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n public getFormattedString() {\r\n return PriceModel.getFormattedString(this.amount, this.currency);\r\n }\r\n\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the amount.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param amount - The initial amount value.\r\n * @param currency - The currency code for formatting.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.\r\n * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.\r\n * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.\r\n * @returns The formatted price string according to locale rules.\r\n * @throws {Error} If currency code is invalid.\r\n */\r\n static getFormattedString(amount: number, currency: CurrencyCode, options: {\r\n displayAsInteger?: boolean,\r\n style?: 'currency' | 'decimal',\r\n currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name'\r\n } = {\r\n displayAsInteger: false,\r\n style: 'currency',\r\n currencyDisplay: 'symbol'\r\n }): string {\r\n\r\n const locale = CurrencyLocaleMap[currency];\r\n if (!currency || !locale) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for formatting.');\r\n }\r\n\r\n let valueToFormat = amount;\r\n const fractionDigits = options.displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: options.style ?? 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (options.displayAsInteger) {\r\n valueToFormat = Math.ceil(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for currency \"${currency}\" and locale \"${locale}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case OperationalCountryCurrency.INR:\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param currency - The currency code to determine the rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the price is negative or currency is invalid.\r\n */\r\n static getRoundedAmount(amount: number, currency: CurrencyCode): number {\r\n if (amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative for rounding.\");\r\n }\r\n\r\n if (currency === undefined) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for rounding.');\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(amount * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n}","import { TaxCategory } from \"./Enum\";\r\nimport PriceModel, { PriceData } from \"./Price\";\r\nimport {\r\n InvalidTaxCategoryError,\r\n InvalidMinQuantityError,\r\n InvalidTieredPriceError,\r\n InvalidQuantityError,\r\n NoApplicableTierError\r\n} from \"./Error\";\r\n\r\n/**\r\n * Represents a pricing tier based on a minimum purchase quantity.\r\n */\r\nexport type PriceTier = {\r\n minQuantity: number;\r\n unitPrice: PriceModel;\r\n};\r\n\r\n/**\r\n * Represents the attributes required for tiered pricing.\r\n */\r\nexport type TieredPriceAttributes = {\r\n baseUnitPrice: PriceData;\r\n taxCategory: TaxCategory;\r\n\r\n /** Quantity-based pricing tiers */\r\n tiers: {\r\n minQuantity: number;\r\n unitPrice: PriceData;\r\n }[];\r\n};\r\n\r\nexport type TieredPriceData = TieredPriceAttributes;\r\n\r\nexport class TieredPriceModel {\r\n protected baseUnitPrice: PriceModel;\r\n protected taxCategory: TaxCategory;\r\n protected tiers: PriceTier[];\r\n\r\n /** Constructor\r\n * Initializes the tiered pricing model with the provided attributes.\r\n * @param data - The tiered pricing attributes.\r\n *\r\n * @throws {Error}\r\n * - If the tax category is not valid\r\n * - If any tier has an invalid minimum quantity or unit price\r\n * - If the base unit price is not valid\r\n */\r\n constructor(data: TieredPriceAttributes) {\r\n const baseUnitPrice = new PriceModel(data.baseUnitPrice);\r\n\r\n if (!data.taxCategory) {\r\n throw new InvalidTaxCategoryError();\r\n }\r\n\r\n const tiers = (data.tiers ?? [])\r\n .map(tier => ({\r\n minQuantity: tier.minQuantity,\r\n unitPrice: new PriceModel(tier.unitPrice),\r\n }))\r\n .sort((a, b) => a.minQuantity - b.minQuantity);\r\n\r\n const hasInvalidMinQuantity = tiers.some(t => t.minQuantity <= 0);\r\n if (hasInvalidMinQuantity) {\r\n throw new InvalidMinQuantityError();\r\n }\r\n\r\n const hasDifferentCurrency = tiers.some(\r\n t => t.unitPrice.getCurrency() !== baseUnitPrice.getCurrency()\r\n );\r\n const hasIrregularPricing = tiers.some(\r\n (tier, index) =>\r\n index > 0 &&\r\n tier.unitPrice.compareTo(tiers[index - 1].unitPrice) > 0\r\n );\r\n const basePriceExceedsFirstTier = tiers[0]?.unitPrice.compareTo(baseUnitPrice) > 0;\r\n\r\n if (hasDifferentCurrency || hasIrregularPricing || basePriceExceedsFirstTier) {\r\n throw new InvalidTieredPriceError(\r\n \"Tiers must share the same currency and must not increase in unit price.\"\r\n );\r\n }\r\n\r\n this.baseUnitPrice = baseUnitPrice;\r\n this.taxCategory = data.taxCategory;\r\n this.tiers = tiers;\r\n }\r\n\r\n /** \r\n * Returns the base unit price \r\n * @returns The base unit price as a PriceModel instance.\r\n */\r\n getBaseUnitPrice(): PriceModel {\r\n return this.baseUnitPrice;\r\n }\r\n\r\n /** \r\n * Returns the tax category \r\n * @returns The tax category as a TaxCategory enum value.\r\n */\r\n getTaxCategory(): TaxCategory {\r\n return this.taxCategory;\r\n }\r\n\r\n /** \r\n * Returns all pricing tiers sorted by minimum quantity \r\n * @returns An array of PriceTier objects.\r\n */\r\n getTiers(): readonly PriceTier[] {\r\n return this.tiers;\r\n }\r\n\r\n getDetails(): TieredPriceData {\r\n return {\r\n baseUnitPrice: this.baseUnitPrice.getDetails(),\r\n taxCategory: this.taxCategory,\r\n tiers: this.tiers.map(tier => ({\r\n minQuantity: tier.minQuantity,\r\n unitPrice: tier.unitPrice.getDetails()\r\n }))\r\n };\r\n }\r\n\r\n /**\r\n * Returns the applicable unit price for a given quantity.\r\n *\r\n * @param quantity - Purchase quantity\r\n * @returns The unit price for the highest applicable tier\r\n *\r\n * @throws {Error}\r\n * - If quantity is less than or equal to zero\r\n * - If quantity does not meet the minimum requirement of any tier\r\n */\r\n getApplicableTier(quantity: number): PriceTier {\r\n if (quantity <= 0) {\r\n throw new InvalidQuantityError();\r\n }\r\n\r\n for (let i = this.tiers.length - 1; i >= 0; i--) {\r\n if (quantity >= this.tiers[i].minQuantity) {\r\n return this.tiers[i];\r\n }\r\n }\r\n\r\n throw new NoApplicableTierError(quantity);\r\n }\r\n\r\n /**\r\n * Returns the minimum quantity required to purchase this product.\r\n */\r\n getMinQuantity(): number {\r\n return this.tiers[0]?.minQuantity ?? 1;\r\n }\r\n\r\n /**\r\n * Returns the maximum discount percentage achievable compared to the base unit price.\r\n */\r\n getMaxDiscountPercent(): number {\r\n if (!this.tiers.length) return 0;\r\n\r\n const lowestTierPrice = this.tiers[this.tiers.length - 1].unitPrice.getAmount();\r\n const basePrice = this.baseUnitPrice.getAmount();\r\n\r\n return ((basePrice - lowestTierPrice) / basePrice) * 100;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ export{a as TieredPriceModel}from'../chunk-KWH7GE23.mjs';import'../chunk-54RUAXYE.mjs';import'../chunk-72DR3HF2.mjs';import'../chunk-NJKSUUOB.mjs';//# sourceMappingURL=TieredPrice.mjs.map
2
+ //# sourceMappingURL=TieredPrice.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"TieredPrice.mjs"}
@@ -0,0 +1,210 @@
1
+ import { OperationalCountry, OperationalCountryCurrency, OperationalLocale, OperationalLanguage } from './Classes/Enum.js';
2
+
3
+ type PriceAttributes = {
4
+ amount: number;
5
+ currency: CurrencyCode;
6
+ };
7
+ type PriceData = PriceAttributes;
8
+ declare class PriceModel {
9
+ protected amount: number;
10
+ protected currency: CurrencyCode;
11
+ /**
12
+ * Creates an instance of PriceModel, storing the currency-correct rounded price.
13
+ * @param amount - The initial price value.
14
+ * @param currency - The currency code used for rounding and determining the currency symbol.
15
+ * @throws {Error} If price is negative or country/currency mapping is missing.
16
+ */
17
+ constructor(data: PriceAttributes);
18
+ /**
19
+ * Gets the currency associated with this price instance.
20
+ * @returns The CurrencyCode enum value.
21
+ */
22
+ getCurrency(): CurrencyCode;
23
+ /**
24
+ * Returns the raw numeric price value.
25
+ */
26
+ getAmount(): number;
27
+ /**
28
+ *
29
+ * @returns PriceData
30
+ */
31
+ getDetails(): PriceData;
32
+ /**
33
+ * Compares this price with another {@link PriceModel} instance.
34
+ *
35
+ * The comparison is performed using the numeric price value and is only valid
36
+ * when both prices are expressed in the same currency.
37
+ *
38
+ * ### Comparison result:
39
+ * - Returns a **negative number** if this price is **less than** `priceModel`
40
+ * - Returns **zero** if both prices are **equal**
41
+ * - Returns a **positive number** if this price is **greater than** `priceModel`
42
+ *
43
+ * @param priceModel - The {@link PriceModel} instance to compare against.
44
+ *
45
+ * @returns
46
+ * A signed number representing the comparison result:
47
+ * - `< 0` → this price is lower
48
+ * - `0` → prices are equal
49
+ * - `> 0` → this price is higher
50
+ *
51
+ * @throws {Error}
52
+ * Throws an error if:
53
+ * - `priceModel` is not an instance of {@link PriceModel}
54
+ * - The currencies of the two prices do not match
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const a = new PriceModel("USD", 100);
59
+ * const b = new PriceModel("USD", 150);
60
+ *
61
+ * a.compareTo(b); // -50
62
+ * b.compareTo(a); // 50
63
+ * a.compareTo(a); // 0
64
+ * ```
65
+ */
66
+ compareTo(priceModel: PriceModel): number;
67
+ add(priceModel: PriceModel): PriceModel;
68
+ subtract(priceModel: PriceModel): PriceModel;
69
+ multiply(factor: number | PriceModel): PriceModel;
70
+ divide(divisor: number | PriceModel): PriceModel;
71
+ min(...priceModels: PriceModel[]): PriceModel;
72
+ max(...priceModels: PriceModel[]): PriceModel;
73
+ /**
74
+ * Gets a zero value PriceModel for the same currency.
75
+ * @returns A PriceModel instance representing zero in the same currency.
76
+ */
77
+ zero(): PriceModel;
78
+ /**
79
+ * Checks if the price is zero.
80
+ * @returns True if the price is zero, false otherwise.
81
+ */
82
+ isZero(): boolean;
83
+ round(): PriceModel;
84
+ /**
85
+ * Gets the rounded price value based on standard currency rules.
86
+ * @returns The numeric price, rounded according to its currency's typical decimal places.
87
+ */
88
+ getRoundedAmount(): number;
89
+ /**
90
+ * Gets a locale-aware formatted display string for the price stored in this instance.
91
+ * Uses the static `PriceModel.getFormattedString` method for the actual formatting.
92
+ * @returns The formatted price string according to locale rules.
93
+ */
94
+ getFormattedString(): string;
95
+ /**
96
+ * Gets a locale-aware formatted display string for the amount.
97
+ * Uses Intl.NumberFormat for accurate formatting based on locale and currency.
98
+ * @param amount - The initial amount value.
99
+ * @param currency - The currency code for formatting.
100
+ * @param options - Configuration options for formatting.
101
+ * @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.
102
+ * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.
103
+ * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.
104
+ * @returns The formatted price string according to locale rules.
105
+ * @throws {Error} If currency code is invalid.
106
+ */
107
+ static getFormattedString(amount: number, currency: CurrencyCode, options?: {
108
+ displayAsInteger?: boolean;
109
+ style?: 'currency' | 'decimal';
110
+ currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
111
+ }): string;
112
+ /**
113
+ * Helper method to determine standard decimal places for a currency.
114
+ * @param currency - The currency code.
115
+ * @returns The number of decimal places (0, 2, or 3 based on common rules).
116
+ */
117
+ private static getDecimalPlaces;
118
+ /**
119
+ * Adds basic thousand separators (commas) to a number string.
120
+ * Does not handle different locale separators (e.g., periods, spaces).
121
+ * @param numStr - The number string (potentially with decimals).
122
+ * @returns The number string with commas added.
123
+ */
124
+ private static addThousandSeparators;
125
+ /**
126
+ * Rounds a price value according to the standard decimal places
127
+ * for the currency associated with the given country.
128
+ *
129
+ * @param price - The price value to round. Must be a non-negative number.
130
+ * @param currency - The currency code to determine the rounding rules.
131
+ * @returns The rounded price as a number.
132
+ * @throws {Error} If the price is negative or currency is invalid.
133
+ */
134
+ static getRoundedAmount(amount: number, currency: CurrencyCode): number;
135
+ }
136
+
137
+ type Prettify<T> = {
138
+ [K in keyof T]: T[K];
139
+ } & {};
140
+ /**
141
+ * Represents a ISO 3166-1 alpha-2 country code (e.g., 'US', 'IN').
142
+ */
143
+ type CountryCode = keyof typeof OperationalCountry;
144
+ /**
145
+ * Represents a ISO 4217 currency code (e.g., 'INR', 'USD').
146
+ */
147
+ type CurrencyCode = keyof typeof OperationalCountryCurrency;
148
+ /**
149
+ * /**
150
+ * Represents a value that can be localized into multiple languages.
151
+ * The 'en' property is mandatory and serves as the default English translation.
152
+ * Additional properties can be added for other locales using their respective locale codes.
153
+ */
154
+ type LocalizedValue<T> = Prettify<{
155
+ en: T;
156
+ } & {
157
+ [locale in Exclude<LocaleCode | LanguageCode, 'en'>]?: T;
158
+ }>;
159
+ /**
160
+ * /**
161
+ * Represents a string that can be localized into multiple languages.
162
+ * The 'en' property is mandatory and serves as the default English translation.
163
+ * Additional properties can be added for other locales using their respective locale codes.
164
+ */
165
+ type LocalizedString = LocalizedValue<string>;
166
+ /**
167
+ * Represents a BCP 47 language tag (e.g., 'en-US', 'fr-FR').
168
+ * Used to identify languages and regional variations.
169
+ */
170
+ type LocaleCode = keyof typeof OperationalLocale;
171
+ type LanguageCode = keyof typeof OperationalLanguage;
172
+ type Color = {
173
+ name: string;
174
+ hex?: string;
175
+ };
176
+ /**
177
+ * Represents a date and time string formatted according to the ISO 8601 standard.
178
+ * Example: "2023-10-27T10:30:00.000Z"
179
+ */
180
+ type ISODateTimeUTC = string;
181
+ type RegionalPrice = {
182
+ [country in CountryCode]?: PriceData;
183
+ };
184
+ interface ShippingDetails {
185
+ courierName: string;
186
+ courierId?: string;
187
+ serviceType?: string;
188
+ rating?: number;
189
+ estimatedDeliveryDays?: number;
190
+ cost: number;
191
+ currency?: string;
192
+ isFallback: boolean;
193
+ trackingUrl?: string;
194
+ deliveryType?: string;
195
+ insuranceAmount?: number;
196
+ weight?: number;
197
+ dimensions?: {
198
+ length: number;
199
+ width: number;
200
+ height: number;
201
+ unit?: string;
202
+ };
203
+ pickupDate?: string;
204
+ deliveryDate?: string;
205
+ status?: string;
206
+ rawApiData?: any;
207
+ [key: string]: any;
208
+ }
209
+
210
+ export { type CountryCode as C, type ISODateTimeUTC as I, type LocaleCode as L, type PriceData as P, type RegionalPrice as R, type ShippingDetails as S, type CurrencyCode as a, PriceModel as b, type LocalizedString as c, type LocalizedValue as d, type Prettify as e, type Color as f, type PriceAttributes as g, type LanguageCode as h };
@@ -0,0 +1,210 @@
1
+ import { OperationalCountry, OperationalCountryCurrency, OperationalLocale, OperationalLanguage } from './Classes/Enum.mjs';
2
+
3
+ type PriceAttributes = {
4
+ amount: number;
5
+ currency: CurrencyCode;
6
+ };
7
+ type PriceData = PriceAttributes;
8
+ declare class PriceModel {
9
+ protected amount: number;
10
+ protected currency: CurrencyCode;
11
+ /**
12
+ * Creates an instance of PriceModel, storing the currency-correct rounded price.
13
+ * @param amount - The initial price value.
14
+ * @param currency - The currency code used for rounding and determining the currency symbol.
15
+ * @throws {Error} If price is negative or country/currency mapping is missing.
16
+ */
17
+ constructor(data: PriceAttributes);
18
+ /**
19
+ * Gets the currency associated with this price instance.
20
+ * @returns The CurrencyCode enum value.
21
+ */
22
+ getCurrency(): CurrencyCode;
23
+ /**
24
+ * Returns the raw numeric price value.
25
+ */
26
+ getAmount(): number;
27
+ /**
28
+ *
29
+ * @returns PriceData
30
+ */
31
+ getDetails(): PriceData;
32
+ /**
33
+ * Compares this price with another {@link PriceModel} instance.
34
+ *
35
+ * The comparison is performed using the numeric price value and is only valid
36
+ * when both prices are expressed in the same currency.
37
+ *
38
+ * ### Comparison result:
39
+ * - Returns a **negative number** if this price is **less than** `priceModel`
40
+ * - Returns **zero** if both prices are **equal**
41
+ * - Returns a **positive number** if this price is **greater than** `priceModel`
42
+ *
43
+ * @param priceModel - The {@link PriceModel} instance to compare against.
44
+ *
45
+ * @returns
46
+ * A signed number representing the comparison result:
47
+ * - `< 0` → this price is lower
48
+ * - `0` → prices are equal
49
+ * - `> 0` → this price is higher
50
+ *
51
+ * @throws {Error}
52
+ * Throws an error if:
53
+ * - `priceModel` is not an instance of {@link PriceModel}
54
+ * - The currencies of the two prices do not match
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const a = new PriceModel("USD", 100);
59
+ * const b = new PriceModel("USD", 150);
60
+ *
61
+ * a.compareTo(b); // -50
62
+ * b.compareTo(a); // 50
63
+ * a.compareTo(a); // 0
64
+ * ```
65
+ */
66
+ compareTo(priceModel: PriceModel): number;
67
+ add(priceModel: PriceModel): PriceModel;
68
+ subtract(priceModel: PriceModel): PriceModel;
69
+ multiply(factor: number | PriceModel): PriceModel;
70
+ divide(divisor: number | PriceModel): PriceModel;
71
+ min(...priceModels: PriceModel[]): PriceModel;
72
+ max(...priceModels: PriceModel[]): PriceModel;
73
+ /**
74
+ * Gets a zero value PriceModel for the same currency.
75
+ * @returns A PriceModel instance representing zero in the same currency.
76
+ */
77
+ zero(): PriceModel;
78
+ /**
79
+ * Checks if the price is zero.
80
+ * @returns True if the price is zero, false otherwise.
81
+ */
82
+ isZero(): boolean;
83
+ round(): PriceModel;
84
+ /**
85
+ * Gets the rounded price value based on standard currency rules.
86
+ * @returns The numeric price, rounded according to its currency's typical decimal places.
87
+ */
88
+ getRoundedAmount(): number;
89
+ /**
90
+ * Gets a locale-aware formatted display string for the price stored in this instance.
91
+ * Uses the static `PriceModel.getFormattedString` method for the actual formatting.
92
+ * @returns The formatted price string according to locale rules.
93
+ */
94
+ getFormattedString(): string;
95
+ /**
96
+ * Gets a locale-aware formatted display string for the amount.
97
+ * Uses Intl.NumberFormat for accurate formatting based on locale and currency.
98
+ * @param amount - The initial amount value.
99
+ * @param currency - The currency code for formatting.
100
+ * @param options - Configuration options for formatting.
101
+ * @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.
102
+ * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.
103
+ * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.
104
+ * @returns The formatted price string according to locale rules.
105
+ * @throws {Error} If currency code is invalid.
106
+ */
107
+ static getFormattedString(amount: number, currency: CurrencyCode, options?: {
108
+ displayAsInteger?: boolean;
109
+ style?: 'currency' | 'decimal';
110
+ currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
111
+ }): string;
112
+ /**
113
+ * Helper method to determine standard decimal places for a currency.
114
+ * @param currency - The currency code.
115
+ * @returns The number of decimal places (0, 2, or 3 based on common rules).
116
+ */
117
+ private static getDecimalPlaces;
118
+ /**
119
+ * Adds basic thousand separators (commas) to a number string.
120
+ * Does not handle different locale separators (e.g., periods, spaces).
121
+ * @param numStr - The number string (potentially with decimals).
122
+ * @returns The number string with commas added.
123
+ */
124
+ private static addThousandSeparators;
125
+ /**
126
+ * Rounds a price value according to the standard decimal places
127
+ * for the currency associated with the given country.
128
+ *
129
+ * @param price - The price value to round. Must be a non-negative number.
130
+ * @param currency - The currency code to determine the rounding rules.
131
+ * @returns The rounded price as a number.
132
+ * @throws {Error} If the price is negative or currency is invalid.
133
+ */
134
+ static getRoundedAmount(amount: number, currency: CurrencyCode): number;
135
+ }
136
+
137
+ type Prettify<T> = {
138
+ [K in keyof T]: T[K];
139
+ } & {};
140
+ /**
141
+ * Represents a ISO 3166-1 alpha-2 country code (e.g., 'US', 'IN').
142
+ */
143
+ type CountryCode = keyof typeof OperationalCountry;
144
+ /**
145
+ * Represents a ISO 4217 currency code (e.g., 'INR', 'USD').
146
+ */
147
+ type CurrencyCode = keyof typeof OperationalCountryCurrency;
148
+ /**
149
+ * /**
150
+ * Represents a value that can be localized into multiple languages.
151
+ * The 'en' property is mandatory and serves as the default English translation.
152
+ * Additional properties can be added for other locales using their respective locale codes.
153
+ */
154
+ type LocalizedValue<T> = Prettify<{
155
+ en: T;
156
+ } & {
157
+ [locale in Exclude<LocaleCode | LanguageCode, 'en'>]?: T;
158
+ }>;
159
+ /**
160
+ * /**
161
+ * Represents a string that can be localized into multiple languages.
162
+ * The 'en' property is mandatory and serves as the default English translation.
163
+ * Additional properties can be added for other locales using their respective locale codes.
164
+ */
165
+ type LocalizedString = LocalizedValue<string>;
166
+ /**
167
+ * Represents a BCP 47 language tag (e.g., 'en-US', 'fr-FR').
168
+ * Used to identify languages and regional variations.
169
+ */
170
+ type LocaleCode = keyof typeof OperationalLocale;
171
+ type LanguageCode = keyof typeof OperationalLanguage;
172
+ type Color = {
173
+ name: string;
174
+ hex?: string;
175
+ };
176
+ /**
177
+ * Represents a date and time string formatted according to the ISO 8601 standard.
178
+ * Example: "2023-10-27T10:30:00.000Z"
179
+ */
180
+ type ISODateTimeUTC = string;
181
+ type RegionalPrice = {
182
+ [country in CountryCode]?: PriceData;
183
+ };
184
+ interface ShippingDetails {
185
+ courierName: string;
186
+ courierId?: string;
187
+ serviceType?: string;
188
+ rating?: number;
189
+ estimatedDeliveryDays?: number;
190
+ cost: number;
191
+ currency?: string;
192
+ isFallback: boolean;
193
+ trackingUrl?: string;
194
+ deliveryType?: string;
195
+ insuranceAmount?: number;
196
+ weight?: number;
197
+ dimensions?: {
198
+ length: number;
199
+ width: number;
200
+ height: number;
201
+ unit?: string;
202
+ };
203
+ pickupDate?: string;
204
+ deliveryDate?: string;
205
+ status?: string;
206
+ rawApiData?: any;
207
+ [key: string]: any;
208
+ }
209
+
210
+ export { type CountryCode as C, type ISODateTimeUTC as I, type LocaleCode as L, type PriceData as P, type RegionalPrice as R, type ShippingDetails as S, type CurrencyCode as a, PriceModel as b, type LocalizedString as c, type LocalizedValue as d, type Prettify as e, type Color as f, type PriceAttributes as g, type LanguageCode as h };
@@ -0,0 +1,2 @@
1
+ import {i,h}from'./chunk-72DR3HF2.mjs';import {o,p,q,r}from'./chunk-NJKSUUOB.mjs';var m=class t{amount;currency;constructor(e){if(e.amount<0)throw new o("Amount cannot be negative.");if(!e.currency)throw new p("Currency code is required.");this.amount=e.amount,this.currency=e.currency;}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}compareTo(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot compare prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot add prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return new t({amount:this.amount+e.getAmount(),currency:this.currency})}subtract(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot subtract prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return new t({amount:this.amount-e.getAmount(),currency:this.currency})}multiply(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot multiply prices in different currencies.");return new t({amount:this.amount*e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new t({amount:this.amount*e,currency:this.currency});throw new r("Must be a non-negative number.")}divide(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot divide prices in different currencies.");return new t({amount:this.amount/e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>0)return new t({amount:this.amount/e,currency:this.currency});throw new r("Must be a positive number.")}min(...e){if(e.length===0)throw new r("Must provide at least one PriceModel.");return e.reduce((r$1,n)=>{if(n instanceof t){if(r$1.getCurrency()!==n.getCurrency())throw new q("Cannot compare prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return r$1.compareTo(n)<0?r$1:n})}max(...e){if(e.length===0)throw new r("Must provide at least one PriceModel.");return e.reduce((r$1,n)=>{if(n instanceof t){if(r$1.getCurrency()!==n.getCurrency())throw new q("Cannot compare prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return r$1.compareTo(n)>0?r$1:n})}zero(){return new t({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new t({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return t.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return t.getFormattedString(this.amount,this.currency)}static getFormattedString(e,r,n={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let u=i[r];if(!r||!u)throw new p("Invalid currency code for formatting.");let o=e,s=n.displayAsInteger?0:t.getDecimalPlaces(r),h$1={style:n.style??"currency",currency:r,signDisplay:"never",currencyDisplay:n.currencyDisplay,minimumFractionDigits:s,maximumFractionDigits:s};n.displayAsInteger&&(o=Math.ceil(o));try{return new Intl.NumberFormat(u,h$1).format(o)}catch(f){return console.error(`Error formatting price for currency "${r}" and locale "${u}":`,f),`${h[r]??r} ${t.addThousandSeparators(o.toFixed(s))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let r=e.split("."),n=r[0],u=r.length>1?"."+r[1]:"";return n.replace(/\B(?=(\d{3})+(?!\d))/g,",")+u}static getRoundedAmount(e,r){if(e<0)throw new o("Amount cannot be negative for rounding.");if(r===void 0)throw new p("Invalid currency code for rounding.");let n=t.getDecimalPlaces(r),u=Math.pow(10,n);return Math.round(e*u)/u}};export{m as a};//# sourceMappingURL=chunk-54RUAXYE.mjs.map
2
+ //# sourceMappingURL=chunk-54RUAXYE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Classes/Price.ts"],"names":["PriceModel","_PriceModel","data","InvalidPriceAmountError","InvalidCurrencyCodeError","priceModel","CurrencyMismatchError","InvalidArgumentError","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","options","locale","CurrencyLocaleMap","valueToFormat","fractionDigits","formattingOptions","error","CurrencySymbolMap","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier"],"mappings":"kFAgBA,IAAqBA,CAArB,CAAA,MAAqB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urrencySymbolMap, OperationalCountryCurrency } from \"./Enum\";\r\nimport {\r\n InvalidPriceAmountError,\r\n InvalidCurrencyCodeError,\r\n CurrencyMismatchError,\r\n InvalidArgumentError\r\n} from \"./Error\";\r\n\r\nexport type PriceAttributes = {\r\n amount: number;\r\n currency: CurrencyCode;\r\n}\r\n\r\nexport type PriceData = PriceAttributes;\r\n\r\nexport default class PriceModel {\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param amount - The initial price value.\r\n * @param currency - The currency code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(data: PriceAttributes) {\r\n if (data.amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative.\");\r\n }\r\n\r\n if (!data.currency) {\r\n throw new InvalidCurrencyCodeError(\"Currency code is required.\");\r\n }\r\n\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n }\r\n\r\n /**\r\n * Gets the currency associated with this price instance.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Returns the raw numeric price value.\r\n */\r\n public getAmount(): number {\r\n return this.amount;\r\n }\r\n\r\n /**\r\n *\r\n * @returns PriceData\r\n */\r\n public getDetails(): PriceData {\r\n return {\r\n amount: this.amount,\r\n currency: this.currency\r\n }\r\n }\r\n\r\n /**\r\n * Compares this price with another {@link PriceModel} instance.\r\n *\r\n * The comparison is performed using the numeric price value and is only valid\r\n * when both prices are expressed in the same currency.\r\n *\r\n * ### Comparison result:\r\n * - Returns a **negative number** if this price is **less than** `priceModel`\r\n * - Returns **zero** if both prices are **equal**\r\n * - Returns a **positive number** if this price is **greater than** `priceModel`\r\n *\r\n * @param priceModel - The {@link PriceModel} instance to compare against.\r\n *\r\n * @returns\r\n * A signed number representing the comparison result:\r\n * - `< 0` → this price is lower\r\n * - `0` → prices are equal\r\n * - `> 0` → this price is higher\r\n *\r\n * @throws {Error}\r\n * Throws an error if:\r\n * - `priceModel` is not an instance of {@link PriceModel}\r\n * - The currencies of the two prices do not match\r\n *\r\n * @example\r\n * ```ts\r\n * const a = new PriceModel(\"USD\", 100);\r\n * const b = new PriceModel(\"USD\", 150);\r\n *\r\n * a.compareTo(b); // -50\r\n * b.compareTo(a); // 50\r\n * a.compareTo(a); // 0\r\n * ```\r\n */\r\n public compareTo(priceModel: PriceModel): number {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return this.amount - priceModel.getAmount();\r\n }\r\n\r\n public add(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot add prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount + priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public subtract(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot subtract prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount - priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public multiply(factor: number | PriceModel): PriceModel {\r\n if (factor instanceof PriceModel) {\r\n if (this.currency !== factor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot multiply prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount * factor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof factor === \"number\" && factor >= 0) {\r\n return new PriceModel({\r\n amount: this.amount * factor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a non-negative number.\");\r\n }\r\n\r\n public divide(divisor: number | PriceModel): PriceModel {\r\n if (divisor instanceof PriceModel) {\r\n if (this.currency !== divisor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot divide prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount / divisor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof divisor === \"number\" && divisor > 0) {\r\n return new PriceModel({\r\n amount: this.amount / divisor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a positive number.\");\r\n }\r\n\r\n public min(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((minPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (minPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return minPrice.compareTo(currentPrice) < 0 ? minPrice : currentPrice;\r\n });\r\n }\r\n\r\n public max(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((maxPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (maxPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return maxPrice.compareTo(currentPrice) > 0 ? maxPrice : currentPrice;\r\n });\r\n }\r\n\r\n /**\r\n * Gets a zero value PriceModel for the same currency.\r\n * @returns A PriceModel instance representing zero in the same currency.\r\n */\r\n public zero(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: 0\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the price is zero.\r\n * @returns True if the price is zero, false otherwise.\r\n */\r\n public isZero(): boolean {\r\n return this.amount === 0;\r\n }\r\n\r\n\r\n public round(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: this.getRoundedAmount()\r\n });\r\n }\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedAmount(): number {\r\n return PriceModel.getRoundedAmount(this.amount, this.currency);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price stored in this instance.\r\n * Uses the static `PriceModel.getFormattedString` method for the actual formatting.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n public getFormattedString() {\r\n return PriceModel.getFormattedString(this.amount, this.currency);\r\n }\r\n\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the amount.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param amount - The initial amount value.\r\n * @param currency - The currency code for formatting.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.\r\n * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.\r\n * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.\r\n * @returns The formatted price string according to locale rules.\r\n * @throws {Error} If currency code is invalid.\r\n */\r\n static getFormattedString(amount: number, currency: CurrencyCode, options: {\r\n displayAsInteger?: boolean,\r\n style?: 'currency' | 'decimal',\r\n currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name'\r\n } = {\r\n displayAsInteger: false,\r\n style: 'currency',\r\n currencyDisplay: 'symbol'\r\n }): string {\r\n\r\n const locale = CurrencyLocaleMap[currency];\r\n if (!currency || !locale) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for formatting.');\r\n }\r\n\r\n let valueToFormat = amount;\r\n const fractionDigits = options.displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: options.style ?? 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (options.displayAsInteger) {\r\n valueToFormat = Math.ceil(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for currency \"${currency}\" and locale \"${locale}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case OperationalCountryCurrency.INR:\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param currency - The currency code to determine the rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the price is negative or currency is invalid.\r\n */\r\n static getRoundedAmount(amount: number, currency: CurrencyCode): number {\r\n if (amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative for rounding.\");\r\n }\r\n\r\n if (currency === undefined) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for rounding.');\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(amount * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n}"]}
@@ -1,2 +1,2 @@
1
- var i=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){this.customFields={...e.customFields},this.version=e.version??1,this.createdAt=e.createdAt&&!isNaN(Date.parse(e.createdAt))?new Date(e.createdAt).toISOString():t.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():t.toISOString(),this.modifiedBy={...e.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(e,t,s,r){this.modifiedBy={id:e,authType:t,requestId:s,lambdaName:r};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}};export{i as a};//# sourceMappingURL=chunk-ATUUYYQT.mjs.map
2
- //# sourceMappingURL=chunk-ATUUYYQT.mjs.map
1
+ var i=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){this.customFields={...e.customFields},this.version=e.version??1,this.createdAt=e.createdAt&&!isNaN(Date.parse(e.createdAt))?new Date(e.createdAt).toISOString():t.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():t.toISOString(),this.modifiedBy={...e.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(e,t,s,r){this.modifiedBy={id:e,authType:t,requestId:s,lambdaName:r};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}};export{i as a};//# sourceMappingURL=chunk-55SOBG62.mjs.map
2
+ //# sourceMappingURL=chunk-55SOBG62.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Classes/Base.ts"],"names":["BaseModel","data","date","id","authType","requestId","lambdaName","fieldName","value"],"mappings":"AA4BqBA,IAAAA,CAAAA,CAArB,KAA+B,CACnB,YAAA,CACA,QACA,SACA,CAAA,UAAA,CACA,WAQV,WAAYC,CAAAA,CAAAA,CAAsBC,EAAa,IAAI,IAAA,CAAQ,CACzD,IAAK,CAAA,YAAA,CAAe,CAAE,GAAGD,CAAAA,CAAK,YAAa,CAAA,CAC3C,IAAK,CAAA,OAAA,CAAUA,EAAK,OAAW,EAAA,CAAA,CAC/B,KAAK,SAAYA,CAAAA,CAAAA,CAAK,WAAa,CAAC,KAAA,CAAM,IAAK,CAAA,KAAA,CAAMA,CAAK,CAAA,SAAS,CAAC,CAElE,CAAA,IAAI,KAAKA,CAAK,CAAA,SAAS,EAAE,WAAY,EAAA,CAErCC,CAAK,CAAA,WAAA,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CAMA,oBAAmC,CACjC,OAAO,CAAE,GAAG,IAAA,CAAK,YAAa,CAChC,CACF","file":"chunk-55SOBG62.mjs","sourcesContent":["import { AuthType } from \"../Auth\";\r\nimport { ISODateTimeUTC } from \"./Common\";\r\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type ModifiedBy = {\r\n id?: string;\r\n authType?: string;\r\n requestId?: string;\r\n lambdaName?: string;\r\n}\r\n\r\nexport type BaseAttributes = {\r\n customFields?: CustomFields;\r\n version?: number;\r\n createdAt?: ISODateTimeUTC;\r\n modifiedAt?: ISODateTimeUTC;\r\n modifiedBy?: ModifiedBy;\r\n};\r\n\r\nexport type BaseData = Required<BaseAttributes>;\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel {\r\n protected customFields: CustomFields;\r\n protected version: number;\r\n protected createdAt: ISODateTimeUTC;\r\n protected modifiedAt: ISODateTimeUTC;\r\n protected modifiedBy: ModifiedBy;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = { ...data.modifiedBy };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns\r\n */\r\n getModifiedBy(): ModifiedBy {\r\n return { ...this.modifiedBy };\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(id?: string, authType?: AuthType, requestId?: string, lambdaName?: string): void {\r\n this.modifiedBy = {\r\n id,\r\n authType,\r\n requestId,\r\n lambdaName,\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\r\n return this.customFields[fieldName] ?? null;\r\n }\r\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\r\n return { ...this.customFields };\r\n }\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-ATUUYYQT.mjs';var n=(e=>(e.BILLING="billing",e.SHIPPING="shipping",e.BILLING_AND_SHIPPING="billing&shipping",e.NONE="none",e))(n||{}),t=class extends a{id;firstName;lastName;company;phone;email;addressLine1;addressLine2;city;postalCode;state;country;isBillingAddress;isShippingAddress;constructor(s,r=new Date){super(s,r),this.id=s.id,this.firstName=s.firstName,this.lastName=s.lastName||"",this.company=s.company||"",this.phone=s.phone,this.email=s.email,this.addressLine1=s.addressLine1,this.addressLine2=s.addressLine2||"",this.city=s.city,this.postalCode=s.postalCode,this.state=s.state,this.country=s.country,this.isBillingAddress=s.isBillingAddress,this.isShippingAddress=s.isShippingAddress;}getDetails(){return {...super.getDetails(),id:this.getId(),firstName:this.getFirstName(),lastName:this.getLastName(),company:this.getCompany(),phone:this.getPhone(),email:this.getEmail(),addressLine1:this.getAddressLine1(),addressLine2:this.getAddressLine2(),city:this.getCity(),postalCode:this.getPostalCode(),state:this.getState(),country:this.getCountry(),isBillingAddress:this.getIsBillingAddress(),isShippingAddress:this.getIsShippingAddress()}}getId(){return this.id}getFirstName(){return this.firstName}getLastName(){return this.lastName}getCompany(){return this.company}getPhone(){return this.phone}getEmail(){return this.email}getAddressLine1(){return this.addressLine1}getAddressLine2(){return this.addressLine2}getCity(){return this.city}getPostalCode(){return this.postalCode}getState(){return this.state}getCountry(){return this.country}getIsBillingAddress(){return this.isBillingAddress}getIsShippingAddress(){return this.isShippingAddress}getAddressType(){return this.isBillingAddress&&this.isShippingAddress?"billing&shipping":this.isBillingAddress?"billing":this.isShippingAddress?"shipping":"none"}static checkIfShippingAddress(s){return s==="shipping"||s==="billing&shipping"}static checkIfBillingAddress(s){return s==="billing"||s==="billing&shipping"}};export{n as a,t as b};//# sourceMappingURL=chunk-H5GPM4LA.mjs.map
2
- //# sourceMappingURL=chunk-H5GPM4LA.mjs.map
1
+ import {a}from'./chunk-55SOBG62.mjs';var n=(e=>(e.BILLING="billing",e.SHIPPING="shipping",e.BILLING_AND_SHIPPING="billing&shipping",e.NONE="none",e))(n||{}),t=class extends a{id;firstName;lastName;company;phone;email;addressLine1;addressLine2;city;postalCode;state;country;isBillingAddress;isShippingAddress;constructor(s,r=new Date){super(s,r),this.id=s.id,this.firstName=s.firstName,this.lastName=s.lastName||"",this.company=s.company||"",this.phone=s.phone,this.email=s.email,this.addressLine1=s.addressLine1,this.addressLine2=s.addressLine2||"",this.city=s.city,this.postalCode=s.postalCode,this.state=s.state,this.country=s.country,this.isBillingAddress=s.isBillingAddress,this.isShippingAddress=s.isShippingAddress;}getDetails(){return {...super.getDetails(),id:this.getId(),firstName:this.getFirstName(),lastName:this.getLastName(),company:this.getCompany(),phone:this.getPhone(),email:this.getEmail(),addressLine1:this.getAddressLine1(),addressLine2:this.getAddressLine2(),city:this.getCity(),postalCode:this.getPostalCode(),state:this.getState(),country:this.getCountry(),isBillingAddress:this.getIsBillingAddress(),isShippingAddress:this.getIsShippingAddress()}}getId(){return this.id}getFirstName(){return this.firstName}getLastName(){return this.lastName}getCompany(){return this.company}getPhone(){return this.phone}getEmail(){return this.email}getAddressLine1(){return this.addressLine1}getAddressLine2(){return this.addressLine2}getCity(){return this.city}getPostalCode(){return this.postalCode}getState(){return this.state}getCountry(){return this.country}getIsBillingAddress(){return this.isBillingAddress}getIsShippingAddress(){return this.isShippingAddress}getAddressType(){return this.isBillingAddress&&this.isShippingAddress?"billing&shipping":this.isBillingAddress?"billing":this.isShippingAddress?"shipping":"none"}static checkIfShippingAddress(s){return s==="shipping"||s==="billing&shipping"}static checkIfBillingAddress(s){return s==="billing"||s==="billing&shipping"}};export{n as a,t as b};//# sourceMappingURL=chunk-5KD2EW7O.mjs.map
2
+ //# sourceMappingURL=chunk-5KD2EW7O.mjs.map