@ubnt/store.core 9.2.0-money.3 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/assets/efg.jpg +0 -0
  3. package/lib/assets/efg.svg +5 -0
  4. package/lib/assets/efgStacked.svg +3 -0
  5. package/lib/assets/gatewayEnterprise.jpg +0 -0
  6. package/lib/assets/gatewayLite.jpg +0 -0
  7. package/lib/assets/gatewayMax.jpg +0 -0
  8. package/lib/assets/gatewayProfessional.jpg +0 -0
  9. package/lib/assets/minus4.svg +8 -8
  10. package/lib/assets/minus5.svg +8 -8
  11. package/lib/assets/nextAi.svg +11 -0
  12. package/lib/assets/plus5.svg +9 -9
  13. package/lib/assets/plus6.svg +9 -9
  14. package/lib/assets/udmPro.jpg +0 -0
  15. package/lib/assets/udmPro2.jpg +0 -0
  16. package/lib/assets/udmProMax.jpg +0 -0
  17. package/lib/assets/udmProMax2.jpg +0 -0
  18. package/lib/assets/udmProSpecial.jpg +0 -0
  19. package/lib/assets/udmProSpecial2.jpg +0 -0
  20. package/lib/components/Header/ProHeader/ProHeader.styles.js +2 -0
  21. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  22. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +3 -1
  23. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  24. package/lib/components/LandingPagePro/LandingPagePro.d.ts +0 -3
  25. package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
  26. package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
  27. package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
  28. package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
  29. package/lib/components/MicrositeHero/MicrositeHero.d.ts +1 -1
  30. package/lib/components/MicrositeHero/MicrositeHero.js +8 -2
  31. package/lib/components/MicrositeHero/MicrositeHero.js.map +1 -1
  32. package/lib/components/MicrositeHero/MicrositeHero.mjs +9 -3
  33. package/lib/components/MicrositeHero/MicrositeHero.mjs.map +1 -1
  34. package/lib/components/MicrositeHero/MicrositeHero.styles.d.ts +1 -0
  35. package/lib/components/MicrositeHero/MicrositeHero.styles.js +21 -5
  36. package/lib/components/MicrositeHero/MicrositeHero.styles.js.map +1 -1
  37. package/lib/components/MicrositeHero/MicrositeHero.styles.mjs +21 -6
  38. package/lib/components/MicrositeHero/MicrositeHero.styles.mjs.map +1 -1
  39. package/lib/components/MicrositeHero/MicrositeHero.types.d.ts +2 -0
  40. package/lib/components/MicrositeHero/MicrositeHero.types.js.map +1 -1
  41. package/lib/components/MicrositeHero/MicrositeHero.types.mjs.map +1 -1
  42. package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +4 -1
  43. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/efg.jpg.js +27 -0
  44. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/efg.jpg.js.map +1 -0
  45. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/efg.jpg.mjs +3 -0
  46. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/efg.jpg.mjs.map +1 -0
  47. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
  48. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
  49. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
  50. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
  51. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
  52. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
  53. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
  54. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
  55. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
  56. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
  57. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
  58. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
  59. package/lib/components/ModelCompareV3/assets/Gateways/gatewayEnterprise.jpg.js +27 -0
  60. package/lib/components/ModelCompareV3/assets/Gateways/gatewayEnterprise.jpg.js.map +1 -0
  61. package/lib/components/ModelCompareV3/assets/Gateways/gatewayEnterprise.jpg.mjs +3 -0
  62. package/lib/components/ModelCompareV3/assets/Gateways/gatewayEnterprise.jpg.mjs.map +1 -0
  63. package/lib/components/ModelCompareV3/assets/nextAi.svg.js +27 -0
  64. package/lib/components/ModelCompareV3/assets/nextAi.svg.js.map +1 -0
  65. package/lib/components/ModelCompareV3/assets/nextAi.svg.mjs +3 -0
  66. package/lib/components/ModelCompareV3/assets/nextAi.svg.mjs.map +1 -0
  67. package/lib/components/ModelCompareV3/data/CloudGateways.js +17 -11
  68. package/lib/components/ModelCompareV3/data/CloudGateways.js.map +1 -1
  69. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +14 -8
  70. package/lib/components/ModelCompareV3/data/CloudGateways.mjs.map +1 -1
  71. package/lib/components/ModelCompareV3/data/Gateway.js +10 -7
  72. package/lib/components/ModelCompareV3/data/Gateway.js.map +1 -1
  73. package/lib/components/ModelCompareV3/data/Gateway.mjs +10 -7
  74. package/lib/components/ModelCompareV3/data/Gateway.mjs.map +1 -1
  75. package/lib/components/ModelCompareV3/data/products/aggregation.js +1 -1
  76. package/lib/components/ModelCompareV3/data/products/aggregation.js.map +1 -1
  77. package/lib/components/ModelCompareV3/data/products/aggregation.mjs +1 -1
  78. package/lib/components/ModelCompareV3/data/products/aggregation.mjs.map +1 -1
  79. package/lib/components/ModelCompareV3/data/products/efg.d.ts +2 -0
  80. package/lib/components/ModelCompareV3/data/products/efg.js +133 -0
  81. package/lib/components/ModelCompareV3/data/products/efg.js.map +1 -0
  82. package/lib/components/ModelCompareV3/data/products/efg.mjs +123 -0
  83. package/lib/components/ModelCompareV3/data/products/efg.mjs.map +1 -0
  84. package/lib/components/ModelCompareV3/data/products/enterprise24PoE.js +1 -1
  85. package/lib/components/ModelCompareV3/data/products/enterprise24PoE.js.map +1 -1
  86. package/lib/components/ModelCompareV3/data/products/enterprise24PoE.mjs +1 -1
  87. package/lib/components/ModelCompareV3/data/products/enterprise24PoE.mjs.map +1 -1
  88. package/lib/components/ModelCompareV3/data/products/enterprise48PoE.js +1 -1
  89. package/lib/components/ModelCompareV3/data/products/enterprise48PoE.js.map +1 -1
  90. package/lib/components/ModelCompareV3/data/products/enterprise48PoE.mjs +1 -1
  91. package/lib/components/ModelCompareV3/data/products/enterprise48PoE.mjs.map +1 -1
  92. package/lib/components/ModelCompareV3/data/products/enterpriseXG24.js +1 -1
  93. package/lib/components/ModelCompareV3/data/products/enterpriseXG24.js.map +1 -1
  94. package/lib/components/ModelCompareV3/data/products/enterpriseXG24.mjs +1 -1
  95. package/lib/components/ModelCompareV3/data/products/enterpriseXG24.mjs.map +1 -1
  96. package/lib/components/ModelCompareV3/data/products/express.js +8 -0
  97. package/lib/components/ModelCompareV3/data/products/express.js.map +1 -1
  98. package/lib/components/ModelCompareV3/data/products/express.mjs +8 -0
  99. package/lib/components/ModelCompareV3/data/products/express.mjs.map +1 -1
  100. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.d.ts +2 -0
  101. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.js +87 -0
  102. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.js.map +1 -0
  103. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.mjs +79 -0
  104. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.mjs.map +1 -0
  105. package/lib/components/ModelCompareV3/data/products/gatewayLite.js +8 -7
  106. package/lib/components/ModelCompareV3/data/products/gatewayLite.js.map +1 -1
  107. package/lib/components/ModelCompareV3/data/products/gatewayLite.mjs +8 -7
  108. package/lib/components/ModelCompareV3/data/products/gatewayLite.mjs.map +1 -1
  109. package/lib/components/ModelCompareV3/data/products/gatewayMax.js +5 -5
  110. package/lib/components/ModelCompareV3/data/products/gatewayMax.js.map +1 -1
  111. package/lib/components/ModelCompareV3/data/products/gatewayMax.mjs +5 -5
  112. package/lib/components/ModelCompareV3/data/products/gatewayMax.mjs.map +1 -1
  113. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.js +12 -11
  114. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.js.map +1 -1
  115. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.mjs +12 -11
  116. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.mjs.map +1 -1
  117. package/lib/components/ModelCompareV3/data/products/missionCritical.js +1 -1
  118. package/lib/components/ModelCompareV3/data/products/missionCritical.js.map +1 -1
  119. package/lib/components/ModelCompareV3/data/products/missionCritical.mjs +1 -1
  120. package/lib/components/ModelCompareV3/data/products/missionCritical.mjs.map +1 -1
  121. package/lib/components/ModelCompareV3/data/products/professional24.js +1 -1
  122. package/lib/components/ModelCompareV3/data/products/professional24.js.map +1 -1
  123. package/lib/components/ModelCompareV3/data/products/professional24.mjs +1 -1
  124. package/lib/components/ModelCompareV3/data/products/professional24.mjs.map +1 -1
  125. package/lib/components/ModelCompareV3/data/products/professional24PoE.js +1 -1
  126. package/lib/components/ModelCompareV3/data/products/professional24PoE.js.map +1 -1
  127. package/lib/components/ModelCompareV3/data/products/professional24PoE.mjs +1 -1
  128. package/lib/components/ModelCompareV3/data/products/professional24PoE.mjs.map +1 -1
  129. package/lib/components/ModelCompareV3/data/products/professional48.js +1 -1
  130. package/lib/components/ModelCompareV3/data/products/professional48.js.map +1 -1
  131. package/lib/components/ModelCompareV3/data/products/professional48.mjs +1 -1
  132. package/lib/components/ModelCompareV3/data/products/professional48.mjs.map +1 -1
  133. package/lib/components/ModelCompareV3/data/products/professional48PoE.js +1 -1
  134. package/lib/components/ModelCompareV3/data/products/professional48PoE.js.map +1 -1
  135. package/lib/components/ModelCompareV3/data/products/professional48PoE.mjs +1 -1
  136. package/lib/components/ModelCompareV3/data/products/professional48PoE.mjs.map +1 -1
  137. package/lib/components/ModelCompareV3/data/products/professionalMax24.js +1 -1
  138. package/lib/components/ModelCompareV3/data/products/professionalMax24.js.map +1 -1
  139. package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs +1 -1
  140. package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs.map +1 -1
  141. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js +1 -1
  142. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js.map +1 -1
  143. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs +1 -1
  144. package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs.map +1 -1
  145. package/lib/components/ModelCompareV3/data/products/professionalMax48.js +1 -1
  146. package/lib/components/ModelCompareV3/data/products/professionalMax48.js.map +1 -1
  147. package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs +1 -1
  148. package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs.map +1 -1
  149. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js +1 -1
  150. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js.map +1 -1
  151. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs +1 -1
  152. package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs.map +1 -1
  153. package/lib/components/ModelCompareV3/data/products/standard16PoE.js +1 -1
  154. package/lib/components/ModelCompareV3/data/products/standard16PoE.js.map +1 -1
  155. package/lib/components/ModelCompareV3/data/products/standard16PoE.mjs +1 -1
  156. package/lib/components/ModelCompareV3/data/products/standard16PoE.mjs.map +1 -1
  157. package/lib/components/ModelCompareV3/data/products/standard24.js +1 -1
  158. package/lib/components/ModelCompareV3/data/products/standard24.js.map +1 -1
  159. package/lib/components/ModelCompareV3/data/products/standard24.mjs +1 -1
  160. package/lib/components/ModelCompareV3/data/products/standard24.mjs.map +1 -1
  161. package/lib/components/ModelCompareV3/data/products/standard24PoE.js +1 -1
  162. package/lib/components/ModelCompareV3/data/products/standard24PoE.js.map +1 -1
  163. package/lib/components/ModelCompareV3/data/products/standard24PoE.mjs +1 -1
  164. package/lib/components/ModelCompareV3/data/products/standard24PoE.mjs.map +1 -1
  165. package/lib/components/ModelCompareV3/data/products/standard48.js +1 -1
  166. package/lib/components/ModelCompareV3/data/products/standard48.js.map +1 -1
  167. package/lib/components/ModelCompareV3/data/products/standard48.mjs +1 -1
  168. package/lib/components/ModelCompareV3/data/products/standard48.mjs.map +1 -1
  169. package/lib/components/ModelCompareV3/data/products/standard48PoE.js +1 -1
  170. package/lib/components/ModelCompareV3/data/products/standard48PoE.js.map +1 -1
  171. package/lib/components/ModelCompareV3/data/products/standard48PoE.mjs +1 -1
  172. package/lib/components/ModelCompareV3/data/products/standard48PoE.mjs.map +1 -1
  173. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js +1 -1
  174. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js.map +1 -1
  175. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs +1 -1
  176. package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs.map +1 -1
  177. package/lib/components/ModelCompareV3/data/products/switchesProfessional.js +1 -1
  178. package/lib/components/ModelCompareV3/data/products/switchesProfessional.js.map +1 -1
  179. package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs +1 -1
  180. package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs.map +1 -1
  181. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js +1 -1
  182. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js.map +1 -1
  183. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs +1 -1
  184. package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs.map +1 -1
  185. package/lib/components/ModelCompareV3/data/products/switchesStandard.js +1 -1
  186. package/lib/components/ModelCompareV3/data/products/switchesStandard.js.map +1 -1
  187. package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs +1 -1
  188. package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs.map +1 -1
  189. package/lib/components/ModelCompareV3/data/products/ucgMax.js +7 -0
  190. package/lib/components/ModelCompareV3/data/products/ucgMax.js.map +1 -1
  191. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +7 -0
  192. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs.map +1 -1
  193. package/lib/components/ModelCompareV3/data/products/ucgUltra.js +8 -0
  194. package/lib/components/ModelCompareV3/data/products/ucgUltra.js.map +1 -1
  195. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +8 -0
  196. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs.map +1 -1
  197. package/lib/components/ModelCompareV3/data/products/udmPro.js +10 -2
  198. package/lib/components/ModelCompareV3/data/products/udmPro.js.map +1 -1
  199. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +10 -2
  200. package/lib/components/ModelCompareV3/data/products/udmPro.mjs.map +1 -1
  201. package/lib/components/ModelCompareV3/data/products/udmProMax.js +10 -3
  202. package/lib/components/ModelCompareV3/data/products/udmProMax.js.map +1 -1
  203. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +10 -3
  204. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs.map +1 -1
  205. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +10 -2
  206. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js.map +1 -1
  207. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +10 -2
  208. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs.map +1 -1
  209. package/lib/components/ModelCompareV3/data/products/udr.js +8 -0
  210. package/lib/components/ModelCompareV3/data/products/udr.js.map +1 -1
  211. package/lib/components/ModelCompareV3/data/products/udr.mjs +8 -0
  212. package/lib/components/ModelCompareV3/data/products/udr.mjs.map +1 -1
  213. package/lib/components/ModelCompareV3/data/products/udw.js +8 -0
  214. package/lib/components/ModelCompareV3/data/products/udw.js.map +1 -1
  215. package/lib/components/ModelCompareV3/data/products/udw.mjs +8 -0
  216. package/lib/components/ModelCompareV3/data/products/udw.mjs.map +1 -1
  217. package/lib/components/ModelCompareV3/data/properties/index.d.ts +2 -0
  218. package/lib/components/ModelCompareV3/data/properties/index.js +4 -0
  219. package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
  220. package/lib/components/ModelCompareV3/data/properties/index.mjs +2 -0
  221. package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
  222. package/lib/components/ModelCompareV3/data/properties/nextAiInspection.d.ts +2 -0
  223. package/lib/components/ModelCompareV3/data/properties/nextAiInspection.js +19 -0
  224. package/lib/components/ModelCompareV3/data/properties/nextAiInspection.js.map +1 -0
  225. package/lib/components/ModelCompareV3/data/properties/nextAiInspection.mjs +11 -0
  226. package/lib/components/ModelCompareV3/data/properties/nextAiInspection.mjs.map +1 -0
  227. package/lib/components/ModelCompareV3/translations/en.json.js +21 -36
  228. package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
  229. package/lib/components/ModelCompareV3/translations/en.json.mjs +21 -36
  230. package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
  231. package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
  232. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +2 -2
  233. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
  234. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
  235. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
  236. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
  237. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
  238. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
  239. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
  240. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
  241. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
  242. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
  243. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
  244. package/lib/constants/icons/menu/efg.svg.js +27 -0
  245. package/lib/constants/icons/menu/efg.svg.js.map +1 -0
  246. package/lib/constants/icons/menu/efg.svg.mjs +3 -0
  247. package/lib/constants/icons/menu/efg.svg.mjs.map +1 -0
  248. package/lib/constants/icons/menu/efgStacked.svg.js +27 -0
  249. package/lib/constants/icons/menu/efgStacked.svg.js.map +1 -0
  250. package/lib/constants/icons/menu/efgStacked.svg.mjs +3 -0
  251. package/lib/constants/icons/menu/efgStacked.svg.mjs.map +1 -0
  252. package/lib/constants/icons/menu/index.d.ts +2 -0
  253. package/lib/constants/icons/menu/index.js +18 -0
  254. package/lib/constants/icons/menu/index.js.map +1 -1
  255. package/lib/constants/icons/menu/index.mjs +4 -0
  256. package/lib/constants/icons/menu/index.mjs.map +1 -1
  257. package/lib/constants/icons/options/colors/black.svg.js +5 -5
  258. package/lib/constants/icons/options/colors/index.js +3 -3
  259. package/lib/constants/icons/options/styles/black.svg.js +5 -5
  260. package/lib/constants/icons/options/styles/index.js +3 -3
  261. package/lib/constants/optionIcons.js +6 -6
  262. package/lib/constants/optionIcons.mjs +4 -4
  263. package/lib/constants/proStoreCategories/mapping/index.d.ts +13 -12
  264. package/lib/constants/proStoreCategories/mapping/index.js +5 -0
  265. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  266. package/lib/constants/proStoreCategories/mapping/index.mjs +5 -0
  267. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  268. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -0
  269. package/lib/constants/proStoreCategories/mapping/unifi.js +1 -0
  270. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  271. package/lib/constants/proStoreCategories/mapping/unifi.mjs +1 -0
  272. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  273. package/lib/constants/proStoreCategories/translations/ar.json.js +29 -24
  274. package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
  275. package/lib/constants/proStoreCategories/translations/ar.json.mjs +29 -25
  276. package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
  277. package/lib/constants/proStoreCategories/translations/de.json.js +29 -24
  278. package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
  279. package/lib/constants/proStoreCategories/translations/de.json.mjs +29 -25
  280. package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
  281. package/lib/constants/proStoreCategories/translations/el.json.js +29 -24
  282. package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
  283. package/lib/constants/proStoreCategories/translations/el.json.mjs +29 -25
  284. package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
  285. package/lib/constants/proStoreCategories/translations/en.json.js +20 -19
  286. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  287. package/lib/constants/proStoreCategories/translations/en.json.mjs +20 -19
  288. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  289. package/lib/constants/proStoreCategories/translations/es.json.js +29 -24
  290. package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
  291. package/lib/constants/proStoreCategories/translations/es.json.mjs +29 -25
  292. package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
  293. package/lib/constants/proStoreCategories/translations/fr.json.js +29 -24
  294. package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
  295. package/lib/constants/proStoreCategories/translations/fr.json.mjs +29 -25
  296. package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
  297. package/lib/constants/proStoreCategories/translations/it.json.js +29 -24
  298. package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
  299. package/lib/constants/proStoreCategories/translations/it.json.mjs +29 -25
  300. package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
  301. package/lib/constants/proStoreCategories/translations/ja.json.js +29 -24
  302. package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
  303. package/lib/constants/proStoreCategories/translations/ja.json.mjs +29 -25
  304. package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
  305. package/lib/constants/proStoreCategories/translations/pt-BR.json.js +29 -24
  306. package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
  307. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +29 -25
  308. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
  309. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +29 -24
  310. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
  311. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +29 -25
  312. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
  313. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +29 -24
  314. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
  315. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +29 -25
  316. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
  317. package/lib/contexts/MenuContext/mapping.js +14 -0
  318. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  319. package/lib/contexts/MenuContext/mapping.mjs +13 -0
  320. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  321. package/lib/types/constants.d.ts +5 -1
  322. package/lib/types/constants.js +1 -0
  323. package/lib/types/constants.js.map +1 -1
  324. package/lib/types/constants.mjs +1 -0
  325. package/lib/types/constants.mjs.map +1 -1
  326. package/lib/utils/address.d.ts +2 -2
  327. package/lib/utils/address.js +8 -5
  328. package/lib/utils/address.js.map +1 -1
  329. package/lib/utils/address.mjs +8 -5
  330. package/lib/utils/address.mjs.map +1 -1
  331. package/lib/utils/money/constants.d.ts +25 -56
  332. package/lib/utils/money/constants.js +7 -68
  333. package/lib/utils/money/constants.js.map +1 -1
  334. package/lib/utils/money/constants.mjs +7 -66
  335. package/lib/utils/money/constants.mjs.map +1 -1
  336. package/lib/utils/money/format.d.ts +5 -10
  337. package/lib/utils/money/format.js +14 -22
  338. package/lib/utils/money/format.js.map +1 -1
  339. package/lib/utils/money/format.mjs +16 -23
  340. package/lib/utils/money/format.mjs.map +1 -1
  341. package/lib/utils/money/index.d.ts +1 -5
  342. package/lib/utils/money/index.js +8 -27
  343. package/lib/utils/money/index.js.map +1 -1
  344. package/lib/utils/money/index.mjs +4 -9
  345. package/lib/utils/money/index.mjs.map +1 -1
  346. package/lib/utils/money/misc.d.ts +28 -68
  347. package/lib/utils/money/misc.js +64 -35
  348. package/lib/utils/money/misc.js.map +1 -1
  349. package/lib/utils/money/misc.mjs +43 -32
  350. package/lib/utils/money/misc.mjs.map +1 -1
  351. package/lib/utils/money/tax.d.ts +2 -38
  352. package/lib/utils/money/tax.js +10 -46
  353. package/lib/utils/money/tax.js.map +1 -1
  354. package/lib/utils/money/tax.mjs +11 -42
  355. package/lib/utils/money/tax.mjs.map +1 -1
  356. package/lib/utils/money/types.d.ts +3 -64
  357. package/lib/utils/number.d.ts +1 -1
  358. package/lib/utils/number.js +1 -1
  359. package/lib/utils/number.js.map +1 -1
  360. package/lib/utils/number.mjs +1 -1
  361. package/lib/utils/number.mjs.map +1 -1
  362. package/lib/utils/validations/stateRegistrationNumberSuperRefinement.js +1 -0
  363. package/lib/utils/validations/stateRegistrationNumberSuperRefinement.js.map +1 -1
  364. package/lib/utils/validations/stateRegistrationNumberSuperRefinement.mjs +1 -0
  365. package/lib/utils/validations/stateRegistrationNumberSuperRefinement.mjs.map +1 -1
  366. package/lib/utils/validations/taxIdSuperRefinement.js +1 -0
  367. package/lib/utils/validations/taxIdSuperRefinement.js.map +1 -1
  368. package/lib/utils/validations/taxIdSuperRefinement.mjs +1 -0
  369. package/lib/utils/validations/taxIdSuperRefinement.mjs.map +1 -1
  370. package/lib/utils/validations.d.ts +15 -0
  371. package/lib/utils/validations.js +23 -0
  372. package/lib/utils/validations.js.map +1 -0
  373. package/lib/utils/validations.mjs +21 -0
  374. package/lib/utils/validations.mjs.map +1 -0
  375. package/package.json +1 -1
  376. package/lib/utils/money/allocators/fixedAmount.d.ts +0 -26
  377. package/lib/utils/money/allocators/fixedAmount.js +0 -55
  378. package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
  379. package/lib/utils/money/allocators/fixedAmount.mjs +0 -53
  380. package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
  381. package/lib/utils/money/allocators/index.d.ts +0 -1
  382. package/lib/utils/money/allocators/index.js +0 -6
  383. package/lib/utils/money/allocators/index.js.map +0 -1
  384. package/lib/utils/money/allocators/index.mjs +0 -3
  385. package/lib/utils/money/allocators/index.mjs.map +0 -1
  386. package/lib/utils/money/dinero.d.ts +0 -5
  387. package/lib/utils/money/dinero.js +0 -101
  388. package/lib/utils/money/dinero.js.map +0 -1
  389. package/lib/utils/money/dinero.mjs +0 -3
  390. package/lib/utils/money/dinero.mjs.map +0 -1
  391. package/lib/utils/money/exchangeRate.d.ts +0 -30
  392. package/lib/utils/money/exchangeRate.js +0 -27
  393. package/lib/utils/money/exchangeRate.js.map +0 -1
  394. package/lib/utils/money/exchangeRate.mjs +0 -23
  395. package/lib/utils/money/exchangeRate.mjs.map +0 -1
  396. package/lib/utils/money/misc.private.d.ts +0 -23
  397. package/lib/utils/money/misc.private.js +0 -46
  398. package/lib/utils/money/misc.private.js.map +0 -1
  399. package/lib/utils/money/misc.private.mjs +0 -21
  400. package/lib/utils/money/misc.private.mjs.map +0 -1
  401. package/lib/utils/money/shipping.d.ts +0 -5
  402. package/lib/utils/money/shipping.js +0 -8
  403. package/lib/utils/money/shipping.js.map +0 -1
  404. package/lib/utils/money/shipping.mjs +0 -6
  405. package/lib/utils/money/shipping.mjs.map +0 -1
  406. package/lib/utils/money/tax.private.d.ts +0 -17
  407. package/lib/utils/money/tax.private.js +0 -65
  408. package/lib/utils/money/tax.private.js.map +0 -1
  409. package/lib/utils/money/tax.private.mjs +0 -60
  410. package/lib/utils/money/tax.private.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","sources":["../../src/utils/validations.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;;"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
