b23-lib 1.12.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +0 -0
  2. package/dist/Auth/index.js +1 -1
  3. package/dist/Auth/index.js.map +1 -1
  4. package/dist/Auth/index.mjs +1 -1
  5. package/dist/Auth/index.mjs.map +1 -1
  6. package/dist/Classes/Address.d.mts +1 -1
  7. package/dist/Classes/Address.d.ts +1 -1
  8. package/dist/Classes/Address.js.map +1 -1
  9. package/dist/Classes/Address.mjs +1 -1
  10. package/dist/Classes/Base.d.mts +5 -5
  11. package/dist/Classes/Base.d.ts +5 -5
  12. package/dist/Classes/Base.js.map +1 -1
  13. package/dist/Classes/Base.mjs +1 -1
  14. package/dist/Classes/Cart.d.mts +27 -12
  15. package/dist/Classes/Cart.d.ts +27 -12
  16. package/dist/Classes/Cart.js +1 -1
  17. package/dist/Classes/Cart.js.map +1 -1
  18. package/dist/Classes/Cart.mjs +1 -1
  19. package/dist/Classes/Cart.mjs.map +1 -1
  20. package/dist/Classes/Common.d.mts +2 -93
  21. package/dist/Classes/Common.d.ts +2 -93
  22. package/dist/Classes/Coupon.d.mts +33 -15
  23. package/dist/Classes/Coupon.d.ts +33 -15
  24. package/dist/Classes/Coupon.js +1 -1
  25. package/dist/Classes/Coupon.js.map +1 -1
  26. package/dist/Classes/Coupon.mjs +1 -1
  27. package/dist/Classes/Customer.d.mts +2 -2
  28. package/dist/Classes/Customer.d.ts +2 -2
  29. package/dist/Classes/Customer.js.map +1 -1
  30. package/dist/Classes/Customer.mjs +1 -1
  31. package/dist/Classes/Customer.mjs.map +1 -1
  32. package/dist/Classes/CustomerAddress.d.mts +1 -1
  33. package/dist/Classes/CustomerAddress.d.ts +1 -1
  34. package/dist/Classes/CustomerAddress.js.map +1 -1
  35. package/dist/Classes/CustomerAddress.mjs +1 -1
  36. package/dist/Classes/Enum.d.mts +43 -2
  37. package/dist/Classes/Enum.d.ts +43 -2
  38. package/dist/Classes/Enum.js +1 -1
  39. package/dist/Classes/Enum.js.map +1 -1
  40. package/dist/Classes/Enum.mjs +1 -1
  41. package/dist/Classes/Error.d.mts +59 -0
  42. package/dist/Classes/Error.d.ts +59 -0
  43. package/dist/Classes/Error.js +2 -0
  44. package/dist/Classes/Error.js.map +1 -0
  45. package/dist/Classes/Error.mjs +2 -0
  46. package/dist/Classes/Error.mjs.map +1 -0
  47. package/dist/Classes/ImageInfo.js +1 -1
  48. package/dist/Classes/ImageInfo.js.map +1 -1
  49. package/dist/Classes/ImageInfo.mjs +1 -1
  50. package/dist/Classes/Inventory.d.mts +25 -6
  51. package/dist/Classes/Inventory.d.ts +25 -6
  52. package/dist/Classes/Inventory.js +1 -1
  53. package/dist/Classes/Inventory.js.map +1 -1
  54. package/dist/Classes/Inventory.mjs +1 -1
  55. package/dist/Classes/Inventory.mjs.map +1 -1
  56. package/dist/Classes/LineItem.d.mts +140 -58
  57. package/dist/Classes/LineItem.d.ts +140 -58
  58. package/dist/Classes/LineItem.js +1 -1
  59. package/dist/Classes/LineItem.js.map +1 -1
  60. package/dist/Classes/LineItem.mjs +1 -1
  61. package/dist/Classes/Order.d.mts +7 -51
  62. package/dist/Classes/Order.d.ts +7 -51
  63. package/dist/Classes/Order.js +1 -1
  64. package/dist/Classes/Order.js.map +1 -1
  65. package/dist/Classes/Order.mjs +1 -1
  66. package/dist/Classes/Order.mjs.map +1 -1
  67. package/dist/Classes/Payment.d.mts +4 -4
  68. package/dist/Classes/Payment.d.ts +4 -4
  69. package/dist/Classes/Payment.js.map +1 -1
  70. package/dist/Classes/Payment.mjs +1 -1
  71. package/dist/Classes/Payment.mjs.map +1 -1
  72. package/dist/Classes/Price.d.mts +1 -82
  73. package/dist/Classes/Price.d.ts +1 -82
  74. package/dist/Classes/Price.js +1 -1
  75. package/dist/Classes/Price.js.map +1 -1
  76. package/dist/Classes/Price.mjs +1 -1
  77. package/dist/Classes/Product.d.mts +103 -85
  78. package/dist/Classes/Product.d.ts +103 -85
  79. package/dist/Classes/Product.js +1 -1
  80. package/dist/Classes/Product.js.map +1 -1
  81. package/dist/Classes/Product.mjs +1 -1
  82. package/dist/Classes/Product.mjs.map +1 -1
  83. package/dist/Classes/ShoppingContainer.d.mts +79 -63
  84. package/dist/Classes/ShoppingContainer.d.ts +79 -63
  85. package/dist/Classes/ShoppingContainer.js +1 -1
  86. package/dist/Classes/ShoppingContainer.js.map +1 -1
  87. package/dist/Classes/ShoppingContainer.mjs +1 -1
  88. package/dist/Classes/TaxRule.d.mts +63 -0
  89. package/dist/Classes/TaxRule.d.ts +63 -0
  90. package/dist/Classes/TaxRule.js +2 -0
  91. package/dist/Classes/TaxRule.js.map +1 -0
  92. package/dist/Classes/TaxRule.mjs +2 -0
  93. package/dist/Classes/TaxRule.mjs.map +1 -0
  94. package/dist/Classes/TieredPrice.d.mts +75 -0
  95. package/dist/Classes/TieredPrice.d.ts +75 -0
  96. package/dist/Classes/TieredPrice.js +2 -0
  97. package/dist/Classes/TieredPrice.js.map +1 -0
  98. package/dist/Classes/TieredPrice.mjs +2 -0
  99. package/dist/Classes/TieredPrice.mjs.map +1 -0
  100. package/dist/Common-D-UoxwM0.d.ts +210 -0
  101. package/dist/Common-FbQ5-3QN.d.mts +210 -0
  102. package/dist/chunk-2SGUPNWZ.mjs +2 -0
  103. package/dist/chunk-2SGUPNWZ.mjs.map +1 -0
  104. package/dist/chunk-54RUAXYE.mjs +2 -0
  105. package/dist/chunk-54RUAXYE.mjs.map +1 -0
  106. package/dist/{chunk-ATUUYYQT.mjs → chunk-55SOBG62.mjs} +2 -2
  107. package/dist/chunk-55SOBG62.mjs.map +1 -0
  108. package/dist/{chunk-H5GPM4LA.mjs → chunk-5KD2EW7O.mjs} +2 -2
  109. package/dist/{chunk-H5GPM4LA.mjs.map → chunk-5KD2EW7O.mjs.map} +1 -1
  110. package/dist/chunk-72DR3HF2.mjs +2 -0
  111. package/dist/chunk-72DR3HF2.mjs.map +1 -0
  112. package/dist/chunk-AMIRIUMH.mjs +2 -0
  113. package/dist/chunk-AMIRIUMH.mjs.map +1 -0
  114. package/dist/chunk-CEGQFFYZ.mjs +2 -0
  115. package/dist/chunk-CEGQFFYZ.mjs.map +1 -0
  116. package/dist/chunk-EP7WVZXC.mjs +2 -0
  117. package/dist/chunk-EP7WVZXC.mjs.map +1 -0
  118. package/dist/chunk-KWH7GE23.mjs +2 -0
  119. package/dist/chunk-KWH7GE23.mjs.map +1 -0
  120. package/dist/chunk-LNIZAPER.mjs +2 -0
  121. package/dist/chunk-LNIZAPER.mjs.map +1 -0
  122. package/dist/chunk-NJKSUUOB.mjs +2 -0
  123. package/dist/chunk-NJKSUUOB.mjs.map +1 -0
  124. package/dist/chunk-NUTKOIGY.mjs +2 -0
  125. package/dist/chunk-NUTKOIGY.mjs.map +1 -0
  126. package/dist/chunk-RBROVHJ4.mjs +2 -0
  127. package/dist/chunk-RBROVHJ4.mjs.map +1 -0
  128. package/dist/index.d.mts +9 -6
  129. package/dist/index.d.ts +9 -6
  130. package/dist/index.js +2 -2
  131. package/dist/index.js.map +1 -1
  132. package/dist/index.mjs +2 -2
  133. package/dist/index.mjs.map +1 -1
  134. package/package.json +35 -4
  135. package/dist/chunk-6PDP4ETM.mjs +0 -2
  136. package/dist/chunk-6PDP4ETM.mjs.map +0 -1
  137. package/dist/chunk-ATUUYYQT.mjs.map +0 -1
  138. package/dist/chunk-CKUUUEWT.mjs +0 -2
  139. package/dist/chunk-CKUUUEWT.mjs.map +0 -1
  140. package/dist/chunk-DKI6BDWK.mjs +0 -2
  141. package/dist/chunk-DKI6BDWK.mjs.map +0 -1
  142. package/dist/chunk-K3AXPTGG.mjs +0 -2
  143. package/dist/chunk-K3AXPTGG.mjs.map +0 -1
  144. package/dist/chunk-LMMJSJTO.mjs +0 -2
  145. package/dist/chunk-LMMJSJTO.mjs.map +0 -1
  146. package/dist/chunk-RWBNLNQ6.mjs +0 -2
  147. package/dist/chunk-RWBNLNQ6.mjs.map +0 -1
  148. package/dist/chunk-V4H3X4PI.mjs +0 -2
  149. package/dist/chunk-V4H3X4PI.mjs.map +0 -1
  150. package/dist/chunk-WOMA746Z.mjs +0 -2
  151. package/dist/chunk-WOMA746Z.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var i=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(t,e=new Date){this.customFields={...t.customFields},this.version=t.version??1,this.createdAt=t.createdAt&&!isNaN(Date.parse(t.createdAt))?new Date(t.createdAt).toISOString():e.toISOString(),this.modifiedAt=t.modifiedAt&&!isNaN(Date.parse(t.modifiedAt))?new Date(t.modifiedAt).toISOString():e.toISOString(),this.modifiedBy={...t.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(t,e,r,d){this.modifiedBy={id:t,authType:e,requestId:r,lambdaName:d};}getCustomField(t){return this.customFields[t]??null}setCustomField(t,e){this.customFields[t]=e;}getAllCustomFields(){return {...this.customFields}}};var s=class extends i{productKey;variantId;stocks;constructor(t){super(t),this.productKey=t.productKey,this.variantId=t.variantId,this.stocks=t.stocks.map(e=>({size:e.size,available:e.available,country:e.country}));}getProductKey(){return this.productKey}getVariantId(){return this.variantId}getStockData(){return [...this.stocks]}getStockBySize(t,e){return this.stocks.find(r=>r.size===t&&r.country===e)}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),variantId:this.getVariantId(),stocks:this.getStockData()}}};exports.InventoryModel=s;//# sourceMappingURL=Inventory.js.map