4
+ if (typeof value !== "number" || Number.isNaN(value)) {
5
+ throw new ErrorClass(`${entity} is not a number: ${value}`);
6
+ }
7
+ if (!Number.isFinite(value)) {
8
+ throw new ErrorClass(`${entity} is not a finite number: ${value}`);
9
+ }
10
+ }
11
+ function isInt(value, entity = "Value", ErrorClass = TypeError) {
12
+ isFiniteNumber(value, entity, ErrorClass);
13
+ if (!Number.isInteger(value)) {
14
+ throw new ErrorClass(`${entity} is not an integer: ${value}`);
15
+ }
16
+ if (!Number.isSafeInteger(value)) {
17
+ throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
18
+ }
19
+ }
20
+ export { isFiniteNumber, isInt };
21
+ //# sourceMappingURL=validations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.mjs","sources":["../../src/utils/validations.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.2.0-money.3",
3
+ "version": "9.2.0",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -1,26 +0,0 @@
1
- import type { Currency } from "../../../types";
2
- import type { Cents, Dino, DinoCurrency } from "../types";
3
- /**
4
- * Helper class to distribute a fixed amount (e.g. discount) between multiple items.
5
- * For example when trying to apply 5$ discount to 3 items, we need to distribute it evenly as possible
6
- */
7
- export declare class FixedAmountAllocator {
8
- /**
9
- * How much we have left to allocate for given allocation from the remaining total
10
- */
11
- remainingAllocationAmount: Dino;
12
- /**
13
- * How much we have left to allocate in total
14
- */
15
- remainingTotalAmount: Dino;
16
- currency: DinoCurrency;
17
- constructor({ initialAllocateAmount, initialTotalAmount, currency, }: {
18
- initialAllocateAmount: Cents;
19
- initialTotalAmount: Cents;
20
- currency: Currency;
21
- });
22
- /**
23
- * We always allocate biggest share to first item
24
- */
25
- allocate(lineItemTotal: Cents, currency: Currency): Dino;
26
- }
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- var dinero_js = require('dinero.js');
4
- var errors = require('../../errors.js');
5
- var misc = require('../misc.js');
6
- "use strict";
7
- var __defProp = Object.defineProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value
13
- }) : obj[key] = value;
14
- var __publicField = (obj, key, value) => {
15
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
16
- return value;
17
- };
18
- class FixedAmountAllocator {
19
- constructor({
20
- initialAllocateAmount,
21
- initialTotalAmount,
22
- currency
23
- }) {
24
- /**
25
- * How much we have left to allocate for given allocation from the remaining total
26
- */
27
- __publicField(this, "remainingAllocationAmount");
28
- /**
29
- * How much we have left to allocate in total
30
- */
31
- __publicField(this, "remainingTotalAmount");
32
- __publicField(this, "currency");
33
- this.remainingAllocationAmount = misc.getDinero(initialAllocateAmount, currency);
34
- this.remainingTotalAmount = misc.getDinero(initialTotalAmount, currency);
35
- this.currency = misc.getDineroCurrency(currency);
36
- }
37
- /**
38
- * We always allocate biggest share to first item
39
- */
40
- allocate(lineItemTotal, currency) {
41
- errors.assert(this.currency.code === currency, `Currency mismatch, expected ${currency}, got ${this.currency.code}`);
42
- const lineItemTotalDinero = misc.getDinero(lineItemTotal, currency);
43
- if (lineItemTotal === 0) {
44
- return lineItemTotalDinero;
45
- }
46
- const [allocationAmount, remainingAllocationAmount] = dinero_js.allocate(this.remainingAllocationAmount, [lineItemTotal, Math.max(misc.amount(this.remainingTotalAmount) - lineItemTotal, 0)]);
47
- errors.assert(!!allocationAmount, "Allocation amount is zero");
48
- errors.assert(!!remainingAllocationAmount, "Remaining allocation remainder is zero");
49
- this.remainingAllocationAmount = remainingAllocationAmount;
50
- this.remainingTotalAmount = dinero_js.subtract(this.remainingTotalAmount, lineItemTotalDinero);
51
- return dinero_js.greaterThan(allocationAmount, lineItemTotalDinero) ? lineItemTotalDinero : allocationAmount;
52
- }
53
- }
54
- exports.FixedAmountAllocator = FixedAmountAllocator;
55
- //# sourceMappingURL=fixedAmount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixedAmount.js","sources":["../../../../src/utils/money/allocators/fixedAmount.ts"],"sourcesContent":["import { allocate, greaterThan, subtract } from \"dinero.js\";\n\nimport type { Currency } from \"../../../types\";\nimport { assert } from \"../../errors\";\nimport { amount, getDinero, getDineroCurrency } from \"../misc\";\nimport type { Cents, Dino, DinoCurrency } from \"../types\";\n\n/**\n * Helper class to distribute a fixed amount (e.g. discount) between multiple items.\n * For example when trying to apply 5$ discount to 3 items, we need to distribute it evenly as possible\n */\nexport class FixedAmountAllocator {\n /**\n * How much we have left to allocate for given allocation from the remaining total\n */\n public remainingAllocationAmount: Dino;\n /**\n * How much we have left to allocate in total\n */\n public remainingTotalAmount: Dino;\n public currency: DinoCurrency;\n\n constructor({\n initialAllocateAmount,\n initialTotalAmount,\n currency,\n }: {\n initialAllocateAmount: Cents;\n initialTotalAmount: Cents;\n currency: Currency;\n }) {\n this.remainingAllocationAmount = getDinero(initialAllocateAmount, currency);\n this.remainingTotalAmount = getDinero(initialTotalAmount, currency);\n this.currency = getDineroCurrency(currency);\n }\n\n /**\n * We always allocate biggest share to first item\n */\n allocate(lineItemTotal: Cents, currency: Currency): Dino {\n assert(\n this.currency.code === currency,\n `Currency mismatch, expected ${currency}, got ${this.currency.code}`,\n );\n const lineItemTotalDinero = getDinero(lineItemTotal, currency);\n /**\n * If total price of line items is zero, it means it's free, thus no discount\n * can be calculated (it's either 0 or infinity, but let's go with 0)\n */\n if (lineItemTotal === 0) {\n return lineItemTotalDinero;\n }\n\n const [allocationAmount, remainingAllocationAmount] = allocate(\n this.remainingAllocationAmount,\n [\n lineItemTotal,\n Math.max(amount(this.remainingTotalAmount) - lineItemTotal, 0),\n ],\n );\n\n assert(!!allocationAmount, \"Allocation amount is zero\");\n assert(\n !!remainingAllocationAmount,\n \"Remaining allocation remainder is zero\",\n );\n\n this.remainingAllocationAmount = remainingAllocationAmount;\n this.remainingTotalAmount = subtract(\n this.remainingTotalAmount,\n lineItemTotalDinero,\n );\n\n /**\n * The discount amount is evenly split but can still be higher than the line item total\n * Need to ceil the price to be not more than the line item total\n */\n return greaterThan(allocationAmount, lineItemTotalDinero)\n ? lineItemTotalDinero\n : allocationAmount;\n }\n}\n"],"names":["FixedAmountAllocator","constructor","initialAllocateAmount","initialTotalAmount","currency","__publicField","remainingAllocationAmount","getDinero","remainingTotalAmount","getDineroCurrency","allocate","lineItemTotal","assert","code","lineItemTotalDinero","allocationAmount","Math","max","amount","subtract","greaterThan"],"mappings":";;;;;;;;;;;;;;;;;AAWO,MAAMA,oBAAqB,CAAA;EAWhCC,WAAYA,CAAA;IACVC,qBAAA;IACAC,kBAAA;IACAC;EAAA,CAKC,EAAA;IAfH;AAAA;AAAA;IAAOC,aAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;IAIP;AAAA;AAAA;IAAOA,aAAA,CAAA,IAAA,EAAA,sBAAA,CAAA;IACAA,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAWA,IAAA,CAAAC,yBAAA,GAA4BC,IAAAA,CAAAA,SAAU,CAAAL,qBAAA,EAAuBE,QAAQ,CAAA;IACrE,IAAA,CAAAI,oBAAA,GAAuBD,IAAAA,CAAAA,SAAU,CAAAJ,kBAAA,EAAoBC,QAAQ,CAAA;IAC7D,IAAA,CAAAA,QAAA,GAAWK,uBAAkBL,QAAQ,CAAA;EAC5C;EAAA;AAAA;AAAA;EAKAM,QAAAA,CAASC,eAAsBP,QAA0B,EAAA;IACvDQ,MAAA,CAAAA,MAAA,CACE,IAAA,CAAKR,SAASS,IAAS,KAAAT,QAAA,EACQ,+BAAAA,QAAiB,SAAA,IAAA,CAAKA,SAASS,IAAI,EAAA,CACpE;IACM,MAAAC,mBAAA,GAAsBP,IAAAA,CAAAA,SAAU,CAAAI,aAAA,EAAeP,QAAQ,CAAA;IAK7D,IAAIO,kBAAkB,CAAG,EAAA;MAChB,OAAAG,mBAAA;IACT;IAEM,MAAA,CAACC,gBAAkB,EAAAT,yBAAyB,CAAI,GAAAI,SAAA,CAAAA,QAAA,CACpD,IAAK,CAAAJ,yBAAA,EACL,CACEK,aAAA,EACAK,KAAKC,GAAI,CAAAC,WAAA,CAAO,KAAKV,oBAAoB,CAAA,GAAIG,eAAe,CAAC,CAAA,CAC/D,CACF;IAEOC,MAAAA,CAAAA,MAAA,CAAA,CAAC,CAACG,gBAAA,EAAkB,2BAA2B,CAAA;IACtDH,MAAA,CAAAA,MAAA,CACE,CAAC,CAACN,yBAAA,EACF,wCAAA,CACF;IAEA,IAAA,CAAKA,yBAA4B,GAAAA,yBAAA;IACjC,IAAA,CAAKE,oBAAuB,GAAAW,SAAA,CAAAA,QAAA,CAC1B,IAAK,CAAAX,oBAAA,EACLM,mBAAA,CACF;IAMA,OAAOM,SAAY,CAAAA,WAAA,CAAAL,gBAAA,EAAkBD,mBAAmB,CAAA,GACpDA,mBACA,GAAAC,gBAAA;EACN;AACF;"}
@@ -1,53 +0,0 @@
1
- import { allocate, subtract, greaterThan } from 'dinero.js';
2
- import { assert } from '../../errors.mjs';
3
- import { getDinero, getDineroCurrency, amount } from '../misc.mjs';
4
- "use strict";
5
- var __defProp = Object.defineProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
7
- enumerable: true,
8
- configurable: true,
9
- writable: true,
10
- value
11
- }) : obj[key] = value;
12
- var __publicField = (obj, key, value) => {
13
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
14
- return value;
15
- };
16
- class FixedAmountAllocator {
17
- constructor({
18
- initialAllocateAmount,
19
- initialTotalAmount,
20
- currency
21
- }) {
22
- /**
23
- * How much we have left to allocate for given allocation from the remaining total
24
- */
25
- __publicField(this, "remainingAllocationAmount");
26
- /**
27
- * How much we have left to allocate in total
28
- */
29
- __publicField(this, "remainingTotalAmount");
30
- __publicField(this, "currency");
31
- this.remainingAllocationAmount = getDinero(initialAllocateAmount, currency);
32
- this.remainingTotalAmount = getDinero(initialTotalAmount, currency);
33
- this.currency = getDineroCurrency(currency);
34
- }
35
- /**
36
- * We always allocate biggest share to first item
37
- */
38
- allocate(lineItemTotal, currency) {
39
- assert(this.currency.code === currency, `Currency mismatch, expected ${currency}, got ${this.currency.code}`);
40
- const lineItemTotalDinero = getDinero(lineItemTotal, currency);
41
- if (lineItemTotal === 0) {
42
- return lineItemTotalDinero;
43
- }
44
- const [allocationAmount, remainingAllocationAmount] = allocate(this.remainingAllocationAmount, [lineItemTotal, Math.max(amount(this.remainingTotalAmount) - lineItemTotal, 0)]);
45
- assert(!!allocationAmount, "Allocation amount is zero");
46
- assert(!!remainingAllocationAmount, "Remaining allocation remainder is zero");
47
- this.remainingAllocationAmount = remainingAllocationAmount;
48
- this.remainingTotalAmount = subtract(this.remainingTotalAmount, lineItemTotalDinero);
49
- return greaterThan(allocationAmount, lineItemTotalDinero) ? lineItemTotalDinero : allocationAmount;
50
- }
51
- }
52
- export { FixedAmountAllocator };
53
- //# sourceMappingURL=fixedAmount.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixedAmount.mjs","sources":["../../../../src/utils/money/allocators/fixedAmount.ts"],"sourcesContent":["import { allocate, greaterThan, subtract } from \"dinero.js\";\n\nimport type { Currency } from \"../../../types\";\nimport { assert } from \"../../errors\";\nimport { amount, getDinero, getDineroCurrency } from \"../misc\";\nimport type { Cents, Dino, DinoCurrency } from \"../types\";\n\n/**\n * Helper class to distribute a fixed amount (e.g. discount) between multiple items.\n * For example when trying to apply 5$ discount to 3 items, we need to distribute it evenly as possible\n */\nexport class FixedAmountAllocator {\n /**\n * How much we have left to allocate for given allocation from the remaining total\n */\n public remainingAllocationAmount: Dino;\n /**\n * How much we have left to allocate in total\n */\n public remainingTotalAmount: Dino;\n public currency: DinoCurrency;\n\n constructor({\n initialAllocateAmount,\n initialTotalAmount,\n currency,\n }: {\n initialAllocateAmount: Cents;\n initialTotalAmount: Cents;\n currency: Currency;\n }) {\n this.remainingAllocationAmount = getDinero(initialAllocateAmount, currency);\n this.remainingTotalAmount = getDinero(initialTotalAmount, currency);\n this.currency = getDineroCurrency(currency);\n }\n\n /**\n * We always allocate biggest share to first item\n */\n allocate(lineItemTotal: Cents, currency: Currency): Dino {\n assert(\n this.currency.code === currency,\n `Currency mismatch, expected ${currency}, got ${this.currency.code}`,\n );\n const lineItemTotalDinero = getDinero(lineItemTotal, currency);\n /**\n * If total price of line items is zero, it means it's free, thus no discount\n * can be calculated (it's either 0 or infinity, but let's go with 0)\n */\n if (lineItemTotal === 0) {\n return lineItemTotalDinero;\n }\n\n const [allocationAmount, remainingAllocationAmount] = allocate(\n this.remainingAllocationAmount,\n [\n lineItemTotal,\n Math.max(amount(this.remainingTotalAmount) - lineItemTotal, 0),\n ],\n );\n\n assert(!!allocationAmount, \"Allocation amount is zero\");\n assert(\n !!remainingAllocationAmount,\n \"Remaining allocation remainder is zero\",\n );\n\n this.remainingAllocationAmount = remainingAllocationAmount;\n this.remainingTotalAmount = subtract(\n this.remainingTotalAmount,\n lineItemTotalDinero,\n );\n\n /**\n * The discount amount is evenly split but can still be higher than the line item total\n * Need to ceil the price to be not more than the line item total\n */\n return greaterThan(allocationAmount, lineItemTotalDinero)\n ? lineItemTotalDinero\n : allocationAmount;\n }\n}\n"],"names":["FixedAmountAllocator","constructor","initialAllocateAmount","initialTotalAmount","currency","__publicField","remainingAllocationAmount","getDinero","remainingTotalAmount","getDineroCurrency","allocate","lineItemTotal","assert","code","lineItemTotalDinero","allocationAmount","Math","max","amount","subtract","greaterThan"],"mappings":";;;;;;;;;;;;;;;AAWO,MAAMA,oBAAqB,CAAA;EAWhCC,WAAYA,CAAA;IACVC,qBAAA;IACAC,kBAAA;IACAC;EAAA,CAKC,EAAA;IAfH;AAAA;AAAA;IAAOC,aAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;IAIP;AAAA;AAAA;IAAOA,aAAA,CAAA,IAAA,EAAA,sBAAA,CAAA;IACAA,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA;IAWA,IAAA,CAAAC,yBAAA,GAA4BC,SAAU,CAAAL,qBAAA,EAAuBE,QAAQ,CAAA;IACrE,IAAA,CAAAI,oBAAA,GAAuBD,SAAU,CAAAJ,kBAAA,EAAoBC,QAAQ,CAAA;IAC7D,IAAA,CAAAA,QAAA,GAAWK,kBAAkBL,QAAQ,CAAA;EAC5C;EAAA;AAAA;AAAA;EAKAM,QAAAA,CAASC,eAAsBP,QAA0B,EAAA;IACvDQ,MAAA,CACE,IAAA,CAAKR,SAASS,IAAS,KAAAT,QAAA,EACQ,+BAAAA,QAAiB,SAAA,IAAA,CAAKA,SAASS,IAAI,EAAA,CACpE;IACM,MAAAC,mBAAA,GAAsBP,SAAU,CAAAI,aAAA,EAAeP,QAAQ,CAAA;IAK7D,IAAIO,kBAAkB,CAAG,EAAA;MAChB,OAAAG,mBAAA;IACT;IAEM,MAAA,CAACC,gBAAkB,EAAAT,yBAAyB,CAAI,GAAAI,QAAA,CACpD,IAAK,CAAAJ,yBAAA,EACL,CACEK,aAAA,EACAK,KAAKC,GAAI,CAAAC,MAAA,CAAO,KAAKV,oBAAoB,CAAA,GAAIG,eAAe,CAAC,CAAA,CAC/D,CACF;IAEOC,MAAA,CAAA,CAAC,CAACG,gBAAA,EAAkB,2BAA2B,CAAA;IACtDH,MAAA,CACE,CAAC,CAACN,yBAAA,EACF,wCAAA,CACF;IAEA,IAAA,CAAKA,yBAA4B,GAAAA,yBAAA;IACjC,IAAA,CAAKE,oBAAuB,GAAAW,QAAA,CAC1B,IAAK,CAAAX,oBAAA,EACLM,mBAAA,CACF;IAMA,OAAOM,WAAY,CAAAL,gBAAA,EAAkBD,mBAAmB,CAAA,GACpDA,mBACA,GAAAC,gBAAA;EACN;AACF;"}
@@ -1 +0,0 @@
1
- export * from "./fixedAmount";
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var fixedAmount = require('./fixedAmount.js');
4
- "use strict";
5
- exports.FixedAmountAllocator = fixedAmount.FixedAmountAllocator;
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,3 +0,0 @@
1
- export { FixedAmountAllocator } from './fixedAmount.mjs';
2
- "use strict";
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Re-exports of dinero.js that is used in store.backend and other store.* repos
3
- * Favor using this module over importing directly from dinero.js to ensure consistent version usage.
4
- */
5
- export { add, allocate, compare, convert, dinero, equal, greaterThan, greaterThanOrEqual, lessThan, maximum, minimum, multiply, subtract, toSnapshot, toUnit, transformScale, } from "dinero.js";
@@ -1,101 +0,0 @@
1
- 'use strict';
2
-
3
- var dinero_js = require('dinero.js');
4
- "use strict";
5
- Object.defineProperty(exports, "add", {
6
- enumerable: true,
7
- get: function () {
8
- return dinero_js.add;
9
- }
10
- });
11
- Object.defineProperty(exports, "allocate", {
12
- enumerable: true,
13
- get: function () {
14
- return dinero_js.allocate;
15
- }
16
- });
17
- Object.defineProperty(exports, "compare", {
18
- enumerable: true,
19
- get: function () {
20
- return dinero_js.compare;
21
- }
22
- });
23
- Object.defineProperty(exports, "convert", {
24
- enumerable: true,
25
- get: function () {
26
- return dinero_js.convert;
27
- }
28
- });
29
- Object.defineProperty(exports, "dinero", {
30
- enumerable: true,
31
- get: function () {
32
- return dinero_js.dinero;
33
- }
34
- });
35
- Object.defineProperty(exports, "equal", {
36
- enumerable: true,
37
- get: function () {
38
- return dinero_js.equal;
39
- }
40
- });
41
- Object.defineProperty(exports, "greaterThan", {
42
- enumerable: true,
43
- get: function () {
44
- return dinero_js.greaterThan;
45
- }
46
- });
47
- Object.defineProperty(exports, "greaterThanOrEqual", {
48
- enumerable: true,
49
- get: function () {
50
- return dinero_js.greaterThanOrEqual;
51
- }
52
- });
53
- Object.defineProperty(exports, "lessThan", {
54
- enumerable: true,
55
- get: function () {
56
- return dinero_js.lessThan;
57
- }
58
- });
59
- Object.defineProperty(exports, "maximum", {
60
- enumerable: true,
61
- get: function () {
62
- return dinero_js.maximum;
63
- }
64
- });
65
- Object.defineProperty(exports, "minimum", {
66
- enumerable: true,
67
- get: function () {
68
- return dinero_js.minimum;
69
- }
70
- });
71
- Object.defineProperty(exports, "multiply", {
72
- enumerable: true,
73
- get: function () {
74
- return dinero_js.multiply;
75
- }
76
- });
77
- Object.defineProperty(exports, "subtract", {
78
- enumerable: true,
79
- get: function () {
80
- return dinero_js.subtract;
81
- }
82
- });
83
- Object.defineProperty(exports, "toSnapshot", {
84
- enumerable: true,
85
- get: function () {
86
- return dinero_js.toSnapshot;
87
- }
88
- });
89
- Object.defineProperty(exports, "toUnit", {
90
- enumerable: true,
91
- get: function () {
92
- return dinero_js.toUnit;
93
- }
94
- });
95
- Object.defineProperty(exports, "transformScale", {
96
- enumerable: true,
97
- get: function () {
98
- return dinero_js.transformScale;
99
- }
100
- });
101
- //# sourceMappingURL=dinero.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dinero.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +0,0 @@
1
- export { add, allocate, compare, convert, dinero, equal, greaterThan, greaterThanOrEqual, lessThan, maximum, minimum, multiply, subtract, toSnapshot, toUnit, transformScale } from 'dinero.js';
2
- "use strict";
3
- //# sourceMappingURL=dinero.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dinero.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,30 +0,0 @@
1
- /**
2
- * Parse exchange rate to dinero friendly amount and scale.
3
- *
4
- * Used to prepare exchange rate for sending over API.
5
- *
6
- * @example
7
- * toSnapshotExchangeRate(0.22); // {amount: 22000, scale: 6}
8
- */
9
- export declare const toSnapshotExchangeRate: (exchangeRate: number) => {
10
- amount: number;
11
- scale: number;
12
- };
13
- /**
14
- * Converts an arbitrary exchange rate to a fixed decimal place number.
15
- *
16
- * Used to take in an input and convert it for storage in the database.
17
- *
18
- * @example
19
- * toFixedExchangeRate("0.123456789") // "0.123457"
20
- * toFixedExchangeRate("0.123456789", true) // 0.123457
21
- */
22
- export declare function toFixedExchangeRate(rate: string | number, asNumber?: boolean): string;
23
- export declare function toFixedExchangeRate(rate: string | number, asNumber?: true): number;
24
- /**
25
- * Invert an exchange rate by doing 1 / rate
26
- * Used to fake a reverse exchange rate in case we don't have it
27
- * @example
28
- * invertExchangeRate("0.22") // "4.545455"
29
- */
30
- export declare function invertExchangeRate(rate: string | number): string;
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var errors = require('../errors.js');
4
- var number = require('../number.js');
5
- var constants = require('./constants.js');
6
- var misc_private = require('./misc.private.js');
7
- "use strict";
8
- const toSnapshotExchangeRate = exchangeRate => {
9
- number.isFloat(exchangeRate, "Exchange rate");
10
- errors.assert(exchangeRate > 0, "Exchange rate must be greater than 0");
11
- const rateInt = misc_private.floatToInt(exchangeRate, constants.EXCHANGE_RATE_DINERO_CURRENCY.base, constants.EXCHANGE_RATE_DINERO_CURRENCY.exponent);
12
- return {
13
- amount: rateInt,
14
- scale: constants.EXCHANGE_RATE_DINERO_CURRENCY.exponent
15
- };
16
- };
17
- function toFixedExchangeRate(rate, asNumber) {
18
- return number.toFixedRate(typeof rate === "string" ? +rate : rate, constants.EXCHANGE_RATE_DINERO_CURRENCY.exponent, asNumber);
19
- }
20
- function invertExchangeRate(rate) {
21
- const exchangeRate = toFixedExchangeRate(rate, true);
22
- return toFixedExchangeRate(1 / exchangeRate, false);
23
- }
24
- exports.invertExchangeRate = invertExchangeRate;
25
- exports.toFixedExchangeRate = toFixedExchangeRate;
26
- exports.toSnapshotExchangeRate = toSnapshotExchangeRate;
27
- //# sourceMappingURL=exchangeRate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exchangeRate.js","sources":["../../../src/utils/money/exchangeRate.ts"],"sourcesContent":["import { assert } from \"../errors\";\nimport { isFloat, toFixedRate } from \"../number\";\nimport { EXCHANGE_RATE_DINERO_CURRENCY } from \"./constants\";\nimport { floatToInt } from \"./misc.private\";\n\n// FIXME: reconsider if needed her as only used in BE for exchange rate Graph other places in code use Float|number\n/**\n * Parse exchange rate to dinero friendly amount and scale.\n *\n * Used to prepare exchange rate for sending over API.\n *\n * @example\n * toSnapshotExchangeRate(0.22); // {amount: 22000, scale: 6}\n */\nexport const toSnapshotExchangeRate = (\n exchangeRate: number,\n): {\n amount: number;\n scale: number;\n} => {\n // Validate input\n isFloat(exchangeRate, \"Exchange rate\");\n assert(exchangeRate > 0, \"Exchange rate must be greater than 0\");\n\n // Get scale of exchange rate\n const rateInt = floatToInt(\n exchangeRate,\n EXCHANGE_RATE_DINERO_CURRENCY.base,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n );\n\n // Return dinero friendly amount and scale\n return {\n amount: rateInt,\n scale: EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n };\n};\n\n/**\n * Converts an arbitrary exchange rate to a fixed decimal place number.\n *\n * Used to take in an input and convert it for storage in the database.\n *\n * @example\n * toFixedExchangeRate(\"0.123456789\") // \"0.123457\"\n * toFixedExchangeRate(\"0.123456789\", true) // 0.123457\n */\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: boolean,\n): string;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: true,\n): number;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: NoInfer<boolean>,\n): string | number {\n // FIXME: Remove + but instead add proper parsing of the string --> number\n // https://stackoverflow.com/a/12862627/1378261\n return toFixedRate(\n typeof rate === \"string\" ? +rate : rate,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n asNumber,\n );\n}\n\n/**\n * Invert an exchange rate by doing 1 / rate\n * Used to fake a reverse exchange rate in case we don't have it\n * @example\n * invertExchangeRate(\"0.22\") // \"4.545455\"\n */\nexport function invertExchangeRate(rate: string | number) {\n const exchangeRate = toFixedExchangeRate(rate, true);\n return toFixedExchangeRate(1 / exchangeRate, false);\n}\n"],"names":["toSnapshotExchangeRate","exchangeRate","isFloat","assert","rateInt","floatToInt","EXCHANGE_RATE_DINERO_CURRENCY","base","exponent","amount","scale","toFixedExchangeRate","rate","asNumber","toFixedRate","invertExchangeRate"],"mappings":";;;;;;;AAca,MAAAA,sBAAA,GACXC,YAIG,IAAA;EAEHC,cAAA,CAAQD,cAAc,eAAe,CAAA;EAC9BE,MAAAA,CAAAA,MAAA,CAAAF,YAAA,GAAe,GAAG,sCAAsC,CAAA;EAG/D,MAAMG,OAAU,GAAAC,YAAA,CAAAA,UAAA,CACdJ,YAAA,EACAK,SAAAA,CAAAA,6BAA8B,CAAAC,IAAA,EAC9BD,SAAAA,CAAAA,6BAA8B,CAAAE,QAAA,CAChC;EAGO,OAAA;IACLC,MAAQ,EAAAL,OAAA;IACRM,OAAOJ,SAA8B,CAAAA,6BAAA,CAAAE;EAAA,CACvC;AACF,CAAA;AAmBgB,SAAAG,mBAAAA,CACdC,MACAC,QACiB,EAAA;EAGV,OAAAC,MAAA,CAAAA,WAAA,CACL,OAAOF,IAAA,KAAS,QAAW,GAAA,CAACA,IAAO,GAAAA,IAAA,EACnCN,SAAAA,CAAAA,6BAA8B,CAAAE,QAAA,EAC9BK,QAAA,CACF;AACF;AAQO,SAASE,mBAAmBH,IAAuB,EAAA;EAClD,MAAAX,YAAA,GAAeU,mBAAoB,CAAAC,IAAA,EAAM,IAAI,CAAA;EAC5C,OAAAD,mBAAA,CAAoB,CAAI,GAAAV,YAAA,EAAc,KAAK,CAAA;AACpD;;;"}
@@ -1,23 +0,0 @@
1
- import { assert } from '../errors.mjs';
2
- import { isFloat, toFixedRate } from '../number.mjs';
3
- import { EXCHANGE_RATE_DINERO_CURRENCY } from './constants.mjs';
4
- import { floatToInt } from './misc.private.mjs';
5
- "use strict";
6
- const toSnapshotExchangeRate = exchangeRate => {
7
- isFloat(exchangeRate, "Exchange rate");
8
- assert(exchangeRate > 0, "Exchange rate must be greater than 0");
9
- const rateInt = floatToInt(exchangeRate, EXCHANGE_RATE_DINERO_CURRENCY.base, EXCHANGE_RATE_DINERO_CURRENCY.exponent);
10
- return {
11
- amount: rateInt,
12
- scale: EXCHANGE_RATE_DINERO_CURRENCY.exponent
13
- };
14
- };
15
- function toFixedExchangeRate(rate, asNumber) {
16
- return toFixedRate(typeof rate === "string" ? +rate : rate, EXCHANGE_RATE_DINERO_CURRENCY.exponent, asNumber);
17
- }
18
- function invertExchangeRate(rate) {
19
- const exchangeRate = toFixedExchangeRate(rate, true);
20
- return toFixedExchangeRate(1 / exchangeRate, false);
21
- }
22
- export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate };
23
- //# sourceMappingURL=exchangeRate.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exchangeRate.mjs","sources":["../../../src/utils/money/exchangeRate.ts"],"sourcesContent":["import { assert } from \"../errors\";\nimport { isFloat, toFixedRate } from \"../number\";\nimport { EXCHANGE_RATE_DINERO_CURRENCY } from \"./constants\";\nimport { floatToInt } from \"./misc.private\";\n\n// FIXME: reconsider if needed her as only used in BE for exchange rate Graph other places in code use Float|number\n/**\n * Parse exchange rate to dinero friendly amount and scale.\n *\n * Used to prepare exchange rate for sending over API.\n *\n * @example\n * toSnapshotExchangeRate(0.22); // {amount: 22000, scale: 6}\n */\nexport const toSnapshotExchangeRate = (\n exchangeRate: number,\n): {\n amount: number;\n scale: number;\n} => {\n // Validate input\n isFloat(exchangeRate, \"Exchange rate\");\n assert(exchangeRate > 0, \"Exchange rate must be greater than 0\");\n\n // Get scale of exchange rate\n const rateInt = floatToInt(\n exchangeRate,\n EXCHANGE_RATE_DINERO_CURRENCY.base,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n );\n\n // Return dinero friendly amount and scale\n return {\n amount: rateInt,\n scale: EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n };\n};\n\n/**\n * Converts an arbitrary exchange rate to a fixed decimal place number.\n *\n * Used to take in an input and convert it for storage in the database.\n *\n * @example\n * toFixedExchangeRate(\"0.123456789\") // \"0.123457\"\n * toFixedExchangeRate(\"0.123456789\", true) // 0.123457\n */\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: boolean,\n): string;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: true,\n): number;\nexport function toFixedExchangeRate(\n rate: string | number,\n asNumber?: NoInfer<boolean>,\n): string | number {\n // FIXME: Remove + but instead add proper parsing of the string --> number\n // https://stackoverflow.com/a/12862627/1378261\n return toFixedRate(\n typeof rate === \"string\" ? +rate : rate,\n EXCHANGE_RATE_DINERO_CURRENCY.exponent,\n asNumber,\n );\n}\n\n/**\n * Invert an exchange rate by doing 1 / rate\n * Used to fake a reverse exchange rate in case we don't have it\n * @example\n * invertExchangeRate(\"0.22\") // \"4.545455\"\n */\nexport function invertExchangeRate(rate: string | number) {\n const exchangeRate = toFixedExchangeRate(rate, true);\n return toFixedExchangeRate(1 / exchangeRate, false);\n}\n"],"names":["toSnapshotExchangeRate","exchangeRate","isFloat","assert","rateInt","floatToInt","EXCHANGE_RATE_DINERO_CURRENCY","base","exponent","amount","scale","toFixedExchangeRate","rate","asNumber","toFixedRate","invertExchangeRate"],"mappings":";;;;;AAca,MAAAA,sBAAA,GACXC,YAIG,IAAA;EAEHC,OAAA,CAAQD,cAAc,eAAe,CAAA;EAC9BE,MAAA,CAAAF,YAAA,GAAe,GAAG,sCAAsC,CAAA;EAG/D,MAAMG,OAAU,GAAAC,UAAA,CACdJ,YAAA,EACAK,6BAA8B,CAAAC,IAAA,EAC9BD,6BAA8B,CAAAE,QAAA,CAChC;EAGO,OAAA;IACLC,MAAQ,EAAAL,OAAA;IACRM,OAAOJ,6BAA8B,CAAAE;EAAA,CACvC;AACF,CAAA;AAmBgB,SAAAG,mBAAAA,CACdC,MACAC,QACiB,EAAA;EAGV,OAAAC,WAAA,CACL,OAAOF,IAAA,KAAS,QAAW,GAAA,CAACA,IAAO,GAAAA,IAAA,EACnCN,6BAA8B,CAAAE,QAAA,EAC9BK,QAAA,CACF;AACF;AAQO,SAASE,mBAAmBH,IAAuB,EAAA;EAClD,MAAAX,YAAA,GAAeU,mBAAoB,CAAAC,IAAA,EAAM,IAAI,CAAA;EAC5C,OAAAD,mBAAA,CAAoB,CAAI,GAAAV,YAAA,EAAc,KAAK,CAAA;AACpD;"}
@@ -1,23 +0,0 @@
1
- import * as currencies from "@dinero.js/currencies";
2
- import type { DinoCurrency } from "./types";
3
- /**
4
- * Fast lookup for our custom currency enum to check that given currency is valid
5
- */
6
- export declare const currencyLookup: Set<string>;
7
- /**
8
- * Dinero currency lookup to check that given currency is valid
9
- */
10
- export declare const dineroCurrenciesLookup: Map<string, currencies.Currency<number>>;
11
- /**
12
- * Private util to convert a float value into a int. Also applies financial rounding to the value if needed.
13
- * Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats
14
- * @example
15
- * floatToInt(69.10, 10, 2); // 6910
16
- * floatToInt(42, 10, 2); // 4200
17
- * floatToInt(0.22, 10, 6); // 220000
18
- */
19
- export declare const floatToInt: (floatAmount: number, base: number, exponent: number) => number;
20
- /**
21
- * FIXME: is it private tho?!
22
- */
23
- export declare const decimalToDinero: (decimalAmount: string | number, currency: DinoCurrency) => import("dinero.js").Dinero<number>;
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- var currencies = require('@dinero.js/currencies');
4
- var dinero_js = require('dinero.js');
5
- require('../../types/index.js');
6
- var number = require('../number.js');
7
- var constants = require('./constants.js');
8
- var generated = require('../../types/generated.js');
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () {
19
- return e[k];
20
- }
21
- });
22
- }
23
- });
24
- }
25
- n["default"] = e;
26
- return Object.freeze(n);
27
- }
28
- var currencies__namespace = /*#__PURE__*/_interopNamespace(currencies);
29
- "use strict";
30
- const currencyLookup = new Set(Object.keys(generated.Currency).map(el => el.toString()));
31
- const dineroCurrenciesLookup = new Map(Object.values(currencies__namespace).map(currency => [currency.code, currency]));
32
- const floatToInt = (floatAmount, base, exponent) => constants.Round.Financial(floatAmount * Math.pow(base, exponent));
33
- const decimalToDinero = (decimalAmount, currency) => {
34
- const parsedNumber = typeof decimalAmount === "number" ? decimalAmount : Number.parseFloat(decimalAmount);
35
- number.isFloat(parsedNumber);
36
- const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(10, currency.exponent)).toFixed(0));
37
- return dinero_js.dinero({
38
- amount: parsedNumberInt,
39
- currency
40
- });
41
- };
42
- exports.currencyLookup = currencyLookup;
43
- exports.decimalToDinero = decimalToDinero;
44
- exports.dineroCurrenciesLookup = dineroCurrenciesLookup;
45
- exports.floatToInt = floatToInt;
46
- //# sourceMappingURL=misc.private.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.private.js","sources":["../../../src/utils/money/misc.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport * as currencies from \"@dinero.js/currencies\";\nimport { dinero } from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { isFloat } from \"../number\";\nimport { Round } from \"./constants\";\nimport type { DinoCurrency } from \"./types\";\n\n/**\n * Fast lookup for our custom currency enum to check that given currency is valid\n */\nexport const currencyLookup = new Set(\n Object.keys(Currency).map((el) => el.toString()),\n);\n\n/**\n * Dinero currency lookup to check that given currency is valid\n */\nexport const dineroCurrenciesLookup = new Map(\n Object.values(currencies).map((currency) => [currency.code, currency]),\n);\n\n/**\n * Private util to convert a float value into a int. Also applies financial rounding to the value if needed.\n * Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats\n * @example\n * floatToInt(69.10, 10, 2); // 6910\n * floatToInt(42, 10, 2); // 4200\n * floatToInt(0.22, 10, 6); // 220000\n */\nexport const floatToInt = (\n floatAmount: number,\n base: number,\n exponent: number,\n // FIXME: pass in the rounding method and or use roundDinero\n): number => Round.Financial(floatAmount * Math.pow(base, exponent));\n\n/**\n * FIXME: is it private tho?!\n */\nexport const decimalToDinero = (\n decimalAmount: string | number,\n currency: DinoCurrency,\n // FIXME: rounding method?!\n) => {\n const parsedNumber =\n typeof decimalAmount === \"number\"\n ? decimalAmount\n : Number.parseFloat(decimalAmount);\n isFloat(parsedNumber);\n\n const parsedNumberInt = Number.parseInt(\n (parsedNumber * Math.pow(10, currency.exponent)).toFixed(0),\n );\n return dinero({\n amount: parsedNumberInt,\n currency,\n });\n};\n"],"names":["currencyLookup","Set","Object","keys","Currency","map","el","toString","dineroCurrenciesLookup","Map","values","currencies","currency","code","floatToInt","floatAmount","base","exponent","Round","Financial","Math","pow","decimalToDinero","decimalAmount","parsedNumber","Number","parseFloat","isFloat","parsedNumberInt","parseInt","toFixed","dinero","amount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAMA,iBAAiB,IAAIC,GAAA,CAChCC,MAAA,CAAOC,KAAKC,SAAAA,CAAAA,QAAQ,CAAA,CAAEC,IAAKC,EAAA,IAAOA,EAAG,CAAAC,QAAA,EAAU,CACjD,CAAA;AAKO,MAAMC,yBAAyB,IAAIC,GAAA,CACxCP,MAAA,CAAOQ,MAAO,CAAAC,qBAAU,CAAE,CAAAN,GAAA,CAAKO,QAAA,IAAa,CAACA,QAAA,CAASC,IAAM,EAAAD,QAAQ,CAAC,CACvE,CAAA;AAUO,MAAME,UAAa,GAAAA,CACxBC,WACA,EAAAC,IAAA,EACAC,QAEW,KAAAC,SAAA,CAAAA,KAAA,CAAMC,SAAU,CAAAJ,WAAA,GAAcK,IAAK,CAAAC,GAAA,CAAIL,IAAM,EAAAC,QAAQ,CAAC,CAAA;AAKtD,MAAAK,eAAA,GAAkBA,CAC7BC,aAAA,EACAX,QAEG,KAAA;EACH,MAAMY,eACJ,OAAOD,aAAA,KAAkB,WACrBA,aACA,GAAAE,MAAA,CAAOC,WAAWH,aAAa,CAAA;EACrCI,MAAA,CAAAA,OAAA,CAAQH,YAAY,CAAA;EAEpB,MAAMI,kBAAkBH,MAAO,CAAAI,QAAA,CAC5B,CAAAL,YAAA,GAAeJ,KAAKC,GAAI,CAAA,EAAA,EAAIT,SAASK,QAAQ,CAAA,EAAGa,QAAQ,CAAC,CAAA,CAC5D;EACA,OAAOC,gBAAO,CAAA;IACZC,MAAQ,EAAAJ,eAAA;IACRhB;EAAA,CACD,CAAA;AACH,CAAA;;;;"}
@@ -1,21 +0,0 @@
1
- import * as currencies from '@dinero.js/currencies';
2
- import { dinero } from 'dinero.js';
3
- import '../../types/index.mjs';
4
- import { isFloat } from '../number.mjs';
5
- import { Round } from './constants.mjs';
6
- import { Currency } from '../../types/generated.mjs';
7
- "use strict";
8
- const currencyLookup = new Set(Object.keys(Currency).map(el => el.toString()));
9
- const dineroCurrenciesLookup = new Map(Object.values(currencies).map(currency => [currency.code, currency]));
10
- const floatToInt = (floatAmount, base, exponent) => Round.Financial(floatAmount * Math.pow(base, exponent));
11
- const decimalToDinero = (decimalAmount, currency) => {
12
- const parsedNumber = typeof decimalAmount === "number" ? decimalAmount : Number.parseFloat(decimalAmount);
13
- isFloat(parsedNumber);
14
- const parsedNumberInt = Number.parseInt((parsedNumber * Math.pow(10, currency.exponent)).toFixed(0));
15
- return dinero({
16
- amount: parsedNumberInt,
17
- currency
18
- });
19
- };
20
- export { currencyLookup, decimalToDinero, dineroCurrenciesLookup, floatToInt };
21
- //# sourceMappingURL=misc.private.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"misc.private.mjs","sources":["../../../src/utils/money/misc.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport * as currencies from \"@dinero.js/currencies\";\nimport { dinero } from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { isFloat } from \"../number\";\nimport { Round } from \"./constants\";\nimport type { DinoCurrency } from \"./types\";\n\n/**\n * Fast lookup for our custom currency enum to check that given currency is valid\n */\nexport const currencyLookup = new Set(\n Object.keys(Currency).map((el) => el.toString()),\n);\n\n/**\n * Dinero currency lookup to check that given currency is valid\n */\nexport const dineroCurrenciesLookup = new Map(\n Object.values(currencies).map((currency) => [currency.code, currency]),\n);\n\n/**\n * Private util to convert a float value into a int. Also applies financial rounding to the value if needed.\n * Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats\n * @example\n * floatToInt(69.10, 10, 2); // 6910\n * floatToInt(42, 10, 2); // 4200\n * floatToInt(0.22, 10, 6); // 220000\n */\nexport const floatToInt = (\n floatAmount: number,\n base: number,\n exponent: number,\n // FIXME: pass in the rounding method and or use roundDinero\n): number => Round.Financial(floatAmount * Math.pow(base, exponent));\n\n/**\n * FIXME: is it private tho?!\n */\nexport const decimalToDinero = (\n decimalAmount: string | number,\n currency: DinoCurrency,\n // FIXME: rounding method?!\n) => {\n const parsedNumber =\n typeof decimalAmount === \"number\"\n ? decimalAmount\n : Number.parseFloat(decimalAmount);\n isFloat(parsedNumber);\n\n const parsedNumberInt = Number.parseInt(\n (parsedNumber * Math.pow(10, currency.exponent)).toFixed(0),\n );\n return dinero({\n amount: parsedNumberInt,\n currency,\n });\n};\n"],"names":["currencyLookup","Set","Object","keys","Currency","map","el","toString","dineroCurrenciesLookup","Map","values","currencies","currency","code","floatToInt","floatAmount","base","exponent","Round","Financial","Math","pow","decimalToDinero","decimalAmount","parsedNumber","Number","parseFloat","isFloat","parsedNumberInt","parseInt","toFixed","dinero","amount"],"mappings":";;;;;;;AAeO,MAAMA,iBAAiB,IAAIC,GAAA,CAChCC,MAAA,CAAOC,KAAKC,QAAQ,CAAA,CAAEC,IAAKC,EAAA,IAAOA,EAAG,CAAAC,QAAA,EAAU,CACjD,CAAA;AAKO,MAAMC,yBAAyB,IAAIC,GAAA,CACxCP,MAAA,CAAOQ,MAAO,CAAAC,UAAU,CAAE,CAAAN,GAAA,CAAKO,QAAA,IAAa,CAACA,QAAA,CAASC,IAAM,EAAAD,QAAQ,CAAC,CACvE,CAAA;AAUO,MAAME,UAAa,GAAAA,CACxBC,WACA,EAAAC,IAAA,EACAC,QAEW,KAAAC,KAAA,CAAMC,SAAU,CAAAJ,WAAA,GAAcK,IAAK,CAAAC,GAAA,CAAIL,IAAM,EAAAC,QAAQ,CAAC,CAAA;AAKtD,MAAAK,eAAA,GAAkBA,CAC7BC,aAAA,EACAX,QAEG,KAAA;EACH,MAAMY,eACJ,OAAOD,aAAA,KAAkB,WACrBA,aACA,GAAAE,MAAA,CAAOC,WAAWH,aAAa,CAAA;EACrCI,OAAA,CAAQH,YAAY,CAAA;EAEpB,MAAMI,kBAAkBH,MAAO,CAAAI,QAAA,CAC5B,CAAAL,YAAA,GAAeJ,KAAKC,GAAI,CAAA,EAAA,EAAIT,SAASK,QAAQ,CAAA,EAAGa,QAAQ,CAAC,CAAA,CAC5D;EACA,OAAOC,MAAO,CAAA;IACZC,MAAQ,EAAAJ,eAAA;IACRhB;EAAA,CACD,CAAA;AACH,CAAA;"}
@@ -1,5 +0,0 @@
1
- import type { Dino } from "./types";
2
- /**
3
- * Rounding for shipping price used only after applying
4
- */
5
- export declare const roundShippingPrice: (price: Dino) => Dino;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var constants = require('./constants.js');
4
- var misc = require('./misc.js');
5
- "use strict";
6
- const roundShippingPrice = price => misc.roundDinero(price, constants.Round.Shipping);
7
- exports.roundShippingPrice = roundShippingPrice;
8
- //# sourceMappingURL=shipping.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shipping.js","sources":["../../../src/utils/money/shipping.ts"],"sourcesContent":["import { Round } from \"./constants\";\nimport { roundDinero } from \"./misc\";\nimport type { Dino } from \"./types\";\n\n/**\n * Rounding for shipping price used only after applying\n */\nexport const roundShippingPrice = (price: Dino) =>\n roundDinero(price, Round.Shipping);\n"],"names":["roundShippingPrice","price","roundDinero","Round","Shipping"],"mappings":";;;;;AAOO,MAAMA,qBAAsBC,KAAA,IACjCC,IAAY,CAAAA,WAAA,CAAAD,KAAA,EAAOE,gBAAMC,QAAQ,CAAA;"}
@@ -1,6 +0,0 @@
1
- import { Round } from './constants.mjs';
2
- import { roundDinero } from './misc.mjs';
3
- "use strict";
4
- const roundShippingPrice = price => roundDinero(price, Round.Shipping);
5
- export { roundShippingPrice };
6
- //# sourceMappingURL=shipping.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shipping.mjs","sources":["../../../src/utils/money/shipping.ts"],"sourcesContent":["import { Round } from \"./constants\";\nimport { roundDinero } from \"./misc\";\nimport type { Dino } from \"./types\";\n\n/**\n * Rounding for shipping price used only after applying\n */\nexport const roundShippingPrice = (price: Dino) =>\n roundDinero(price, Round.Shipping);\n"],"names":["roundShippingPrice","price","roundDinero","Round","Shipping"],"mappings":";;;AAOO,MAAMA,qBAAsBC,KAAA,IACjCC,WAAY,CAAAD,KAAA,EAAOE,MAAMC,QAAQ,CAAA;"}
@@ -1,17 +0,0 @@
1
- import type { Dinero } from "dinero.js";
2
- import type { Cents, LineItemSummary, SingleLineItemSummary, TaxRate } from "./types";
3
- /**
4
- * Private helper to convert a floating number to a dinero friendly allocation integer pair
5
- * @see https://v2.dinerojs.com/docs/api/mutations/allocate
6
- * @example
7
- * taxRateToDineroAllocation(0.1) // [1, 9]
8
- * taxRateToDineroAllocation(0.5) // [5, 5]
9
- */
10
- export declare const taxRateToDineroAllocation: (taxRate: TaxRate) => [number, number];
11
- /**
12
- * Reverse engineer the taxable amount from "whole item" taxable amount into "per item" taxable amount for custom tax
13
- * rate calculations
14
- */
15
- export declare const allocatePerItemTaxableAmount: (itemSummary: LineItemSummary) => SingleLineItemSummary[];
16
- export declare const calculateWholeQtyLineItemTax: (itemSummary: LineItemSummary, taxRate: TaxRate) => Dinero<Cents>;
17
- export declare const calculatePerQtyLineItemTax: (itemSummary: LineItemSummary, taxRate: TaxRate) => Dinero<Cents>;