1
+ 'use strict';var H=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);var D=new Uint8Array(256),S=D.length;function U(){return S>D.length-16&&(H__default.default.randomFillSync(D),S=0),D.slice(S,S+=16)}var F=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function q(t){return typeof t=="string"&&F.test(t)}var $=q;var a=[];for(let t=0;t<256;++t)a.push((t+256).toString(16).slice(1));function T(t,e=0){return a[t[e+0]]+a[t[e+1]]+a[t[e+2]]+a[t[e+3]]+"-"+a[t[e+4]]+a[t[e+5]]+"-"+a[t[e+6]]+a[t[e+7]]+"-"+a[t[e+8]]+a[t[e+9]]+"-"+a[t[e+10]]+a[t[e+11]]+a[t[e+12]]+a[t[e+13]]+a[t[e+14]]+a[t[e+15]]}function Z(t){if(!$(t))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}var K=Z;function j(t){t=unescape(encodeURIComponent(t));let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}var X="6ba7b810-9dad-11d1-80b4-00c04fd430c8",W="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function k(t,e,r){function i(n,o,d,f){var u;if(typeof n=="string"&&(n=j(n)),typeof o=="string"&&(o=K(o)),((u=o)===null||u===void 0?void 0:u.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+n.length);if(l.set(o),l.set(n,o.length),l=r(l),l[6]=l[6]&15|e,l[8]=l[8]&63|128,d){f=f||0;for(let P=0;P<16;++P)d[f+P]=l[P];return d}return T(l)}try{i.name=t;}catch{}return i.DNS=X,i.URL=W,i}var B={randomUUID:H__default.default.randomUUID};function _(t,e,r){if(B.randomUUID&&!e&&!t)return B.randomUUID();t=t||{};let i=t.random||(t.rng||U)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){r=r||0;for(let n=0;n<16;++n)e[r+n]=i[n];return e}return T(i)}var z=_;function te(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),H__default.default.createHash("sha1").update(t).digest()}var Q=te;var re=k("v5",80,Q),O=re;var h=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(e,r=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():r.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():r.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,r,i,n){this.modifiedBy={id:e,authType:r,requestId:i,lambdaName:n};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,r){this.customFields[e]=r;}getAllCustomFields(){return {...this.customFields}}};var y={"en-IN":"en","kn-IN":"kn"};var G={INR:"\u20B9"},V={INR:"en-IN"};var v=class extends Error{constructor(e="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${e}`),this.name="SelectionAttributeParseError";}};var w=class extends Error{constructor(e="Tax category is not valid."){super(`InvalidTaxCategory: ${e}`),this.name="InvalidTaxCategoryError";}},M=class extends Error{constructor(e="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${e}`),this.name="InvalidMinQuantityError";}},E=class extends Error{constructor(e){super(`InvalidTieredPrice: ${e}`),this.name="InvalidTieredPriceError";}},L=class extends Error{constructor(e="Quantity must be greater than zero."){super(`InvalidQuantity: ${e}`),this.name="InvalidQuantityError";}},N=class extends Error{constructor(e){super(`NoApplicableTier: Quantity ${e} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}};var I=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},b=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},p=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},g=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}},x=class extends Error{constructor(e="Invalid image source configuration."){super(`InvalidImageSource: ${e}`),this.name="InvalidImageSourceError";}};var A=class{sources;alt;order;label;constructor(e){if(this.sources={...e.sources},this.alt=e.alt,this.order=e.order,this.label=e.label,!this.sources.original)throw new x("ImageInfoModel cannot be created without an 'original' source URL.")}getSources(){return {...this.sources}}getSource(e){return this.sources[e]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(e){this.alt=e;}setOrder(e){this.order=e;}setLabel(e){this.label=e;}setSource(e,r){if(r===void 0){if(e==="original")throw new x("Cannot remove the 'original' image source.");delete this.sources[e];}else this.sources[e]=r;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var C=class t{amount;currency;constructor(e){if(e.amount<0)throw new I("Amount cannot be negative.");if(!e.currency)throw new b("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 p("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new p("Cannot add prices in different currencies.")}else throw new g("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 p("Cannot subtract prices in different currencies.")}else throw new g("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 p("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 g("Must be a non-negative number.")}divide(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new p("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 g("Must be a positive number.")}min(...e){if(e.length===0)throw new g("Must provide at least one PriceModel.");return e.reduce((r,i)=>{if(i instanceof t){if(r.getCurrency()!==i.getCurrency())throw new p("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return r.compareTo(i)<0?r:i})}max(...e){if(e.length===0)throw new g("Must provide at least one PriceModel.");return e.reduce((r,i)=>{if(i instanceof t){if(r.getCurrency()!==i.getCurrency())throw new p("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return r.compareTo(i)>0?r:i})}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,i={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let n=V[r];if(!r||!n)throw new b("Invalid currency code for formatting.");let o=e,d=i.displayAsInteger?0:t.getDecimalPlaces(r),f={style:i.style??"currency",currency:r,signDisplay:"never",currencyDisplay:i.currencyDisplay,minimumFractionDigits:d,maximumFractionDigits:d};i.displayAsInteger&&(o=Math.ceil(o));try{return new Intl.NumberFormat(n,f).format(o)}catch(u){return console.error(`Error formatting price for currency "${r}" and locale "${n}":`,u),`${G[r]??r} ${t.addThousandSeparators(o.toFixed(d))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let r=e.split("."),i=r[0],n=r.length>1?"."+r[1]:"";return i.replace(/\B(?=(\d{3})+(?!\d))/g,",")+n}static getRoundedAmount(e,r){if(e<0)throw new I("Amount cannot be negative for rounding.");if(r===void 0)throw new b("Invalid currency code for rounding.");let i=t.getDecimalPlaces(r),n=Math.pow(10,i);return Math.round(e*n)/n}};var R=class{baseUnitPrice;taxCategory;tiers;constructor(e){let r=new C(e.baseUnitPrice);if(!e.taxCategory)throw new w;let i=(e.tiers??[]).map(u=>({minQuantity:u.minQuantity,unitPrice:new C(u.unitPrice)})).sort((u,l)=>u.minQuantity-l.minQuantity);if(i.some(u=>u.minQuantity<=0))throw new M;let o=i.some(u=>u.unitPrice.getCurrency()!==r.getCurrency()),d=i.some((u,l)=>l>0&&u.unitPrice.compareTo(i[l-1].unitPrice)>0),f=i[0]?.unitPrice.compareTo(r)>0;if(o||d||f)throw new E("Tiers must share the same currency and must not increase in unit price.");this.baseUnitPrice=r,this.taxCategory=e.taxCategory,this.tiers=i;}getBaseUnitPrice(){return this.baseUnitPrice}getTaxCategory(){return this.taxCategory}getTiers(){return this.tiers}getDetails(){return {baseUnitPrice:this.baseUnitPrice.getDetails(),taxCategory:this.taxCategory,tiers:this.tiers.map(e=>({minQuantity:e.minQuantity,unitPrice:e.unitPrice.getDetails()}))}}getApplicableTier(e){if(e<=0)throw new L;for(let r=this.tiers.length-1;r>=0;r--)if(e>=this.tiers[r].minQuantity)return this.tiers[r];throw new N(e)}getMinQuantity(){return this.tiers[0]?.minQuantity??1}getMaxDiscountPercent(){if(!this.tiers.length)return 0;let e=this.tiers[this.tiers.length-1].unitPrice.getAmount(),r=this.baseUnitPrice.getAmount();return (r-e)/r*100}};var m=class t extends h{id;key;sku;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(e){return Object.keys(e).filter(i=>e[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>e[i].name?`${i}:c+${e[i].name}`:`${i}:${e[i]}`).join("|")}static parseSelectionAttributesKey(e){try{let r={},i=e.split("|");for(let n of i){let[o,d]=n.split(":");d.startsWith("c+")?r[o]={name:d.slice(2)}:r[o]=d;}return r}catch(r){throw new v(r?.message)}}constructor(e,r=new Date){super(e,r),this.id=e.id,this.key=e.key,this.sku=e.sku,this.name={...e.name},this.description={...e.description},this.slug={...e.slug},this.brand=e.brand,this.pricing=Object.keys(e.pricing).reduce((i,n)=>(e.pricing[n]&&(i[n]=new R(e.pricing[n])),i),{}),this.targetGender=e.targetGender,this.attributes=c.deepClone(e.attributes),this.specifications=c.deepClone(e.specifications),this.categories=c.deepClone(e.categories),this.variants=(e.variants||[]).map(i=>({selectionAttributes:i.selectionAttributes,images:{primary:new A(i.images.primary),gallery:(i.images.gallery||[]).map(n=>new A(n))}})),this.isActive=e.isActive,this.searchTags=e.searchTags?c.deepClone(e.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getSku(){return this.sku}getName(e){return e?this.name[e]??this.name[y[e]]??this.name.en:c.deepClone(this.name)}getDescription(e){return e?this.description[e]??this.description[y[e]]??this.description.en:c.deepClone(this.description)}getSlug(e){return e?this.slug[e]??this.slug[y[e]]??this.slug.en:c.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:this.pricing}getAttributes(){return c.deepClone(this.attributes)}getImagesBySelectionAttributes(e){let r=t.generateSelectionAttributesKey(e),i=this.variants.find(n=>t.generateSelectionAttributesKey(n.selectionAttributes)===r);return i?i.images:null}getImages(e,r){switch(r){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return c.deepClone(this.categories)}getSpecifications(e){return e?c.deepClone(this.specifications[e]??this.specifications[y[e]]??this.specifications.en):c.deepClone(this.specifications)}getSearchTags(e){return e?c.deepClone(this.searchTags[e]??this.searchTags[y[e]]??this.searchTags.en):c.deepClone(this.searchTags)}getDetails(){let e=super.getDetails();return {id:this.getId(),key:this.getKey(),sku:this.getSku(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((r,i)=>(this.pricing[i]&&(r[i]=this.pricing[i]?.getDetails()),r),{}),attributes:this.getAttributes(),variants:this.variants.map(r=>({selectionAttributes:c.deepClone(r.selectionAttributes),images:{primary:r.images.primary.getDetails(),gallery:r.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}validateSelectionAttribute(e){let r=t.generateSelectionAttributesKey(e);return this.variants.some(i=>t.generateSelectionAttributesKey(i.selectionAttributes)===r)}validateSize(e){return this.attributes.size.includes(e)}};var ie={isUUID:t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t),isEmail:t=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t),isURL:t=>/^(http|https):\/\/[^ "]+$/.test(t),generateUUID:(t,e)=>e&&t?O(t,e):z(),generateSearchId:(t,e)=>`${t}#${m.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:t=>{let[e,r]=t.split("#");return {key:e,selectionAttribute:r}},deepClone(t){return structuredClone(t)}},c=ie;var Y=class extends h{productKey;stocks;constructor(e){super(e),this.productKey=e.productKey,this.stocks=e.stocks.map(r=>({selectionAttribute:c.deepClone(r.selectionAttribute),size:r.size,available:r.available,country:r.country}));}getProductKey(){return this.productKey}getStockData(e,r,i){let n=e?m.generateSelectionAttributesKey(e):void 0;return this.stocks.filter(o=>!(n&&m.generateSelectionAttributesKey(o.selectionAttribute)!==n||r&&o.size!==r||i&&o.country!==i))}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),stocks:this.getStockData()}}};exports.InventoryModel=Y;//# sourceMappingURL=Inventory.js.map
2
2
  //# sourceMappingURL=Inventory.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Classes/Base.ts","../../src/Classes/Inventory.ts"],"names":["BaseModel","data","date","id","authType","requestId","lambdaName","fieldName","value","InventoryModel","item","size","country"],"mappings":"aA4BA,IAAqBA,CAArB,CAAA,KAA+B,CACnB,YAAA,CACA,QACA,SACA,CAAA,UAAA,CACA,UAQV,CAAA,WAAA,CAAYC,EAAsBC,CAAa,CAAA,IAAI,IAAQ,CAAA,CACzD,KAAK,YAAe,CAAA,CAAE,GAAGD,CAAAA,CAAK,YAAa,CAAA,CAC3C,IAAK,CAAA,OAAA,CAAUA,EAAK,OAAW,EAAA,CAAA,CAC/B,IAAK,CAAA,SAAA,CAAYA,EAAK,SAAa,EAAA,CAAC,KAAM,CAAA,IAAA,CAAK,MAAMA,CAAK,CAAA,SAAS,CAAC,CAAA,CAElE,IAAI,IAAA,CAAKA,CAAK,CAAA,SAAS,EAAE,WAAY,EAAA,CAErCC,CAAK,CAAA,WAAA,GACP,IAAK,CAAA,UAAA,CAAaD,CAAK,CAAA,UAAA,EAAc,CAAC,KAAM,CAAA,IAAA,CAAK,KAAMA,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AA,CAAK,YAAa,CAChC,CACF,CC9IO,CAAA,IAAMC,CAAN,CAAA,cAA6BT,CAAU,CAClC,UAAA,CACA,SACA,CAAA,MAAA,CAEV,WAAYC,CAAAA,CAAAA,CAA2B,CACrC,KAAA,CAAMA,CAAI,CACV,CAAA,IAAA,CAAK,UAAaA,CAAAA,CAAAA,CAAK,WACvB,IAAK,CAAA,SAAA,CAAYA,CAAK,CAAA,SAAA,CACtB,KAAK,MAASA,CAAAA,CAAAA,CAAK,MAAO,CAAA,GAAA,CAAIS,CAAS,GAAA,CACrC,IAAMA,CAAAA,CAAAA,CAAK,KACX,SAAWA,CAAAA,CAAAA,CAAK,SAChB,CAAA,OAAA,CAASA,EAAK,OAChB,CAAA,CAAE,EACJ,CAEA,eAAwB,CACtB,OAAO,IAAK,CAAA,UACd,CAEA,YAAA,EAAuB,CACrB,OAAO,KAAK,SACd,CAEA,YAA4B,EAAA,CAC1B,OAAO,CAAC,GAAG,IAAK,CAAA,MAAM,CACxB,CAEA,cAAA,CAAeC,CAAcC,CAAAA,CAAAA,CAAwC,CACnE,OAAO,IAAK,CAAA,MAAA,CAAO,KAAKF,CAAQA,EAAAA,CAAAA,CAAK,IAASC,GAAAA,CAAAA,EAAQD,EAAK,OAAYE,GAAAA,CAAO,CAChF,CAEA,YAA4B,CAC1B,OAAO,CACL,GAAG,MAAM,UAAW,EAAA,CACpB,UAAY,CAAA,IAAA,CAAK,eACjB,CAAA,SAAA,CAAW,IAAK,CAAA,YAAA,GAChB,MAAQ,CAAA,IAAA,CAAK,YAAa,EAC5B,CACF,CACF","file":"Inventory.js","sourcesContent":["import { AuthType } from \"../Auth\";\r\nimport { ISODateTime } 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?: ISODateTime;\r\n modifiedAt?: ISODateTime;\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: ISODateTime;\r\n protected modifiedAt: ISODateTime;\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","import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CountryCode } from \"./Common\";\r\n\r\nexport type StockData = {\r\n size: string;\r\n available: number;\r\n country: CountryCode;\r\n}\r\n\r\nexport type InventoryAttributes = BaseAttributes & {\r\n productKey: string;\r\n variantId: string;\r\n stocks: StockData[];\r\n}\r\nexport type InventoryData = BaseData & InventoryAttributes;\r\n\r\nexport class InventoryModel extends BaseModel {\r\n protected productKey: string;\r\n protected variantId: string;\r\n protected stocks: StockData[];\r\n\r\n constructor(data: InventoryAttributes) {\r\n super(data);\r\n this.productKey = data.productKey;\r\n this.variantId = data.variantId;\r\n this.stocks = data.stocks.map(item => ({\r\n size: item.size,\r\n available: item.available,\r\n country: item.country\r\n }));\r\n }\r\n\r\n getProductKey(): string {\r\n return this.productKey;\r\n }\r\n\r\n getVariantId(): string {\r\n return this.variantId;\r\n }\r\n\r\n getStockData(): StockData[] {\r\n return [...this.stocks];\r\n }\r\n\r\n getStockBySize(size: string, country: string): StockData | undefined {\r\n return this.stocks.find(item => item.size === size && item.country === country);\r\n }\r\n\r\n getDetails(): InventoryData {\r\n return {\r\n ...super.getDetails(),\r\n productKey: this.getProductKey(),\r\n variantId: this.getVariantId(),\r\n stocks: this.getStockData()\r\n };\r\n }\r\n}"]}
1
+ {"version":3,"sources":["../../node_modules/uuid/dist/esm-node/rng.js","../../node_modules/uuid/dist/esm-node/regex.js","../../node_modules/uuid/dist/esm-node/validate.js","../../node_modules/uuid/dist/esm-node/stringify.js","../../node_modules/uuid/dist/esm-node/parse.js","../../node_modules/uuid/dist/esm-node/v35.js","../../node_modules/uuid/dist/esm-node/native.js","../../node_modules/uuid/dist/esm-node/v4.js","../../node_modules/uuid/dist/esm-node/sha1.js","../../node_modules/uuid/dist/esm-node/v5.js","../../src/Classes/Base.ts","../../src/Classes/Enum.ts","../../src/Classes/Error.ts","../../src/Classes/ImageInfo.ts","../../src/Classes/Price.ts","../../src/Classes/TieredPrice.ts","../../src/Classes/Product.ts","../../src/Utils/index.ts","../../src/Classes/Inventory.ts"],"names":["rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","v","parse_default","stringToBytes","str","bytes","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","_namespace","native_default","v4","options","rnds","v4_default","sha1","sha1_default","v5","v5_default","BaseModel","data","date","id","authType","requestId","lambdaName","fieldName","LocaleLanguageMap","CurrencySymbolMap","CurrencyLocaleMap","SelectionAttributeParseError","message","InvalidTaxCategoryError","InvalidMinQuantityError","InvalidTieredPriceError","InvalidQuantityError","NoApplicableTierError","quantity","InvalidPriceAmountError","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","InvalidImageSourceError","ImageInfoModel","resolutionKey","altText","order","label","url","PriceModel","_PriceModel","priceModel","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","locale","valueToFormat","fractionDigits","formattingOptions","error","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier","TieredPriceModel","baseUnitPrice","tiers","tier","a","b","t","hasDifferentCurrency","hasIrregularPricing","index","basePriceExceedsFirstTier","lowestTierPrice","basePrice","ProductModel","_ProductModel","selectionAttributes","key","attributes","part","acc","country","Utils_default","variant","image","searchKey","match","category","baseDetails","img","size","Utils","selectionAttribute","searchId","obj","InventoryModel","item","selectionAttributeKey"],"mappings":"qJACA,IAAMA,EAAY,IAAI,UAAA,CAAW,GAAG,CAEhCC,CAAAA,CAAAA,CAAUD,EAAU,MACT,CAAA,SAARE,GAAuB,CAC5B,OAAID,EAAUD,CAAU,CAAA,MAAA,CAAS,KAC/BG,kBAAO,CAAA,cAAA,CAAeH,CAAS,CAAA,CAC/BC,EAAU,CAGLD,CAAAA,CAAAA,CAAAA,CAAU,MAAMC,CAASA,CAAAA,CAAAA,EAAW,EAAE,CAC/C,CCXA,IAAOG,CAAQ,CAAA,qHAAA,CCEf,SAASC,CAASC,CAAAA,CAAAA,CAAM,CACtB,OAAO,OAAOA,GAAS,QAAYF,EAAAA,CAAAA,CAAM,IAAKE,CAAAA,CAAI,CACpD,CAEA,IAAOC,EAAQF,CCAf,CAAA,IAAMG,EAAY,EAAC,CAEnB,QAASC,CAA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ASN,CACtBT,EAAAA,CAAAA,EAAWe,EAAK,OAAYf,GAAAA,CAAAA,CAEjC,CACH,CAMA,UAAA,EAA4B,CAC1B,OAAO,CACL,GAAG,KAAM,CAAA,UAAA,GACT,UAAY,CAAA,IAAA,CAAK,eACjB,CAAA,MAAA,CAAQ,KAAK,YAAa,EAC5B,CACF,CACF","file":"Inventory.js","sourcesContent":["import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","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","/**\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}","export enum ImageResolution {\r\n THUMBNAIL = 'thumbnail',\r\n SMALL = 'small',\r\n MEDIUM = 'medium',\r\n LARGE = 'large',\r\n ORIGINAL = 'original',\r\n}\r\n\r\nimport { InvalidImageSourceError } from \"./Error\";\r\n\r\nexport type ImageInfoAttribute = {\r\n sources: { [key in ImageResolution]?: string } & { original: string };\r\n alt?: string;\r\n order?: number;\r\n label?: string;\r\n};\r\n\r\nexport type ImageInfoData = ImageInfoAttribute;\r\n\r\n/**\r\n * Represents and manages structured image data, including multiple resolutions.\r\n */\r\nexport default class ImageInfoModel {\r\n protected sources: { [key in ImageResolution]?: string } & { original: string };\r\n protected alt?: string;\r\n protected order?: number;\r\n protected label?: string;\r\n\r\n /**\r\n * Creates an instance of ImageInfoModel.\r\n * @param data - The initial image data.\r\n */\r\n constructor(data: ImageInfoAttribute) {\r\n this.sources = { ...data.sources };\r\n this.alt = data.alt;\r\n this.order = data.order;\r\n this.label = data.label;\r\n\r\n if (!this.sources.original) {\r\n throw new InvalidImageSourceError(\"ImageInfoModel cannot be created without an 'original' source URL.\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sources object containing URLs for different resolutions.\r\n * Returns a copy to prevent external modification.\r\n */\r\n getSources() {\r\n return { ...this.sources };\r\n }\r\n\r\n /**\r\n * Gets the URL for a specific resolution key.\r\n * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').\r\n * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.\r\n */\r\n getSource(resolutionKey: ImageResolution): string {\r\n return this.sources[resolutionKey] || this.sources.original;\r\n }\r\n\r\n /**\r\n * Gets the alternative text for the image.\r\n */\r\n getAlt(): string | undefined {\r\n return this.alt;\r\n }\r\n\r\n /**\r\n * Gets the display order number for the image.\r\n */\r\n getOrder(): number | undefined {\r\n return this.order;\r\n }\r\n\r\n /**\r\n * Gets the display label or caption for the image.\r\n */\r\n getLabel(): string | undefined {\r\n return this.label;\r\n }\r\n\r\n /**\r\n * Sets the alternative text for the image.\r\n * @param altText - The new alt text.\r\n */\r\n setAlt(altText: string | undefined): void {\r\n this.alt = altText;\r\n // Potentially add logic here to trigger updates if needed\r\n }\r\n\r\n /**\r\n * Sets the display order for the image.\r\n * @param order - The new order number.\r\n */\r\n setOrder(order: number | undefined): void {\r\n this.order = order;\r\n }\r\n\r\n /**\r\n * Sets the display label for the image.\r\n * @param label - The new label text.\r\n */\r\n setLabel(label: string | undefined): void {\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Updates or adds a URL for a specific resolution.\r\n * @param resolutionKey - The key of the resolution to update/add.\r\n * @param url - The URL for the resolution. Set to undefined to remove.\r\n */\r\n setSource(resolutionKey: ImageResolution, url: string | undefined): void {\r\n if (url === undefined) {\r\n // Prevent deleting the 'original' key if it's required\r\n if (resolutionKey === 'original') {\r\n throw new InvalidImageSourceError(\"Cannot remove the 'original' image source.\");\r\n }\r\n delete this.sources[resolutionKey];\r\n } else {\r\n this.sources[resolutionKey] = url;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a plain JavaScript object representation of the image info.\r\n */\r\n getDetails(): ImageInfoData {\r\n return {\r\n sources: this.getSources(),\r\n alt: this.getAlt(),\r\n order: this.getOrder(),\r\n label: this.getLabel(),\r\n };\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","import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { Color, LocalizedString, CountryCode, LocaleCode, LocalizedValue, Prettify } from './Common';\r\nimport { GenderCategory, ImageCategory, LocaleLanguageMap } from \"./Enum\";\r\nimport { SelectionAttributeParseError } from \"./Error\";\r\nimport ImageInfoModel, { ImageInfoData } from \"./ImageInfo\";\r\nimport { TieredPriceModel, TieredPriceAttributes, TieredPriceData } from \"./TieredPrice\";\r\n\r\nexport type ProductSelectionAttributes = Prettify<{\r\n color: Color[];\r\n size: string[];\r\n} & {\r\n [key: string]: string | string[] | Color[];\r\n}>;\r\n\r\nexport type SelectionAttributes = {\r\n color: Color;\r\n [key: string]: string | Color;\r\n};\r\n\r\nexport type VariantData = {\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoData;\r\n gallery: ImageInfoData[];\r\n };\r\n};\r\n\r\nexport type VariantModel = {\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoModel;\r\n gallery: ImageInfoModel[];\r\n };\r\n};\r\n\r\n\r\nexport type ProductSpecification = { [key: string]: string | string[] };\r\n\r\nexport type ProductAttributes = BaseAttributes & {\r\n id: string;\r\n key: string;\r\n sku: string;\r\n\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n slug: LocalizedString;\r\n brand: string;\r\n\r\n pricing: {\r\n [country in CountryCode]?: TieredPriceAttributes;\r\n };\r\n\r\n targetGender: GenderCategory;\r\n attributes: ProductSelectionAttributes;\r\n specifications: LocalizedValue<ProductSpecification>;\r\n categories: string[];\r\n\r\n variants: VariantData[];\r\n\r\n // Metadata\r\n isActive: boolean;\r\n searchTags?: LocalizedValue<string[]>;\r\n};\r\n\r\nexport type ProductData = Required<ProductAttributes>\r\n\r\nexport default class ProductModel extends BaseModel {\r\n protected id: string;\r\n protected key: string;\r\n protected sku: string;\r\n\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected slug: LocalizedString;\r\n protected brand: string;\r\n\r\n protected pricing: {\r\n [country in CountryCode]?: TieredPriceModel;\r\n };\r\n\r\n protected variants: VariantModel[];\r\n\r\n protected targetGender: GenderCategory;\r\n protected attributes: ProductSelectionAttributes;\r\n protected specifications: LocalizedValue<ProductSpecification>;\r\n protected categories: string[];\r\n\r\n // Metadata\r\n protected isActive: boolean;\r\n\r\n protected searchTags: LocalizedValue<string[]>;\r\n\r\n static productKeyRegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n\r\n /**\r\n * Generates a unique key for checking uniqueness for a given selection attributes.\r\n * Excludes 'size' from the key generation.\r\n * @param selectionAttributes - The selection attributes.\r\n * @returns A string key representing the unique attribute combination.\r\n */\r\n static generateSelectionAttributesKey(selectionAttributes: SelectionAttributes): string {\r\n const sortedKeys = Object.keys(selectionAttributes)\r\n .filter(key => selectionAttributes[key] !== undefined && key.toLowerCase() !== 'size')\r\n .sort()\r\n\r\n return sortedKeys.map(key => {\r\n if ((selectionAttributes[key] as Color).name) {\r\n return `${key}:c+${(selectionAttributes[key] as Color).name}`;\r\n }\r\n return `${key}:${selectionAttributes[key]}`;\r\n }).join('|');\r\n }\r\n\r\n /**\r\n * Parses a selection attributes key into an object.\r\n * @param key - The selection attributes key to parse.\r\n * @returns An object containing the parsed selection attributes.\r\n */\r\n static parseSelectionAttributesKey(key: string): SelectionAttributes {\r\n try {\r\n const attributes: SelectionAttributes = {} as unknown as SelectionAttributes;\r\n const parts = key.split('|');\r\n for (const part of parts) {\r\n const [key, value] = part.split(':');\r\n if (value.startsWith('c+')) {\r\n attributes[key] = { name: value.slice(2) } as Color;\r\n } else {\r\n attributes[key] = value;\r\n }\r\n }\r\n return attributes;\r\n } catch (error: any) {\r\n throw new SelectionAttributeParseError(error?.message);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of ProductModel.\r\n * Initializes properties based on the provided data, creating copies where necessary.\r\n * @param data - The initial product attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: ProductAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.id = data.id;\r\n this.key = data.key;\r\n this.sku = data.sku;\r\n\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.slug = { ...data.slug };\r\n this.brand = data.brand;\r\n\r\n this.pricing = (Object.keys(data.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (data.pricing[country]) {\r\n acc[country] = new TieredPriceModel(data.pricing[country]);\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]?: TieredPriceModel });\r\n\r\n this.targetGender = data.targetGender;\r\n this.attributes = Utils.deepClone(data.attributes);\r\n this.specifications = Utils.deepClone(data.specifications);\r\n this.categories = Utils.deepClone(data.categories);\r\n\r\n this.variants = (data.variants || []).map(variant => ({\r\n selectionAttributes: variant.selectionAttributes,\r\n images: {\r\n primary: new ImageInfoModel(variant.images.primary),\r\n gallery: (variant.images.gallery || []).map(image => new ImageInfoModel(image))\r\n }\r\n }));\r\n\r\n this.isActive = data.isActive;\r\n this.searchTags = data.searchTags ? Utils.deepClone(data.searchTags) : { en: [] };\r\n }\r\n\r\n /**\r\n * Gets the base Product ID.\r\n * @returns Product ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the user-friendly product key.\r\n * @returns Product Key.\r\n */\r\n getKey(): string {\r\n return this.key;\r\n }\r\n\r\n /**\r\n * Gets the SKU for the product.\r\n * @returns SKU string.\r\n */\r\n getSku(): string {\r\n return this.sku;\r\n }\r\n\r\n /**\r\n * Gets the full localized product name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the product name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return Utils.deepClone(this.name);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product description object.\r\n * @returns A copy of the LocalizedString object for the description.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the product description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return Utils.deepClone(this.description);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product slug object.\r\n * @returns A copy of the LocalizedString object for the slug.\r\n */\r\n getSlug(): LocalizedString\r\n /**\r\n * Gets the product slug for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The slug string for the specified locale.\r\n */\r\n getSlug(locale: LocaleCode): string\r\n getSlug(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.slug[locale] ?? this.slug[LocaleLanguageMap[locale]] ?? this.slug.en;\r\n } else {\r\n return Utils.deepClone(this.slug);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the brand associated with the product.\r\n * @returns The brand name string.\r\n */\r\n getBrand(): string {\r\n return this.brand;\r\n }\r\n\r\n /**\r\n * Gets the tiered price details for the product.\r\n * @returns Pricing details mapped by country.\r\n */\r\n getPriceDetails(): { [country in CountryCode]?: TieredPriceModel }\r\n /**\r\n * Gets the tiered price details for a specific country.\r\n * @param country - The country code.\r\n * @returns The tiered price model for the country, or null if not found.\r\n */\r\n getPriceDetails(country: CountryCode): TieredPriceModel | null\r\n getPriceDetails(country?: CountryCode): { [country in CountryCode]?: TieredPriceModel } | TieredPriceModel | null {\r\n if (country) {\r\n return this.pricing[country] ?? null;\r\n }\r\n return this.pricing;\r\n }\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getAttributes(): ProductSelectionAttributes {\r\n return Utils.deepClone(this.attributes);\r\n }\r\n\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n private getImagesBySelectionAttributes(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | null {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n const match = this.variants.find(variant =>\r\n ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey\r\n );\r\n\r\n return match ? match.images : null;\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n getImages(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] }\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.PRIMARY): ImageInfoModel\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.GALLERY): ImageInfoModel[]\r\n getImages(selectionAttributes: SelectionAttributes, category?: ImageCategory): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | ImageInfoModel | ImageInfoModel[] {\r\n switch (category) {\r\n case ImageCategory.PRIMARY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.primary ?? this.variants[0]?.images?.primary;\r\n case ImageCategory.GALLERY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.gallery ?? [];\r\n default:\r\n return this.getImagesBySelectionAttributes(selectionAttributes) ?? { primary: this.variants[0]?.images?.primary, gallery: [] };\r\n }\r\n }\r\n\r\n\r\n /**\r\n * Checks if the product is active.\r\n * @returns True if the product is active, false otherwise.\r\n */\r\n getIsActive(): boolean {\r\n return this.isActive;\r\n }\r\n\r\n /**\r\n * Gets the target gender category for the product.\r\n * @returns The GenderCategory enum value.\r\n */\r\n getTargetGender(): GenderCategory {\r\n return this.targetGender;\r\n }\r\n\r\n /**\r\n * Gets the list of categories the product belongs to. Returns a copy.\r\n * @returns An array of category.\r\n */\r\n getCategories(): string[] {\r\n return Utils.deepClone(this.categories);\r\n }\r\n\r\n /**\r\n * Gets the full localized product specifications object.\r\n * @returns Product Specifications\r\n */\r\n getSpecifications(): LocalizedValue<ProductSpecification>\r\n /**\r\n * Gets the product specifications for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The ProductSpecification object for the specified locale, or undefined if not found.\r\n */\r\n getSpecifications(locale: LocaleCode): ProductSpecification | undefined\r\n getSpecifications(locale?: LocaleCode): LocalizedValue<ProductSpecification> | ProductSpecification | undefined {\r\n if (locale) {\r\n return Utils.deepClone(this.specifications[locale] ?? this.specifications[LocaleLanguageMap[locale]] ?? this.specifications.en);\r\n } else {\r\n return Utils.deepClone(this.specifications);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the localized list of search tags. Returns a copy.\r\n * @returns Localized array of search tags.\r\n */\r\n getSearchTags(): LocalizedValue<string[]>\r\n /**\r\n * Gets the search tags for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The array of search tags for the specified locale, or undefined if not found.\r\n */\r\n getSearchTags(locale: LocaleCode): string[] | undefined\r\n getSearchTags(locale?: LocaleCode): LocalizedValue<string[]> | string[] | undefined {\r\n if (locale) {\r\n return Utils.deepClone(this.searchTags[locale] ?? this.searchTags[LocaleLanguageMap[locale]] ?? this.searchTags.en);\r\n } else {\r\n return Utils.deepClone(this.searchTags);\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @returns ProductData\r\n */\r\n getDetails(): ProductData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n id: this.getId(),\r\n key: this.getKey(),\r\n sku: this.getSku(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n slug: this.getSlug(),\r\n brand: this.getBrand(),\r\n pricing: (Object.keys(this.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (this.pricing[country]) {\r\n acc[country] = this.pricing[country]?.getDetails();\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]: TieredPriceData }),\r\n attributes: this.getAttributes(),\r\n variants: this.variants.map(v => ({\r\n selectionAttributes: Utils.deepClone(v.selectionAttributes),\r\n images: {\r\n primary: v.images.primary.getDetails(),\r\n gallery: v.images.gallery.map(img => img.getDetails())\r\n }\r\n })),\r\n isActive: this.getIsActive(),\r\n targetGender: this.getTargetGender(),\r\n categories: this.getCategories(),\r\n specifications: this.getSpecifications(),\r\n searchTags: this.getSearchTags(),\r\n ...baseDetails\r\n };\r\n }\r\n\r\n\r\n /**\r\n * Validates if the provided selection attributes exist for this product.\r\n * @param selectionAttributes - The attributes to validate.\r\n * @returns True if a valid selection attribute exists, false otherwise.\r\n */\r\n validateSelectionAttribute(selectionAttributes: SelectionAttributes): boolean {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n return this.variants.some(variant => ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey);\r\n }\r\n\r\n /**\r\n * Validates if a specific size is available for this product.\r\n * @param size - The size to check.\r\n * @returns True if the size exists in the product's attributes, false otherwise.\r\n */\r\n validateSize(size: string): boolean {\r\n return this.attributes.size.includes(size);\r\n }\r\n}","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\nimport ProductModel, { SelectionAttributes } from '../Classes/Product';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, selectionAttribute: SelectionAttributes) => {\r\n return `${key}#${ProductModel.generateSelectionAttributesKey(selectionAttribute)}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, selectionAttribute] = searchId.split('#');\r\n return {\r\n key,\r\n selectionAttribute\r\n }\r\n },\r\n\r\n deepClone<T>(obj: T): T {\r\n return structuredClone(obj);\r\n }\r\n}\r\n\r\nexport default Utils;\r\n","import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CountryCode } from \"./Common\";\r\nimport ProductModel, { SelectionAttributes } from \"./Product\";\r\n\r\nexport type StockData = {\r\n selectionAttribute: SelectionAttributes;\r\n size: string;\r\n available: number;\r\n country: CountryCode;\r\n}\r\n\r\nexport type InventoryAttributes = BaseAttributes & {\r\n productKey: string;\r\n stocks: StockData[];\r\n}\r\nexport type InventoryData = BaseData & InventoryAttributes;\r\n\r\nexport class InventoryModel extends BaseModel {\r\n protected productKey: string;\r\n protected stocks: StockData[];\r\n\r\n /**\r\n * Creates an instance of InventoryModel.\r\n * @param data - The initial inventory attributes.\r\n */\r\n constructor(data: InventoryAttributes) {\r\n super(data);\r\n this.productKey = data.productKey;\r\n this.stocks = data.stocks.map(item => ({\r\n selectionAttribute: Utils.deepClone(item.selectionAttribute),\r\n size: item.size,\r\n available: item.available,\r\n country: item.country\r\n }));\r\n }\r\n\r\n /**\r\n * Gets the product key associated with this inventory.\r\n * @returns The product key string.\r\n */\r\n getProductKey(): string {\r\n return this.productKey;\r\n }\r\n\r\n /**\r\n * Retrieves stock information for a specific size and country.\r\n * @param selectionAttribute - The selection attributes to filter by.\r\n * @param size - The size to filter by.\r\n * @param country - The country to filter by.\r\n * @returns An array of StockData objects matching the specified criteria.\r\n */\r\n getStockData(selectionAttribute?: SelectionAttributes, size?: string, country?: CountryCode): StockData[] {\r\n let selectionAttributeKey = selectionAttribute ? ProductModel.generateSelectionAttributesKey(selectionAttribute) : undefined;\r\n return this.stocks.filter(item => {\r\n if (selectionAttributeKey && ProductModel.generateSelectionAttributesKey(item.selectionAttribute) !== selectionAttributeKey) return false;\r\n if (size && item.size !== size) return false;\r\n if (country && item.country !== country) return false;\r\n return true;\r\n });\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the inventory's current state.\r\n * @returns InventoryData suitable for serialization.\r\n */\r\n getDetails(): InventoryData {\r\n return {\r\n ...super.getDetails(),\r\n productKey: this.getProductKey(),\r\n stocks: this.getStockData()\r\n };\r\n }\r\n}"]}
@@ -1,2 +1,2 @@
1
- import {a as a$1}from'../chunk-ATUUYYQT.mjs';var a=class extends a$1{productKey;variantId;stocks;constructor(t){super(t),this.productKey=t.productKey,this.variantId=t.variantId,this.stocks=t.stocks.map(r=>({size:r.size,available:r.available,country:r.country}));}getProductKey(){return this.productKey}getVariantId(){return this.variantId}getStockData(){return [...this.stocks]}getStockBySize(t,r){return this.stocks.find(e=>e.size===t&&e.country===r)}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),variantId:this.getVariantId(),stocks:this.getStockData()}}};export{a as InventoryModel};//# sourceMappingURL=Inventory.mjs.map
1
+ import {a as a$2,b}from'../chunk-LNIZAPER.mjs';import'../chunk-KWH7GE23.mjs';import'../chunk-54RUAXYE.mjs';import'../chunk-72DR3HF2.mjs';import'../chunk-NUTKOIGY.mjs';import'../chunk-NJKSUUOB.mjs';import {a as a$1}from'../chunk-55SOBG62.mjs';var a=class extends a$1{productKey;stocks;constructor(e){super(e),this.productKey=e.productKey,this.stocks=e.stocks.map(t=>({selectionAttribute:a$2.deepClone(t.selectionAttribute),size:t.size,available:t.available,country:t.country}));}getProductKey(){return this.productKey}getStockData(e,t,s){let i=e?b.generateSelectionAttributesKey(e):void 0;return this.stocks.filter(r=>!(i&&b.generateSelectionAttributesKey(r.selectionAttribute)!==i||t&&r.size!==t||s&&r.country!==s))}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),stocks:this.getStockData()}}};export{a as InventoryModel};//# sourceMappingURL=Inventory.mjs.map
2
2
  //# sourceMappingURL=Inventory.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Classes/Inventory.ts"],"names":["InventoryModel","BaseModel","data","item","size","country"],"mappings":"6CAgBaA,IAAAA,CAAAA,CAAN,cAA6BC,GAAU,CAClC,WACA,SACA,CAAA,MAAA,CAEV,YAAYC,CAA2B,CAAA,CACrC,MAAMA,CAAI,CAAA,CACV,KAAK,UAAaA,CAAAA,CAAAA,CAAK,WACvB,IAAK,CAAA,SAAA,CAAYA,CAAK,CAAA,SAAA,CACtB,IAAK,CAAA,MAAA,CAASA,EAAK,MAAO,CAAA,GAAA,CAAIC,IAAS,CACrC,IAAA,CAAMA,EAAK,IACX,CAAA,SAAA,CAAWA,CAAK,CAAA,SAAA,CAChB,OAASA,CAAAA,CAAAA,CAAK,OAChB,CAAE,CAAA,EACJ,CAEA,aAAwB,EAAA,CACtB,OAAO,IAAK,CAAA,UACd,CAEA,YAAA,EAAuB,CACrB,OAAO,KAAK,SACd,CAEA,cAA4B,CAC1B,OAAO,CAAC,GAAG,IAAA,CAAK,MAAM,CACxB,CAEA,cAAA,CAAeC,EAAcC,CAAwC,CAAA,CACnE,OAAO,IAAK,CAAA,MAAA,CAAO,KAAKF,CAAQA,EAAAA,CAAAA,CAAK,IAASC,GAAAA,CAAAA,EAAQD,CAAK,CAAA,OAAA,GAAYE,CAAO,CAChF,CAEA,YAA4B,CAC1B,OAAO,CACL,GAAG,KAAA,CAAM,UAAW,EAAA,CACpB,UAAY,CAAA,IAAA,CAAK,eACjB,CAAA,SAAA,CAAW,KAAK,YAAa,EAAA,CAC7B,OAAQ,IAAK,CAAA,YAAA,EACf,CACF,CACF","file":"Inventory.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CountryCode } from \"./Common\";\r\n\r\nexport type StockData = {\r\n size: string;\r\n available: number;\r\n country: CountryCode;\r\n}\r\n\r\nexport type InventoryAttributes = BaseAttributes & {\r\n productKey: string;\r\n variantId: string;\r\n stocks: StockData[];\r\n}\r\nexport type InventoryData = BaseData & InventoryAttributes;\r\n\r\nexport class InventoryModel extends BaseModel {\r\n protected productKey: string;\r\n protected variantId: string;\r\n protected stocks: StockData[];\r\n\r\n constructor(data: InventoryAttributes) {\r\n super(data);\r\n this.productKey = data.productKey;\r\n this.variantId = data.variantId;\r\n this.stocks = data.stocks.map(item => ({\r\n size: item.size,\r\n available: item.available,\r\n country: item.country\r\n }));\r\n }\r\n\r\n getProductKey(): string {\r\n return this.productKey;\r\n }\r\n\r\n getVariantId(): string {\r\n return this.variantId;\r\n }\r\n\r\n getStockData(): StockData[] {\r\n return [...this.stocks];\r\n }\r\n\r\n getStockBySize(size: string, country: string): StockData | undefined {\r\n return this.stocks.find(item => item.size === size && item.country === country);\r\n }\r\n\r\n getDetails(): InventoryData {\r\n return {\r\n ...super.getDetails(),\r\n productKey: this.getProductKey(),\r\n variantId: this.getVariantId(),\r\n stocks: this.getStockData()\r\n };\r\n }\r\n}"]}
1
+ {"version":3,"sources":["../../src/Classes/Inventory.ts"],"names":["InventoryModel","BaseModel","data","item","Utils_default","selectionAttribute","size","country","selectionAttributeKey","ProductModel"],"mappings":"kPAkBaA,IAAAA,CAAAA,CAAN,cAA6BC,GAAU,CAClC,WACA,MAMV,CAAA,WAAA,CAAYC,CAA2B,CAAA,CACrC,KAAMA,CAAAA,CAAI,EACV,IAAK,CAAA,UAAA,CAAaA,EAAK,UACvB,CAAA,IAAA,CAAK,OAASA,CAAK,CAAA,MAAA,CAAO,GAAIC,CAAAA,CAAAA,GAAS,CACrC,kBAAA,CAAoBC,IAAM,SAAUD,CAAAA,CAAAA,CAAK,kBAAkB,CAC3D,CAAA,IAAA,CAAMA,EAAK,IACX,CAAA,SAAA,CAAWA,CAAK,CAAA,SAAA,CAChB,OAASA,CAAAA,CAAAA,CAAK,OAChB,CAAE,CAAA,EACJ,CAMA,aAAwB,EAAA,CACtB,OAAO,IAAK,CAAA,UACd,CASA,YAAA,CAAaE,CAA0CC,CAAAA,CAAAA,CAAeC,EAAoC,CACxG,IAAIC,EAAwBH,CAAqBI,CAAAA,CAAAA,CAAa,+BAA+BJ,CAAkB,CAAA,CAAI,KACnH,CAAA,CAAA,OAAO,IAAK,CAAA,MAAA,CAAO,OAAOF,CACpB,EAAA,EAAAK,GAAyBC,CAAa,CAAA,8BAAA,CAA+BN,EAAK,kBAAkB,CAAA,GAAMK,CAClGF,EAAAA,CAAAA,EAAQH,CAAK,CAAA,IAAA,GAASG,GACtBC,CAAWJ,EAAAA,CAAAA,CAAK,UAAYI,CAEjC,CAAA,CACH,CAMA,UAA4B,EAAA,CAC1B,OAAO,CACL,GAAG,KAAA,CAAM,YACT,CAAA,UAAA,CAAY,KAAK,aAAc,EAAA,CAC/B,OAAQ,IAAK,CAAA,YAAA,EACf,CACF,CACF","file":"Inventory.mjs","sourcesContent":["import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport { CountryCode } from \"./Common\";\r\nimport ProductModel, { SelectionAttributes } from \"./Product\";\r\n\r\nexport type StockData = {\r\n selectionAttribute: SelectionAttributes;\r\n size: string;\r\n available: number;\r\n country: CountryCode;\r\n}\r\n\r\nexport type InventoryAttributes = BaseAttributes & {\r\n productKey: string;\r\n stocks: StockData[];\r\n}\r\nexport type InventoryData = BaseData & InventoryAttributes;\r\n\r\nexport class InventoryModel extends BaseModel {\r\n protected productKey: string;\r\n protected stocks: StockData[];\r\n\r\n /**\r\n * Creates an instance of InventoryModel.\r\n * @param data - The initial inventory attributes.\r\n */\r\n constructor(data: InventoryAttributes) {\r\n super(data);\r\n this.productKey = data.productKey;\r\n this.stocks = data.stocks.map(item => ({\r\n selectionAttribute: Utils.deepClone(item.selectionAttribute),\r\n size: item.size,\r\n available: item.available,\r\n country: item.country\r\n }));\r\n }\r\n\r\n /**\r\n * Gets the product key associated with this inventory.\r\n * @returns The product key string.\r\n */\r\n getProductKey(): string {\r\n return this.productKey;\r\n }\r\n\r\n /**\r\n * Retrieves stock information for a specific size and country.\r\n * @param selectionAttribute - The selection attributes to filter by.\r\n * @param size - The size to filter by.\r\n * @param country - The country to filter by.\r\n * @returns An array of StockData objects matching the specified criteria.\r\n */\r\n getStockData(selectionAttribute?: SelectionAttributes, size?: string, country?: CountryCode): StockData[] {\r\n let selectionAttributeKey = selectionAttribute ? ProductModel.generateSelectionAttributesKey(selectionAttribute) : undefined;\r\n return this.stocks.filter(item => {\r\n if (selectionAttributeKey && ProductModel.generateSelectionAttributesKey(item.selectionAttribute) !== selectionAttributeKey) return false;\r\n if (size && item.size !== size) return false;\r\n if (country && item.country !== country) return false;\r\n return true;\r\n });\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the inventory's current state.\r\n * @returns InventoryData suitable for serialization.\r\n */\r\n getDetails(): InventoryData {\r\n return {\r\n ...super.getDetails(),\r\n productKey: this.getProductKey(),\r\n stocks: this.getStockData()\r\n };\r\n }\r\n}"]}
@@ -1,67 +1,102 @@
1
- import { LocalizedString, Color, BasePrice, PriceTier, LocaleCode } from './Common.mjs';
1
+ import { P as PriceData, C as CountryCode, c as LocalizedString, d as LocalizedValue, b as PriceModel, L as LocaleCode, a as CurrencyCode } from '../Common-FbQ5-3QN.mjs';
2
+ import CouponModel from './Coupon.mjs';
3
+ import { TaxCategory, TaxSystem, LineItemState } from './Enum.mjs';
2
4
  import ImageInfoModel, { ImageInfoData } from './ImageInfo.mjs';
3
- import { LocalizedProductSpecification, ProductSpecification } from './Product.mjs';
4
- import './Enum.mjs';
5
+ import ProductModel, { SelectionAttributes, ProductSpecification } from './Product.mjs';
6
+ import { TaxSlabs, TaxRuleModel } from './TaxRule.mjs';
7
+ import { TieredPriceData, TieredPriceModel } from './TieredPrice.mjs';
5
8
  import './Base.mjs';
6
9
  import '../Auth/index.mjs';
7
10
 
8
11
  type SubItem = {
9
- size: string;
12
+ size: string | 'ONESIZE';
10
13
  quantity: number;
11
14
  };
15
+ type LineItemPricing = {
16
+ unitPrice: PriceData;
17
+ tierPricing: TieredPriceData;
18
+ taxCategory: TaxCategory;
19
+ tax: {
20
+ taxRuleId: string;
21
+ taxSystem: TaxSystem;
22
+ country: CountryCode;
23
+ rate: number;
24
+ taxSlabs: TaxSlabs;
25
+ };
26
+ };
27
+ type LineItemTotals = {
28
+ quantity: number;
29
+ subtotal: PriceData;
30
+ discounts: Record<string, PriceData>;
31
+ taxableAmount: PriceData;
32
+ taxTotal: PriceData;
33
+ grandTotal: PriceData;
34
+ };
12
35
  type LineItemAttributes = {
13
36
  id: string;
14
37
  productKey: string;
15
- variantId: string;
38
+ selectionAttribute: SelectionAttributes;
16
39
  name: LocalizedString;
17
- attributes: {
18
- color: Color;
19
- };
20
- specifications: LocalizedProductSpecification;
40
+ specifications: LocalizedValue<ProductSpecification>;
21
41
  primaryImage: ImageInfoData;
22
42
  subItems: SubItem[];
23
- basePrice: BasePrice;
24
- priceTiers: PriceTier[];
25
- };
26
- type LineItemData = LineItemAttributes & {
27
- totalQuantity: number;
28
- priceTotals: {
29
- subtotal: number;
30
- mrpTotal: number;
31
- };
43
+ pricing: LineItemPricing;
44
+ state?: LineItemState;
45
+ total: LineItemTotals;
32
46
  };
47
+ type LineItemData = Required<LineItemAttributes>;
33
48
  /**
34
49
  * Represents a line item within a shopping cart.
35
50
  */
36
51
  declare class LineItemModel {
37
52
  protected id: string;
38
53
  protected productKey: string;
39
- protected variantId: string;
54
+ protected selectionAttribute: SelectionAttributes;
40
55
  protected name: LocalizedString;
41
- protected attributes: {
42
- color: Color;
43
- };
44
- protected specifications: LocalizedProductSpecification;
56
+ protected specifications: LocalizedValue<ProductSpecification>;
45
57
  protected primaryImage: ImageInfoModel;
46
58
  protected subItems: SubItem[];
47
- protected totalQuantity: number;
48
- protected basePrice: BasePrice;
49
- protected priceTotals: {
50
- subtotal: number;
51
- mrpTotal: number;
59
+ protected pricing: {
60
+ unitPrice: PriceModel;
61
+ tierPricing: TieredPriceModel;
62
+ taxCategory: TaxCategory;
63
+ tax: {
64
+ taxRuleId: string;
65
+ taxSystem: TaxSystem;
66
+ country: CountryCode;
67
+ taxSlabs: TaxSlabs;
68
+ rate: number;
69
+ };
70
+ };
71
+ protected state: LineItemState;
72
+ protected total: {
73
+ quantity: number;
74
+ subtotal: PriceModel;
75
+ discounts: Record<string, PriceModel>;
76
+ taxableAmount: PriceModel;
77
+ taxTotal: PriceModel;
78
+ grandTotal: PriceModel;
52
79
  };
53
- protected priceTiers: PriceTier[];
54
80
  /**
55
81
  * Creates an instance of LineItemModel.
56
82
  * @param data - The initial line item attributes.
57
83
  */
58
84
  constructor(data: LineItemAttributes);
59
- /** Gets the unique identifier of the line item. */
85
+ /**
86
+ * Gets the unique identifier of the line item.
87
+ * @returns The unique ID string.
88
+ */
60
89
  getId(): string;
61
- /** Gets the product key associated with this line item. */
90
+ /**
91
+ * Gets the product key associated with this line item.
92
+ * @returns The product key string.
93
+ */
62
94
  getProductKey(): string;
63
- /** Gets the product variant ID associated with this line item. */
64
- getVariantId(): string;
95
+ /**
96
+ * Gets the selection attributes (e.g., size, color) for this line item.
97
+ * @returns A copy of the selection attributes object.
98
+ */
99
+ getSelectionAttribute(): SelectionAttributes;
65
100
  /**
66
101
  * Gets the full localized product name object.
67
102
  * @returns A copy of the LocalizedString object for the name.
@@ -73,45 +108,67 @@ declare class LineItemModel {
73
108
  * @returns The name string for the specified locale.
74
109
  */
75
110
  getName(locale: LocaleCode): string;
76
- /** Gets the variant attributes. */
77
- getAttributes(): {
78
- color: Color;
79
- };
80
111
  /**
81
112
  * Gets the full localized product specifications object.
82
113
  * @returns Product Specifications
83
114
  */
84
- getSpecifications(): LocalizedProductSpecification;
115
+ getSpecifications(): LocalizedValue<ProductSpecification>;
85
116
  /**
86
117
  * Gets the product specifications for a specific locale, falling back to English ('en').
87
118
  * @param locale - The desired locale code.
88
119
  * @returns The ProductSpecification object for the specified locale, or undefined if not found.
89
120
  */
90
121
  getSpecifications(locale: LocaleCode): ProductSpecification | undefined;
91
- /** Gets the image information model for this line item. */
122
+ /**
123
+ * Gets the image information model for this line item.
124
+ * @returns The ImageInfoModel instance.
125
+ */
92
126
  getImage(): ImageInfoModel;
93
- /** Gets the sub-items (size/quantity breakdown). */
127
+ /**
128
+ * Gets the sub-items (size/quantity breakdown).
129
+ * @returns A copy of the array of SubItems.
130
+ */
94
131
  getSubItems(): SubItem[];
95
- /** Gets the total quantity for this line item across all sub-items. */
132
+ /**
133
+ * Gets the total quantity for this line item across all sub-items.
134
+ * @returns The total quantity as a number.
135
+ */
96
136
  getTotalQuantity(): number;
97
- /** Gets the base price for a single unit. */
98
- getBasePrice(): BasePrice;
99
- /** Gets the calculated price details (subtotal, mrpTotal) for this line item. */
100
- getPriceTotals(): {
101
- subtotal: number;
102
- mrpTotal: number;
137
+ /**
138
+ * Gets the pricing information model for this line item.
139
+ * @returns An object containing unit price, tiered pricing, tax category, and tax details.
140
+ */
141
+ getPricing(): {
142
+ unitPrice: PriceModel;
143
+ tierPricing: TieredPriceModel;
144
+ taxCategory: TaxCategory;
145
+ tax: {
146
+ taxRuleId: string;
147
+ taxSystem: TaxSystem;
148
+ country: "IN";
149
+ rate: number;
150
+ taxSlabs: TaxSlabs;
151
+ };
103
152
  };
104
- /** Gets the applicable price tiers for this product variant. */
105
- getPriceTiers(): PriceTier[];
106
153
  /**
107
- * Recalculates the total quantity based on the quantities in subItems.
154
+ * Gets the current state of the line item.
155
+ * @returns The LineItemState enum value.
108
156
  */
109
- protected recalculateTotalQuantity(): void;
157
+ getState(): LineItemState;
110
158
  /**
111
- * Recalculates the line item's price (subtotal and mrpTotal)
112
- * based on total quantity, base price, and applicable price tiers.
159
+ * Gets the total price for this line item (including all sub-items).
160
+ * @returns An object containing line item totals including subtotal, tax, discounts, and grand total.
113
161
  */
114
- protected recalculatePriceTotal(): void;
162
+ getTotal(): {
163
+ quantity: number;
164
+ subtotal: PriceModel;
165
+ taxableAmount: PriceModel;
166
+ taxTotal: PriceModel;
167
+ discounts: {
168
+ [k: string]: PriceModel;
169
+ };
170
+ grandTotal: PriceModel;
171
+ };
115
172
  /**
116
173
  * Gets a plain data object representing the line item's details.
117
174
  * @returns LineItemData.
@@ -122,19 +179,44 @@ declare class LineItemModel {
122
179
  * If a sub-item with the same size already exists, its quantity is either
123
180
  * updated by adding the new quantity or replaced entirely, based on the `addQuantity` flag.
124
181
  * Sub-items with a resulting quantity of 0 are removed.
125
- * Recalculates total quantity and price totals afterwards.
126
- *
127
182
  * @param subItems - An array of `SubItem` objects to add or update.
128
183
  * @param addQuantity - If true, adds the quantity from `subItem` to the existing quantity.
129
184
  * If false, replaces the existing quantity with the one from `subItem`.
130
185
  */
131
186
  addSubItems(subItems: SubItem[], addQuantity: boolean): void;
187
+ /**
188
+ * Updates the line item with the latest product data (price, image, name, specifications).
189
+ * Validates that the product matches the line item's selection and is active.
190
+ * @param product - The product model to update from.
191
+ * @param cartCountry - The country code for pricing context.
192
+ * @param cartCurrency - The currency code for pricing context.
193
+ * @throws {Error} If product mismatch, inactive, size mismatch, or pricing missing.
194
+ */
195
+ updateProductData(product: ProductModel, cartCountry: CountryCode, cartCurrency: CurrencyCode): void;
196
+ /**
197
+ * Updates the discounts applied to this line item and recalculates totals.
198
+ * @param appliedDiscounts - List of coupons and their allocated discount amounts.
199
+ */
200
+ updateDiscounts(appliedDiscounts: {
201
+ coupon: CouponModel;
202
+ amount: PriceModel;
203
+ }[]): void;
204
+ /**
205
+ * Updates the tax rule for this line item and recalculates totals.
206
+ * @param taxRule - The new tax rule to apply.
207
+ * @throws {Error} If the tax rule category does not match the item's tax category.
208
+ */
209
+ updateTax(taxRule: TaxRuleModel): void;
210
+ /**
211
+ * Recalculates the line item totals based on current quantity, unit price, discounts, and tax rates.
212
+ */
213
+ calculateTotals(): void;
132
214
  /**
133
215
  * Resets the line item's properties to their default empty or initial state.
134
216
  * Useful for clearing out line item data without creating a new instance.
135
- * Recalculates total quantity and price totals afterwards (which will be zero).
217
+ * Recalculates total quantity and price total afterwards (which will be zero).
136
218
  */
137
219
  clearLineItem(): void;
138
220
  }
139
221
 
140
- export { type LineItemAttributes, type LineItemData, type SubItem, LineItemModel as default };
222
+ export { type LineItemAttributes, type LineItemData, type LineItemPricing, type LineItemTotals, type SubItem, LineItemModel as default };