b23-lib 2.1.0 → 2.1.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 (82) hide show
  1. package/dist/Auth/index.js +1 -1
  2. package/dist/Auth/index.js.map +1 -1
  3. package/dist/Auth/index.mjs +1 -1
  4. package/dist/Auth/index.mjs.map +1 -1
  5. package/dist/Classes/Address.js +1 -1
  6. package/dist/Classes/Address.js.map +1 -1
  7. package/dist/Classes/Address.mjs +1 -1
  8. package/dist/Classes/Base.d.mts +30 -25
  9. package/dist/Classes/Base.d.ts +30 -25
  10. package/dist/Classes/Base.js +1 -1
  11. package/dist/Classes/Base.js.map +1 -1
  12. package/dist/Classes/Base.mjs +1 -1
  13. package/dist/Classes/Cart.js +2 -2
  14. package/dist/Classes/Cart.js.map +1 -1
  15. package/dist/Classes/Cart.mjs +1 -1
  16. package/dist/Classes/Coupon.js +1 -1
  17. package/dist/Classes/Coupon.js.map +1 -1
  18. package/dist/Classes/Coupon.mjs +1 -1
  19. package/dist/Classes/Customer.js +1 -1
  20. package/dist/Classes/Customer.js.map +1 -1
  21. package/dist/Classes/Customer.mjs +1 -1
  22. package/dist/Classes/Customer.mjs.map +1 -1
  23. package/dist/Classes/CustomerAddress.js +1 -1
  24. package/dist/Classes/CustomerAddress.js.map +1 -1
  25. package/dist/Classes/CustomerAddress.mjs +1 -1
  26. package/dist/Classes/CustomerAddress.mjs.map +1 -1
  27. package/dist/Classes/Inventory.js +1 -1
  28. package/dist/Classes/Inventory.js.map +1 -1
  29. package/dist/Classes/Inventory.mjs +1 -1
  30. package/dist/Classes/Inventory.mjs.map +1 -1
  31. package/dist/Classes/LineItem.d.mts +3 -3
  32. package/dist/Classes/LineItem.d.ts +3 -3
  33. package/dist/Classes/LineItem.js +2 -2
  34. package/dist/Classes/LineItem.js.map +1 -1
  35. package/dist/Classes/LineItem.mjs +1 -1
  36. package/dist/Classes/Order.js +2 -2
  37. package/dist/Classes/Order.js.map +1 -1
  38. package/dist/Classes/Order.mjs +1 -1
  39. package/dist/Classes/Payment.js +1 -1
  40. package/dist/Classes/Payment.js.map +1 -1
  41. package/dist/Classes/Payment.mjs +1 -1
  42. package/dist/Classes/Product.js +1 -1
  43. package/dist/Classes/Product.js.map +1 -1
  44. package/dist/Classes/Product.mjs +1 -1
  45. package/dist/Classes/ShoppingContainer.js +2 -2
  46. package/dist/Classes/ShoppingContainer.js.map +1 -1
  47. package/dist/Classes/ShoppingContainer.mjs +1 -1
  48. package/dist/Classes/TaxRule.js +2 -2
  49. package/dist/Classes/TaxRule.js.map +1 -1
  50. package/dist/Classes/TaxRule.mjs +1 -1
  51. package/dist/chunk-6KCJVEZD.mjs +2 -0
  52. package/dist/chunk-6KCJVEZD.mjs.map +1 -0
  53. package/dist/chunk-7NLMXN4H.mjs +2 -0
  54. package/dist/chunk-7NLMXN4H.mjs.map +1 -0
  55. package/dist/chunk-FGXEJC4J.mjs +2 -0
  56. package/dist/{chunk-G6UFVELO.mjs.map → chunk-FGXEJC4J.mjs.map} +1 -1
  57. package/dist/chunk-GMGMQ2NX.mjs +2 -0
  58. package/dist/{chunk-I3IWW4V2.mjs.map → chunk-GMGMQ2NX.mjs.map} +1 -1
  59. package/dist/chunk-OIR5JBJY.mjs +2 -0
  60. package/dist/chunk-OIR5JBJY.mjs.map +1 -0
  61. package/dist/chunk-TUT4BB3Z.mjs +3 -0
  62. package/dist/{chunk-NFRTZM45.mjs.map → chunk-TUT4BB3Z.mjs.map} +1 -1
  63. package/dist/{chunk-5KD2EW7O.mjs → chunk-YSUBOEFT.mjs} +2 -2
  64. package/dist/{chunk-5KD2EW7O.mjs.map → chunk-YSUBOEFT.mjs.map} +1 -1
  65. package/dist/{chunk-K6Q6YDUX.mjs → chunk-ZAHR3SJ2.mjs} +2 -2
  66. package/dist/{chunk-K6Q6YDUX.mjs.map → chunk-ZAHR3SJ2.mjs.map} +1 -1
  67. package/dist/index.d.mts +2 -24
  68. package/dist/index.d.ts +2 -24
  69. package/dist/index.js +2 -2
  70. package/dist/index.js.map +1 -1
  71. package/dist/index.mjs +2 -2
  72. package/dist/index.mjs.map +1 -1
  73. package/package.json +1 -1
  74. package/dist/chunk-55SOBG62.mjs +0 -2
  75. package/dist/chunk-55SOBG62.mjs.map +0 -1
  76. package/dist/chunk-AMIRIUMH.mjs +0 -2
  77. package/dist/chunk-AMIRIUMH.mjs.map +0 -1
  78. package/dist/chunk-G6UFVELO.mjs +0 -2
  79. package/dist/chunk-I3IWW4V2.mjs +0 -2
  80. package/dist/chunk-MJBRKWRU.mjs +0 -2
  81. package/dist/chunk-MJBRKWRU.mjs.map +0 -1
  82. package/dist/chunk-NFRTZM45.mjs +0 -3
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export{d as Fetch,b as Logger,c as ResponseUtility}from'./chunk-AMIRIUMH.mjs';import {b}from'./chunk-K6Q6YDUX.mjs';export{a as Utils}from'./chunk-K6Q6YDUX.mjs';import'./chunk-ZVLJ5BAG.mjs';import'./chunk-R32ZSPV6.mjs';import {l,j,a,b as b$1,c,d as d$1}from'./chunk-72DR3HF2.mjs';import'./chunk-7LEGYAOJ.mjs';import'./chunk-DGFO2MH6.mjs';import'./chunk-55SOBG62.mjs';var d={$id:"standards",definitions:{lowercaseText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]*$"},lowercaseText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,10}$"},lowercaseText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,16}$"},lowercaseText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,30}$"},lowercaseText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,50}$"},lowercaseText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,256}$"},text:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).*$"},text10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,10}$"},text16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,16}$"},text30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,30}$"},text50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,50}$"},text256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,256}$"},requiredText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).+$"},requiredText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,10}$"},requiredText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,16}$"},requiredText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,30}$"},requiredText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,50}$"},requiredText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,256}$"},url:{type:"string",pattern:"^https://[^\\s/$.?#].[^\\s]*$",maxLength:2048},uuid:{type:"string",minLength:1,pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"},productKey:{type:"string",pattern:b.productKeyRegex.source},productSku:{type:"string",pattern:b.productSKURegex.source},taxCategory:{type:"string",enum:Object.values(l)},genderCategory:{type:"string",enum:Object.values(j)},price:{type:"object",properties:{amount:{type:"number",minimum:0},currency:{$ref:"#/definitions/currency"}},required:["amount","currency"]},color:{type:"object",properties:{name:{type:"string"},hexCode:{type:"string"}},required:["name"]},attributeValue:{oneOf:[{type:"string"},{$ref:"#/definitions/color"}]},selectionAttributes:{type:"object",properties:{color:{$ref:"#/definitions/color"}},required:["color"],additionalProperties:{$ref:"#/definitions/attributeValue"}},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},company:{$ref:"#/definitions/text50"},phone:{type:"string",pattern:"^[0-9]{10}$"},email:{type:"string",pattern:"^[^\\s]+@[^\\s]+\\.[^\\s]+$"},addressLine1:{$ref:"#/definitions/requiredText50"},addressLine2:{$ref:"#/definitions/text50"},city:{$ref:"#/definitions/requiredText30"},postalCode:{$ref:"#/definitions/requiredText16"},state:{type:"string",enum:["AP","AR","AS","BR","CT","GA","GJ","HR","HP","JH","KA","KL","MP","MH","MN","ML","MZ","NL","OR","PB","RJ","SK","TN","TG","TR","UP","UT","WB","AN","CH","DH","LD","DL","PY","LA","JK"]},country:{type:"string",enum:Object.values(a)},currency:{type:"string",enum:Object.values(b$1)},locale:{type:"string",enum:Object.values(c)},language:{type:"string",enum:Object.values(d$1)},localeOrLanguage:{type:"string",enum:[...Object.values(c),...Object.values(d$1)]},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},company:{$ref:"standards#/definitions/company"},phone:{$ref:"standards#/definitions/phone"},email:{$ref:"standards#/definitions/email"},addressLine1:{$ref:"standards#/definitions/addressLine1"},addressLine2:{$ref:"standards#/definitions/addressLine2"},city:{$ref:"standards#/definitions/city"},postalCode:{$ref:"standards#/definitions/postalCode"},state:{$ref:"standards#/definitions/state"},country:{$ref:"standards#/definitions/country"}},required:["firstName","lastName","phone","email","addressLine1","postalCode","state","country"]}}};var $={getStandardSchemaDefinition(){return d}},g=$;
2
- export{g as Schema};//# sourceMappingURL=index.mjs.map
1
+ export{b as Logger,c as ResponseUtility}from'./chunk-OIR5JBJY.mjs';import {b}from'./chunk-ZAHR3SJ2.mjs';export{a as Utils}from'./chunk-ZAHR3SJ2.mjs';import'./chunk-ZVLJ5BAG.mjs';import'./chunk-R32ZSPV6.mjs';import {l,j,a,b as b$1,c as c$1,d as d$1}from'./chunk-72DR3HF2.mjs';import'./chunk-7LEGYAOJ.mjs';import'./chunk-DGFO2MH6.mjs';import'./chunk-6KCJVEZD.mjs';var d={$id:"standards",definitions:{lowercaseText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]*$"},lowercaseText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,10}$"},lowercaseText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,16}$"},lowercaseText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,30}$"},lowercaseText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,50}$"},lowercaseText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,256}$"},text:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).*$"},text10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,10}$"},text16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,16}$"},text30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,30}$"},text50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,50}$"},text256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,256}$"},requiredText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).+$"},requiredText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,10}$"},requiredText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,16}$"},requiredText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,30}$"},requiredText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,50}$"},requiredText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,256}$"},url:{type:"string",pattern:"^https://[^\\s/$.?#].[^\\s]*$",maxLength:2048},uuid:{type:"string",minLength:1,pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"},productKey:{type:"string",pattern:b.productKeyRegex.source},productSku:{type:"string",pattern:b.productSKURegex.source},taxCategory:{type:"string",enum:Object.values(l)},genderCategory:{type:"string",enum:Object.values(j)},price:{type:"object",properties:{amount:{type:"number",minimum:0},currency:{$ref:"#/definitions/currency"}},required:["amount","currency"]},color:{type:"object",properties:{name:{type:"string"},hexCode:{type:"string"}},required:["name"]},attributeValue:{oneOf:[{type:"string"},{$ref:"#/definitions/color"}]},selectionAttributes:{type:"object",properties:{color:{$ref:"#/definitions/color"}},required:["color"],additionalProperties:{$ref:"#/definitions/attributeValue"}},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},company:{$ref:"#/definitions/text50"},phone:{type:"string",pattern:"^[0-9]{10}$"},email:{type:"string",pattern:"^[^\\s]+@[^\\s]+\\.[^\\s]+$"},addressLine1:{$ref:"#/definitions/requiredText50"},addressLine2:{$ref:"#/definitions/text50"},city:{$ref:"#/definitions/requiredText30"},postalCode:{$ref:"#/definitions/requiredText16"},state:{type:"string",enum:["AP","AR","AS","BR","CT","GA","GJ","HR","HP","JH","KA","KL","MP","MH","MN","ML","MZ","NL","OR","PB","RJ","SK","TN","TG","TR","UP","UT","WB","AN","CH","DH","LD","DL","PY","LA","JK"]},country:{type:"string",enum:Object.values(a)},currency:{type:"string",enum:Object.values(b$1)},locale:{type:"string",enum:Object.values(c$1)},language:{type:"string",enum:Object.values(d$1)},localeOrLanguage:{type:"string",enum:[...Object.values(c$1),...Object.values(d$1)]},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},company:{$ref:"standards#/definitions/company"},phone:{$ref:"standards#/definitions/phone"},email:{$ref:"standards#/definitions/email"},addressLine1:{$ref:"standards#/definitions/addressLine1"},addressLine2:{$ref:"standards#/definitions/addressLine2"},city:{$ref:"standards#/definitions/city"},postalCode:{$ref:"standards#/definitions/postalCode"},state:{$ref:"standards#/definitions/state"},country:{$ref:"standards#/definitions/country"}},required:["firstName","lastName","phone","email","addressLine1","postalCode","state","country"]}}};var c={getStandardSchemaDefinition(){return d}},$=c;
2
+ export{$ as Schema};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Schema/definition.ts","../src/Schema/index.ts"],"names":["definition_default","ProductModel","TaxCategory","GenderCategory","OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","Schema","Schema_default"],"mappings":"8WAGA,IAAOA,CAAQ,CAAA,CACb,GAAO,CAAA,WAAA,CACP,WAAe,CAAA,CACX,aAAiB,CAAA,CACb,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,2BACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CAAA,CACA,eAAmB,CAAA,CACf,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,gCACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CAAA,CACA,eAAmB,CAAA,CACf,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,gCACf,CACA,CAAA,gBAAA,CAAoB,CAChB,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,iCACf,CAAA,CACA,IAAQ,CAAA,CACJ,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,uBACf,CACA,CAAA,MAAA,CAAU,CACN,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,4BACf,CACA,CAAA,MAAA,CAAU,CACN,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,4BACf,CAAA,CACA,MAAU,CAAA,CACN,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,4BACf,CACA,CAAA,MAAA,CAAU,CACN,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,4BACf,CAAA,CACA,OAAW,CAAA,CACP,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,6BACf,CACA,CAAA,YAAA,CAAgB,CACZ,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,uBACf,CAAA,CACA,cAAkB,CAAA,CACd,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,4BACf,CACA,CAAA,cAAA,CAAkB,CACd,IAAA,CAAQ,QACR,CAAA,OAAA,CA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CAAsC,CAAA,CAChE,IAAQ,CAAA,CAAE,IAAQ,CAAA,6BAA8B,CAChD,CAAA,UAAA,CAAc,CAAE,IAAA,CAAQ,mCAAoC,CAAA,CAC5D,MAAS,CAAE,IAAA,CAAQ,8BAA+B,CAAA,CAClD,OAAW,CAAA,CAAE,IAAQ,CAAA,gCAAiC,CAC1D,CAAA,CACA,QAAY,CAAA,CAAC,WAAa,CAAA,UAAA,CAAY,OAAS,CAAA,OAAA,CAAS,cAAgB,CAAA,YAAA,CAAc,OAAS,CAAA,SAAS,CAC5G,CACJ,CACF,CAAA,CC3MMC,IAAAA,CAAAA,CAAS,CACb,2BAAA,EAA8B,CAC5B,OAAOR,CACT,CACF,EAEOS,CAAQD,CAAAA","file":"index.mjs","sourcesContent":["import { GenderCategory, OperationalCountry, OperationalCountryCurrency, OperationalLanguage, OperationalLocale, TaxCategory } from \"../Classes/Enum\";\r\nimport ProductModel from \"../Classes/Product\";\r\n\r\nexport default {\r\n \"$id\": \"standards\",\r\n \"definitions\": {\r\n \"lowercaseText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]*$\"\r\n },\r\n \"lowercaseText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,10}$\"\r\n },\r\n \"lowercaseText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,16}$\"\r\n },\r\n \"lowercaseText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,30}$\"\r\n },\r\n \"lowercaseText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,50}$\"\r\n },\r\n \"lowercaseText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,256}$\"\r\n },\r\n \"text\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).*$\"\r\n },\r\n \"text10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,10}$\"\r\n },\r\n \"text16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,16}$\"\r\n },\r\n \"text30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,30}$\"\r\n },\r\n \"text50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,50}$\"\r\n },\r\n \"text256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,256}$\"\r\n },\r\n \"requiredText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).+$\"\r\n },\r\n \"requiredText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,10}$\"\r\n },\r\n \"requiredText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,16}$\"\r\n },\r\n \"requiredText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,30}$\"\r\n },\r\n \"requiredText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,50}$\"\r\n },\r\n \"requiredText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,256}$\"\r\n },\r\n \"url\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^https://[^\\\\s/$.?#].[^\\\\s]*$\",\r\n \"maxLength\": 2048\r\n },\r\n \"uuid\": {\r\n \"type\": \"string\",\r\n \"minLength\": 1,\r\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"\r\n },\r\n \"productKey\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productKeyRegex.source\r\n },\r\n \"productSku\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productSKURegex.source\r\n },\r\n \"taxCategory\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(TaxCategory)\r\n },\r\n \"genderCategory\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(GenderCategory)\r\n },\r\n \"price\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"amount\": { \"type\": \"number\", \"minimum\": 0 },\r\n \"currency\": { \"$ref\": \"#/definitions/currency\" }\r\n },\r\n \"required\": [\"amount\", \"currency\"]\r\n },\r\n \"color\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"name\": {\r\n \"type\": \"string\"\r\n },\r\n \"hexCode\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"required\": [\r\n \"name\"\r\n ]\r\n },\r\n \"attributeValue\": {\r\n \"oneOf\": [\r\n { \"type\": \"string\" },\r\n {\r\n \"$ref\": \"#/definitions/color\"\r\n }\r\n ]\r\n },\r\n \"selectionAttributes\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"color\": { \"$ref\": \"#/definitions/color\" }\r\n },\r\n \"required\": [\"color\"],\r\n \"additionalProperties\": {\r\n \"$ref\": \"#/definitions/attributeValue\"\r\n }\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\r\n \"company\": { \"$ref\": \"#/definitions/text50\" },\r\n \"phone\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[0-9]{10}$\"\r\n },\r\n \"email\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[^\\\\s]+@[^\\\\s]+\\\\.[^\\\\s]+$\"\r\n },\r\n \"addressLine1\": { \"$ref\": \"#/definitions/requiredText50\" },\r\n \"addressLine2\": { \"$ref\": \"#/definitions/text50\" },\r\n \"city\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"postalCode\": { \"$ref\": \"#/definitions/requiredText16\" },\r\n \"state\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"AP\", \"AR\", \"AS\", \"BR\", \"CT\", \"GA\", \"GJ\", \"HR\", \"HP\", \"JH\", \"KA\", \"KL\", \"MP\", \"MH\", \"MN\", \"ML\", \"MZ\", \"NL\", \"OR\", \"PB\", \"RJ\", \"SK\", \"TN\", \"TG\", \"TR\", \"UP\", \"UT\", \"WB\", \"AN\", \"CH\", \"DH\", \"LD\", \"DL\", \"PY\", \"LA\", \"JK\"]\r\n },\r\n \"country\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountry)\r\n },\r\n \"currency\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountryCurrency)\r\n },\r\n \"locale\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLocale)\r\n },\r\n \"language\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLanguage)\r\n },\r\n \"localeOrLanguage\": {\r\n \"type\": \"string\",\r\n \"enum\": [...Object.values(OperationalLocale), ...Object.values(OperationalLanguage)]\r\n },\r\n \"addressType\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"shipping\", \"billing\", \"billing&shipping\"]\r\n },\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"firstName\": {\"$ref\": \"standards#/definitions/firstName\"},\r\n \"lastName\": { \"$ref\": \"standards#/definitions/lastName\" },\r\n \"company\": { \"$ref\": \"standards#/definitions/company\" },\r\n \"phone\": { \"$ref\": \"standards#/definitions/phone\" },\r\n \"email\": { \"$ref\": \"standards#/definitions/email\" },\r\n \"addressLine1\": { \"$ref\": \"standards#/definitions/addressLine1\" },\r\n \"addressLine2\": { \"$ref\": \"standards#/definitions/addressLine2\" },\r\n \"city\": { \"$ref\": \"standards#/definitions/city\" },\r\n \"postalCode\": { \"$ref\": \"standards#/definitions/postalCode\" },\r\n \"state\": { \"$ref\": \"standards#/definitions/state\" },\r\n \"country\": { \"$ref\": \"standards#/definitions/country\" }\r\n },\r\n \"required\": [\"firstName\", \"lastName\", \"phone\", \"email\", \"addressLine1\", \"postalCode\", \"state\", \"country\"]\r\n }\r\n }\r\n}","import SchemaDefinitions from './definition';\r\n\r\nconst Schema = {\r\n getStandardSchemaDefinition() {\r\n return SchemaDefinitions;\r\n }\r\n}\r\n\r\nexport default Schema;\r\n"]}
1
+ {"version":3,"sources":["../src/Schema/definition.ts","../src/Schema/index.ts"],"names":["definition_default","ProductModel","TaxCategory","GenderCategory","OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","Schema","Schema_default"],"mappings":"0WAGA,IAAOA,CAAQ,CAAA,CACb,GAAO,CAAA,WAAA,CACP,WAAe,CAAA,CACX,aAAiB,CAAA,CACb,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,2BACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CAAA,CACA,eAAmB,CAAA,CACf,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,gCACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CAAA,CACA,eAAmB,CAAA,CACf,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,gCACf,CACA,CAAA,gBAAA,CAAoB,CAChB,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,iCACf,CAAA,CACA,IAAQ,CAAA,CACJ,IAAQ,CAAA,QAAA,CACR,OAAW,CAAA,uBACf,CACA,CAAA,MAAA,CAAU,CACN,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,4BACf,CACA,CAAA,MAAA,CAAU,CACN,IAAA,CAAQ,QACR,CAAA,OAAA,CAAW,4B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kB,CACtD,CAAA,CACA,OAAW,CAAA,CACP,IAAQ,CAAA,QAAA,CACR,UAAc,CAAA,CACV,SAAa,CAAA,CAAC,IAAQ,CAAA,kCAAkC,CACxD,CAAA,QAAA,CAAY,CAAE,IAAA,CAAQ,iCAAkC,CAAA,CACxD,OAAW,CAAA,CAAE,KAAQ,gCAAiC,CAAA,CACtD,KAAS,CAAA,CAAE,IAAQ,CAAA,8BAA+B,CAClD,CAAA,KAAA,CAAS,CAAE,IAAA,CAAQ,8BAA+B,CAAA,CAClD,YAAgB,CAAA,CAAE,IAAQ,CAAA,qCAAsC,CAChE,CAAA,YAAA,CAAgB,CAAE,IAAA,CAAQ,qCAAsC,CAAA,CAChE,IAAQ,CAAA,CAAE,IAAQ,CAAA,6BAA8B,CAChD,CAAA,UAAA,CAAc,CAAE,IAAA,CAAQ,mCAAoC,CAAA,CAC5D,MAAS,CAAE,IAAA,CAAQ,8BAA+B,CAAA,CAClD,OAAW,CAAA,CAAE,IAAQ,CAAA,gCAAiC,CAC1D,CAAA,CACA,QAAY,CAAA,CAAC,WAAa,CAAA,UAAA,CAAY,OAAS,CAAA,OAAA,CAAS,cAAgB,CAAA,YAAA,CAAc,OAAS,CAAA,SAAS,CAC5G,CACJ,CACF,CAAA,CC3MMC,IAAAA,CAAAA,CAAS,CACb,2BAAA,EAA8B,CAC5B,OAAOR,CACT,CACF,EAEOS,CAAQD,CAAAA","file":"index.mjs","sourcesContent":["import { GenderCategory, OperationalCountry, OperationalCountryCurrency, OperationalLanguage, OperationalLocale, TaxCategory } from \"../Classes/Enum\";\r\nimport ProductModel from \"../Classes/Product\";\r\n\r\nexport default {\r\n \"$id\": \"standards\",\r\n \"definitions\": {\r\n \"lowercaseText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]*$\"\r\n },\r\n \"lowercaseText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,10}$\"\r\n },\r\n \"lowercaseText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,16}$\"\r\n },\r\n \"lowercaseText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,30}$\"\r\n },\r\n \"lowercaseText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,50}$\"\r\n },\r\n \"lowercaseText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[a-z]{0,256}$\"\r\n },\r\n \"text\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).*$\"\r\n },\r\n \"text10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,10}$\"\r\n },\r\n \"text16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,16}$\"\r\n },\r\n \"text30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,30}$\"\r\n },\r\n \"text50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,50}$\"\r\n },\r\n \"text256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{0,256}$\"\r\n },\r\n \"requiredText\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).+$\"\r\n },\r\n \"requiredText10\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,10}$\"\r\n },\r\n \"requiredText16\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,16}$\"\r\n },\r\n \"requiredText30\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,30}$\"\r\n },\r\n \"requiredText50\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,50}$\"\r\n },\r\n \"requiredText256\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$).{1,256}$\"\r\n },\r\n \"url\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^https://[^\\\\s/$.?#].[^\\\\s]*$\",\r\n \"maxLength\": 2048\r\n },\r\n \"uuid\": {\r\n \"type\": \"string\",\r\n \"minLength\": 1,\r\n \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"\r\n },\r\n \"productKey\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productKeyRegex.source\r\n },\r\n \"productSku\": {\r\n \"type\": \"string\",\r\n \"pattern\": ProductModel.productSKURegex.source\r\n },\r\n \"taxCategory\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(TaxCategory)\r\n },\r\n \"genderCategory\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(GenderCategory)\r\n },\r\n \"price\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"amount\": { \"type\": \"number\", \"minimum\": 0 },\r\n \"currency\": { \"$ref\": \"#/definitions/currency\" }\r\n },\r\n \"required\": [\"amount\", \"currency\"]\r\n },\r\n \"color\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"name\": {\r\n \"type\": \"string\"\r\n },\r\n \"hexCode\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"required\": [\r\n \"name\"\r\n ]\r\n },\r\n \"attributeValue\": {\r\n \"oneOf\": [\r\n { \"type\": \"string\" },\r\n {\r\n \"$ref\": \"#/definitions/color\"\r\n }\r\n ]\r\n },\r\n \"selectionAttributes\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"color\": { \"$ref\": \"#/definitions/color\" }\r\n },\r\n \"required\": [\"color\"],\r\n \"additionalProperties\": {\r\n \"$ref\": \"#/definitions/attributeValue\"\r\n }\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\r\n \"company\": { \"$ref\": \"#/definitions/text50\" },\r\n \"phone\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[0-9]{10}$\"\r\n },\r\n \"email\": { \r\n \"type\" : \"string\",\r\n \"pattern\": \"^[^\\\\s]+@[^\\\\s]+\\\\.[^\\\\s]+$\"\r\n },\r\n \"addressLine1\": { \"$ref\": \"#/definitions/requiredText50\" },\r\n \"addressLine2\": { \"$ref\": \"#/definitions/text50\" },\r\n \"city\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"postalCode\": { \"$ref\": \"#/definitions/requiredText16\" },\r\n \"state\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"AP\", \"AR\", \"AS\", \"BR\", \"CT\", \"GA\", \"GJ\", \"HR\", \"HP\", \"JH\", \"KA\", \"KL\", \"MP\", \"MH\", \"MN\", \"ML\", \"MZ\", \"NL\", \"OR\", \"PB\", \"RJ\", \"SK\", \"TN\", \"TG\", \"TR\", \"UP\", \"UT\", \"WB\", \"AN\", \"CH\", \"DH\", \"LD\", \"DL\", \"PY\", \"LA\", \"JK\"]\r\n },\r\n \"country\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountry)\r\n },\r\n \"currency\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalCountryCurrency)\r\n },\r\n \"locale\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLocale)\r\n },\r\n \"language\": {\r\n \"type\": \"string\",\r\n \"enum\": Object.values(OperationalLanguage)\r\n },\r\n \"localeOrLanguage\": {\r\n \"type\": \"string\",\r\n \"enum\": [...Object.values(OperationalLocale), ...Object.values(OperationalLanguage)]\r\n },\r\n \"addressType\": {\r\n \"type\": \"string\",\r\n \"enum\": [\"shipping\", \"billing\", \"billing&shipping\"]\r\n },\r\n \"address\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"firstName\": {\"$ref\": \"standards#/definitions/firstName\"},\r\n \"lastName\": { \"$ref\": \"standards#/definitions/lastName\" },\r\n \"company\": { \"$ref\": \"standards#/definitions/company\" },\r\n \"phone\": { \"$ref\": \"standards#/definitions/phone\" },\r\n \"email\": { \"$ref\": \"standards#/definitions/email\" },\r\n \"addressLine1\": { \"$ref\": \"standards#/definitions/addressLine1\" },\r\n \"addressLine2\": { \"$ref\": \"standards#/definitions/addressLine2\" },\r\n \"city\": { \"$ref\": \"standards#/definitions/city\" },\r\n \"postalCode\": { \"$ref\": \"standards#/definitions/postalCode\" },\r\n \"state\": { \"$ref\": \"standards#/definitions/state\" },\r\n \"country\": { \"$ref\": \"standards#/definitions/country\" }\r\n },\r\n \"required\": [\"firstName\", \"lastName\", \"phone\", \"email\", \"addressLine1\", \"postalCode\", \"state\", \"country\"]\r\n }\r\n }\r\n}","import SchemaDefinitions from './definition';\r\n\r\nconst Schema = {\r\n getStandardSchemaDefinition() {\r\n return SchemaDefinitions;\r\n }\r\n}\r\n\r\nexport default Schema;\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b23-lib",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "This repo hold common classes, type and util functiona",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,2 +0,0 @@
1
- var i=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){this.customFields={...e.customFields},this.version=e.version??1,this.createdAt=e.createdAt&&!isNaN(Date.parse(e.createdAt))?new Date(e.createdAt).toISOString():t.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():t.toISOString(),this.modifiedBy={...e.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(e,t,s,r){this.modifiedBy={id:e,authType:t,requestId:s,lambdaName:r};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}};export{i as a};//# sourceMappingURL=chunk-55SOBG62.mjs.map
2
- //# sourceMappingURL=chunk-55SOBG62.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Classes/Base.ts"],"names":["BaseModel","data","date","id","authType","requestId","lambdaName","fieldName","value"],"mappings":"AA4BqBA,IAAAA,CAAAA,CAArB,KAA+B,CACnB,YAAA,CACA,QACA,SACA,CAAA,UAAA,CACA,WAQV,WAAYC,CAAAA,CAAAA,CAAsBC,EAAa,IAAI,IAAA,CAAQ,CACzD,IAAK,CAAA,YAAA,CAAe,CAAE,GAAGD,CAAAA,CAAK,YAAa,CAAA,CAC3C,IAAK,CAAA,OAAA,CAAUA,EAAK,OAAW,EAAA,CAAA,CAC/B,KAAK,SAAYA,CAAAA,CAAAA,CAAK,WAAa,CAAC,KAAA,CAAM,IAAK,CAAA,KAAA,CAAMA,CAAK,CAAA,SAAS,CAAC,CAElE,CAAA,IAAI,KAAKA,CAAK,CAAA,SAAS,EAAE,WAAY,EAAA,CAErCC,CAAK,CAAA,WAAA,EACP,CAAA,IAAA,CAAK,WAAaD,CAAK,CAAA,UAAA,EAAc,CAAC,KAAM,CAAA,IAAA,CAAK,MAAMA,CAAK,CAAA,UAAU,CAAC,CACnE,CAAA,IAAI,KAAKA,CAAK,CAAA,UAAU,EAAE,WAAY,EAAA,CACtCC,EAAK,WAAY,EAAA,CAErB,IAAK,CAAA,UAAA,CAAa,CAAE,GAAGD,EAAK,UAAW,EACzC,CAMA,UAAuB,EAAA,CACrB,OAAO,CACL,YAAA,CAAc,IAAK,CAAA,kBAAA,EACnB,CAAA,OAAA,CAAS,KAAK,UAAW,EAAA,CACzB,UAAW,IAAK,CAAA,YAAA,GAChB,UAAY,CAAA,IAAA,CAAK,aAAc,EAAA,CAC/B,UAAY,CAAA,IAAA,CAAK,eACnB,CACF,CAMA,UAAqB,EAAA,CACnB,OAAO,IAAK,CAAA,OACd,CAMA,YAAuB,EAAA,CACrB,OAAO,IAAK,CAAA,SACd,CAMA,gBAA2B,EAAA,CACzB,OAAO,IAAI,IAAA,CAAK,IAAK,CAAA,SAAS,CAAE,CAAA,OAAA,EAClC,CAOA,aAAA,EAAwB,CACtB,OAAO,IAAA,CAAK,UACd,CAMA,iBAAA,EAA4B,CAC1B,OAAO,IAAI,IAAA,CAAK,KAAK,UAAU,CAAA,CAAE,SACnC,CAMA,eAA4B,CAC1B,OAAO,CAAE,GAAG,IAAK,CAAA,UAAW,CAC9B,CAMA,aAAA,CAAcE,EAAaC,CAAqBC,CAAAA,CAAAA,CAAoBC,EAA2B,CAC7F,IAAA,CAAK,WAAa,CAChB,EAAA,CAAAH,EACA,QAAAC,CAAAA,CAAAA,CACA,UAAAC,CACA,CAAA,UAAA,CAAAC,CACF,EACF,CAOA,cAAeC,CAAAA,CAAAA,CAAwB,CACrC,OAAO,KAAK,YAAaA,CAAAA,CAAS,GAAK,IACzC,CAQA,eAAeA,CAAmBC,CAAAA,CAAAA,CAAkB,CAClD,IAAA,CAAK,YAAaD,CAAAA,CAAS,EAAIC,EACjC,CAMA,oBAAmC,CACjC,OAAO,CAAE,GAAG,IAAA,CAAK,YAAa,CAChC,CACF","file":"chunk-55SOBG62.mjs","sourcesContent":["import { AuthType } from \"../Auth\";\r\nimport { ISODateTimeUTC } from \"./Common\";\r\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type ModifiedBy = {\r\n id?: string;\r\n authType?: string;\r\n requestId?: string;\r\n lambdaName?: string;\r\n}\r\n\r\nexport type BaseAttributes = {\r\n customFields?: CustomFields;\r\n version?: number;\r\n createdAt?: ISODateTimeUTC;\r\n modifiedAt?: ISODateTimeUTC;\r\n modifiedBy?: ModifiedBy;\r\n};\r\n\r\nexport type BaseData = Required<BaseAttributes>;\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel {\r\n protected customFields: CustomFields;\r\n protected version: number;\r\n protected createdAt: ISODateTimeUTC;\r\n protected modifiedAt: ISODateTimeUTC;\r\n protected modifiedBy: ModifiedBy;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = { ...data.modifiedBy };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns\r\n */\r\n getModifiedBy(): ModifiedBy {\r\n return { ...this.modifiedBy };\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(id?: string, authType?: AuthType, requestId?: string, lambdaName?: string): void {\r\n this.modifiedBy = {\r\n id,\r\n authType,\r\n requestId,\r\n lambdaName,\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\r\n return this.customFields[fieldName] ?? null;\r\n }\r\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\r\n return { ...this.customFields };\r\n }\r\n}\r\n"]}
@@ -1,2 +0,0 @@
1
- import S from'util';var i=Object.freeze({INVALID_UUID:"Invalid UUID",INVALID_EMAIL:"Invalid Email",INVALID_TOKEN:"Invalid Token",TOKEN_EXPIRED:"Token Expired",INVALID_VERIFIER:"Invalid Verifier",INVALID_PERMISSIONS:"Invalid Permissions",INVALID_AUTH_TYPE:"Invalid Authorization Type",USER_PRIVATE_KEY_NOT_FOUND:"User Private Key Not Found",USER_PUBLIC_KEY_NOT_FOUND:"User Public Key Not Found",ANONYMOUS_PRIVATE_KEY_NOT_FOUND:"Anonymous Private Key Not Found",ANONYMOUS_PUBLIC_KEY_NOT_FOUND:"Anonymous Public Key Not Found",SYSTEM_PRIVATE_KEY_NOT_FOUND:"System Private Key Not Found",SYSTEM_PUBLIC_KEY_NOT_FOUND:"System Public Key Not Found",ADMIN_PRIVATE_KEY_NOT_FOUND:"Admin Private Key Not Found",ADMIN_PUBLIC_KEY_NOT_FOUND:"Admin Public Key Not Found",SECRET_TOKEN_NOT_FOUND:"Secret Token Not Found",ANONYMOUS_SESSION_NOT_ALLOWED:"Anonymous Session Not Allowed",USER_SESSION_NOT_ALLOWED:"User Session Not Allowed",SYSTEM_SESSION_NOT_ALLOWED:"System Session Not Allowed",CDN_SESSION_NOT_ALLOWED:"CDN Session Not Allowed",INTERNAL_SERVER_ERROR:"Internal Server Error",SOMETHING_WENT_WRONG:"Something went wrong",AUTH_CONTEXT_NOT_INITIALIZED:"Auth Context not Initialized"});var a={logException:(s,t)=>{console.error(`Exception Occurred in Function: ${s}, Error: ${a.inspect(t)}`);},logError:(s,t)=>{console.error(`Error Occurred in Function: ${s}, Error: ${a.inspect(t)}`);},logWarning:(s,t)=>{console.warn(`Warning in Function: ${s} - ${a.inspect(t)}`);},logMessage:(s,t)=>{console.log(`Message in Function: ${s} - ${a.inspect(t)}`);},logInvalidPayload:(s,t)=>{console.error(`Invalid Payload received for Function: ${s}, Error: ${a.inspect(t)}`);},inspect:s=>typeof s=="string"?s:S.inspect(s)},o=a;var y={handleException:(s,t,r)=>{t.knownError?(t.logError&&o.logError(s,t),r.status(t.status).json({status:t.status,error:t.error})):t.status&&t.error?(o.logException(s,t),r.status(t.status).json({error:t.errorMessage||JSON.stringify(t.error),status:t.status})):(o.logException(s,t),r.status(500).json({status:500,error:i.INTERNAL_SERVER_ERROR}));},generateResponse:(s,t,r)=>({status:s,data:t,error:r}),generateError:(s,t,r=!0,E=!1)=>({status:s,error:t,knownError:r,logError:E})},P=y;var p=async(s,t,r="GET",E={},_)=>{let c={method:r,headers:{"Content-Type":"application/json",...E}};r!=="GET"&&_&&(c.body=JSON.stringify(_));let n=`${s}${t?"/"+t:""}`,O=n.includes("api.xetile.com")||n.includes("localhost");try{let e=await fetch(n,c);if(!e.ok){let u,N=await e.text();try{u=JSON.parse(N);}catch{u={status:e.status,error:N||e.statusText},o.logWarning("Fetch",`Failed to parse error response body as JSON for URL-${n}. Raw text: ${N}`);}throw {status:e.status,statusText:e.statusText,error:u}}let I=await e.json();return o.logMessage("Fetch",`API call successful: URL-${n}, Status- ${e.status}`),{status:e.status,statusText:e.statusText,data:O?I.data:I}}catch(e){throw o.logError("Fetch",`API call failed: URL-${n}, Status- ${e.status||500}, Error- ${o.inspect(e.error||e)}`),{status:e.status||500,statusText:e.statusText||i.INTERNAL_SERVER_ERROR,error:e.error||{status:e.status||500,error:e.statusText||i.SOMETHING_WENT_WRONG}}}},$=p;export{i as a,o as b,P as c,$ as d};//# sourceMappingURL=chunk-AMIRIUMH.mjs.map
2
- //# sourceMappingURL=chunk-AMIRIUMH.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/enums/ErrorTypes.ts","../src/Logger/index.ts","../src/Utils/response.ts","../src/Utils/fetch.ts"],"names":["ErrorTypes_default","Logger","functionName","error","message","errorMessage","context","util","Logger_default","ResponseUtility","res","status","data","knownError","logError","response_default","Fetch","baseURL","endpoint","method","headers","payload","options","completeURL","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B,CAAA,UAAA,CAAYA,CAAI,CAAA,UAAA,EAAc7B,CAAW,CAAA,qBAAA,CACzC,KAAO6B,CAAAA,CAAAA,CAAI,KAAS,EAAA,CAClB,OAAQA,CAAI,CAAA,MAAA,EAAU,GACtB,CAAA,KAAA,CAAOA,CAAI,CAAA,UAAA,EAAc7B,CAAW,CAAA,oBACtC,CACF,CACF,CACF,CAAA,CAEO8B,CAAQd,CAAAA","file":"chunk-AMIRIUMH.mjs","sourcesContent":["export default Object.freeze({\r\n INVALID_UUID: \"Invalid UUID\",\r\n INVALID_EMAIL: \"Invalid Email\",\r\n INVALID_TOKEN: \"Invalid Token\",\r\n TOKEN_EXPIRED: \"Token Expired\",\r\n INVALID_VERIFIER: \"Invalid Verifier\",\r\n INVALID_PERMISSIONS: \"Invalid Permissions\",\r\n INVALID_AUTH_TYPE: \"Invalid Authorization Type\",\r\n USER_PRIVATE_KEY_NOT_FOUND: \"User Private Key Not Found\",\r\n USER_PUBLIC_KEY_NOT_FOUND: \"User Public Key Not Found\",\r\n ANONYMOUS_PRIVATE_KEY_NOT_FOUND: \"Anonymous Private Key Not Found\",\r\n ANONYMOUS_PUBLIC_KEY_NOT_FOUND: \"Anonymous Public Key Not Found\",\r\n SYSTEM_PRIVATE_KEY_NOT_FOUND: \"System Private Key Not Found\",\r\n SYSTEM_PUBLIC_KEY_NOT_FOUND: \"System Public Key Not Found\",\r\n ADMIN_PRIVATE_KEY_NOT_FOUND: \"Admin Private Key Not Found\",\r\n ADMIN_PUBLIC_KEY_NOT_FOUND: \"Admin Public Key Not Found\",\r\n SECRET_TOKEN_NOT_FOUND: \"Secret Token Not Found\",\r\n ANONYMOUS_SESSION_NOT_ALLOWED: \"Anonymous Session Not Allowed\",\r\n USER_SESSION_NOT_ALLOWED: \"User Session Not Allowed\",\r\n SYSTEM_SESSION_NOT_ALLOWED: \"System Session Not Allowed\",\r\n CDN_SESSION_NOT_ALLOWED: \"CDN Session Not Allowed\",\r\n INTERNAL_SERVER_ERROR: \"Internal Server Error\",\r\n SOMETHING_WENT_WRONG: 'Something went wrong',\r\n AUTH_CONTEXT_NOT_INITIALIZED: 'Auth Context not Initialized'\r\n})","import util from 'util';\r\nconst Logger = {\r\n logException: (functionName: string, error: any) => {\r\n console.error(`Exception Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logError: (functionName: string, error: any) => {\r\n console.error(`Error Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logWarning: (functionName: string, message: any) => {\r\n console.warn(`Warning in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logMessage: (functionName: string, message: any) => {\r\n console.log(`Message in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logInvalidPayload: (functionName: string, errorMessage: string) => {\r\n console.error(`Invalid Payload received for Function: ${functionName}, Error: ${Logger.inspect(errorMessage)}`);\r\n },\r\n\r\n inspect: (context: any) => {\r\n return (typeof context === \"string\" ? context : util.inspect(context));\r\n }\r\n}\r\n\r\nexport default Logger;","import ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport const ResponseUtility = {\r\n handleException: (functionName: string, error: any, res: any) => {\r\n if (error.knownError) {\r\n error.logError && Logger.logError(functionName, error);\r\n res.status(error.status).json({\r\n status: error.status,\r\n error: error.error\r\n });\r\n } else if(error.status && error.error) {\r\n Logger.logException(functionName, error);\r\n res.status(error.status).json({\r\n error: error.errorMessage || JSON.stringify(error.error),\r\n status: error.status,\r\n });\r\n } else {\r\n Logger.logException(functionName, error);\r\n res.status(500).json({\r\n status: 500,\r\n error: ErrorTypes.INTERNAL_SERVER_ERROR\r\n })\r\n }\r\n },\r\n\r\n generateResponse: (status: number, data?: any, error?: string) => {\r\n return {\r\n status,\r\n data,\r\n error\r\n }\r\n },\r\n\r\n generateError: (status: number, error: string, knownError: Boolean = true, logError: boolean = false) => {\r\n return {\r\n status,\r\n error,\r\n knownError,\r\n logError\r\n }\r\n }\r\n}\r\n\r\nexport default ResponseUtility;","\"use client\";\r\n\r\nimport ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport type ErrorType = {\r\n status: number;\r\n statusText: string;\r\n error: any;\r\n};\r\n\r\nexport type SuccessType = {\r\n status: number;\r\n statusText: string;\r\n data: any;\r\n};\r\n\r\n/**\r\n * Makes an HTTP request to the specified endpoint using the provided parameters.\r\n *\r\n * @param {string} baseURL - The base URL of the API.\r\n * @param {string} endpoint - The specific endpoint to call.\r\n * @param {'GET' | 'POST' | 'PATCH' | 'DELETE'} [method='GET'] - The HTTP method to use for the request.\r\n * @param {Record<string, string>} [headers={}] - Additional headers to include in the request.\r\n * @param {any} [payload] - The payload to send with the request, if applicable.\r\n * @returns {Promise<SuccessType>} - A promise that resolves to the response data if the request is successful.\r\n * @throws {ErrorType} - Throws an error if the request fails.\r\n */\r\nconst Fetch = async (\r\n baseURL: string,\r\n endpoint: string,\r\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET',\r\n headers: Record<string, string> = {},\r\n payload?: any,\r\n): Promise<SuccessType> => {\r\n const options: RequestInit = {\r\n method,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n ...headers,\r\n },\r\n };\r\n\r\n if (method !== 'GET' && payload) {\r\n options.body = JSON.stringify(payload);\r\n }\r\n\r\n const completeURL = `${baseURL}${endpoint ? ('/' + endpoint) : ''}`;\r\n const isInternalAPI = completeURL.includes('api.xetile.com') || completeURL.includes('localhost');\r\n \r\n try {\r\n const response: any = await fetch(completeURL, options);\r\n\r\n if (!response.ok) {\r\n let errorBody: any;\r\n const errorText = await response.text();\r\n\r\n try {\r\n errorBody = JSON.parse(errorText);\r\n } catch (parseError) {\r\n errorBody = {\r\n status: response.status,\r\n error: errorText || response.statusText\r\n };\r\n Logger.logWarning('Fetch', `Failed to parse error response body as JSON for URL-${completeURL}. Raw text: ${errorText}`);\r\n }\r\n\r\n throw {\r\n status: response.status,\r\n statusText: response.statusText,\r\n error: errorBody\r\n } as ErrorType;\r\n }\r\n\r\n const body = await response.json();\r\n\r\n Logger.logMessage('Fetch', `API call successful: URL-${completeURL}, Status- ${response.status}`);\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n data: isInternalAPI ? body.data : body,\r\n } as SuccessType;\r\n } catch (err: any) {\r\n \r\n Logger.logError('Fetch', `API call failed: URL-${completeURL}, Status- ${err.status || 500}, Error- ${Logger.inspect(err.error || err)}`);\r\n throw {\r\n status: err.status || 500,\r\n statusText: err.statusText || ErrorTypes.INTERNAL_SERVER_ERROR,\r\n error: err.error || {\r\n status: err.status || 500,\r\n error: err.statusText || ErrorTypes.SOMETHING_WENT_WRONG,\r\n }\r\n } as ErrorType;\r\n }\r\n};\r\n\r\nexport default Fetch;\r\n"]}
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-MJBRKWRU.mjs';import {b}from'./chunk-5KD2EW7O.mjs';import {e}from'./chunk-I3IWW4V2.mjs';import {a as a$2}from'./chunk-K6Q6YDUX.mjs';import {a as a$3}from'./chunk-R32ZSPV6.mjs';import {a}from'./chunk-55SOBG62.mjs';var D=class extends a{id;customerId;customerEmail;anonymousId;lineItems;shippingDetails;shippingAddress;billingAddress;coupons;total;country;currency;locale;constructor(t,i=new Date){super(t,i),this.id=t.id,this.customerId=t.customerId,this.customerEmail=t.customerEmail,this.anonymousId=t.anonymousId,this.country=t.country,this.currency=t.currency,this.locale=t.locale,this.lineItems=(t.lineItems??[]).map(o=>new a$1(o)),this.billingAddress=t.billingAddress?new b(t.billingAddress,i):null,this.shippingAddress=t.shippingAddress?new b(t.shippingAddress,i):null,this.coupons=(t.coupons??[]).map(o=>new e(o)),this.shippingDetails=t.shippingDetails?a$2.deepClone(t.shippingDetails):null,this.total={subtotal:new a$3(t.total.subtotal),shipping:new a$3(t.total.shipping),effectiveShipping:new a$3(t.total.effectiveShipping),taxTotal:new a$3(t.total.taxTotal),couponTotal:Object.fromEntries(Object.entries(t.total.couponTotal).map(([o,e])=>[o,new a$3(e)])),couponDiscountTotal:new a$3(t.total.couponDiscountTotal),grandTotal:new a$3(t.total.grandTotal)};}getId(){return this.id}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getAnonymousId(){return this.anonymousId}getLineItems(){return this.lineItems.map(t=>new a$1(t.getDetails()))}getLineItemsCount(){return this.lineItems.length}getShippingDetails(){return this.shippingDetails?{...this.shippingDetails}:null}getShippingAddress(){return this.shippingAddress?new b(this.shippingAddress.getDetails()):null}hasShippingAddress(){return !!this.shippingAddress}hasBillingAddress(){return !!this.billingAddress}getBillingAddress(){return this.billingAddress?new b(this.billingAddress.getDetails()):null}getCoupons(){return this.coupons}getCountry(){return this.country}getCurrency(){return this.currency}getLocale(){return this.locale}getTotal(){return this.total}getDetails(){return {...super.getDetails(),id:this.getId(),customerId:this.getCustomerId(),customerEmail:this.getCustomerEmail(),anonymousId:this.getAnonymousId(),lineItems:this.getLineItems().map(t=>t.getDetails()),shippingDetails:this.getShippingDetails(),shippingAddress:this.getShippingAddress()?.getDetails()||null,billingAddress:this.getBillingAddress()?.getDetails()||null,coupons:this.getCoupons().map(t=>t.getDetails()),total:{subtotal:this.getTotal().subtotal.getDetails(),shipping:this.getTotal().shipping.getDetails(),effectiveShipping:this.getTotal().effectiveShipping.getDetails(),taxTotal:this.getTotal().taxTotal.getDetails(),couponTotal:Object.fromEntries(Object.entries(this.getTotal().couponTotal).map(([t,i])=>[t,i.getDetails()])),couponDiscountTotal:this.getTotal().couponDiscountTotal.getDetails(),grandTotal:this.getTotal().grandTotal.getDetails()},country:this.getCountry(),currency:this.getCurrency(),locale:this.getLocale()}}calculateTotals(){let t=new a$3({amount:0,currency:this.currency}),i=this.lineItems.filter(r=>r.getState()!=="CANCELLED"),o=i.reduce((r,c)=>r.add(c.getTotal().subtotal),t),e=new a$3({amount:this.shippingDetails?.cost||0,currency:this.currency}).round(),s=t,n={},u={};this.coupons.forEach(r=>{let c=r.calculateApplicableCouponDiscount(o,e,this.country,this.currency);s=s.add(c),n[r.getCode()]=c,r.getCategory()!=="SHIPPING"&&(u[r.getCode()]=c);}),this.applyDiscountsInLineItem(u);let p=i.reduce((r,c)=>r.add(c.getTotal().taxTotal),t),l=this.coupons.find(r=>r.getCategory()==="SHIPPING"),h=l?e.subtract(n[l.getCode()]||t):e,g=o.add(e).add(p).subtract(s);this.total={subtotal:o,shipping:e,effectiveShipping:h,couponTotal:n,couponDiscountTotal:s,taxTotal:p,grandTotal:g};}updateShippingDetails(t){this.shippingDetails=t,this.calculateTotals();}applyCoupons(t){let i=t.filter(e=>e.getCategory()==="SHIPPING"),o=t.filter(e=>e.getCategory()!=="SHIPPING");this.coupons=[],this.total.couponDiscountTotal=this.total.subtotal.zero(),this.total.couponTotal={},o.length&&this.applyNonShippingCoupons(o),this.applyDiscountsInLineItem(this.total.couponTotal),i.length&&this.applyShippingCoupons(i),this.calculateTotals();}applyDiscountsInLineItem(t){let i=Array.from(Object.entries(t)).filter(e=>!e[1].isZero()),o=new Map;this.lineItems.forEach(e=>o.set(e.getId(),[])),i.forEach(([e,s])=>{let n=this.coupons.find(l=>l.getCode()===e);if(!n||s.isZero())return;let u=this.lineItems.filter(l=>l.getState()!=="CANCELLED"&&!l.getTotal().subtotal.isZero()).sort((l,h)=>l.getTotal().subtotal.compareTo(h.getTotal().subtotal)),p=new a$3({amount:0,currency:this.currency});u.forEach((l,h)=>{let g;h===u.length-1?g=s.subtract(p):g=s.multiply(l.getTotal().subtotal).divide(this.total.subtotal).round(),p=p.add(g),o.get(l.getId())?.push({coupon:n,amount:g});});}),this.lineItems.forEach(e=>{e.getState()==="CANCELLED"||this.total.subtotal.isZero()?e.updateDiscounts([]):e.updateDiscounts(o.get(e.getId())||[]);});}updateTax(t){this.lineItems.forEach(i=>{i.updateTax(t[i.getPricing().taxCategory]);}),this.calculateTotals();}applyNonShippingCoupons(t){let i=t.filter(o=>o.getType()==="coupon");if(i.length===1){let o=i[0].calculateApplicableCouponDiscount(this.total.subtotal,this.total.shipping,this.country,this.currency);o.getAmount()>0&&(this.coupons.push(i[0]),this.total.couponTotal[i[0].getCode()]=o,this.total.couponDiscountTotal=o);}}applyShippingCoupons(t){if(this.total.shipping.getAmount()>0&&t.length>0){let i=this.total.subtotal.subtract(this.total.couponDiscountTotal),o=t.reduce((s,n)=>{if(!s)return n;let u=n.calculateApplicableCouponDiscount(i,this.total.shipping,this.country,this.currency).min(this.total.shipping),p=s.calculateApplicableCouponDiscount(i,this.total.shipping,this.country,this.currency).min(this.total.shipping);return u===p?n.getType()==="coupon"?n:s:u>p?n:s}),e=o.calculateApplicableCouponDiscount(i,this.total.shipping,this.country,this.currency).min(this.total.shipping);e.getAmount()>0&&(this.coupons.push(o),this.total.couponTotal[o.getCode()]=e,this.total.couponDiscountTotal=this.total.couponDiscountTotal.add(e),this.total.effectiveShipping=this.total.shipping.subtract(e));}}};export{D as a};//# sourceMappingURL=chunk-G6UFVELO.mjs.map
2
- //# sourceMappingURL=chunk-G6UFVELO.mjs.map
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-K6Q6YDUX.mjs';import {a as a$2}from'./chunk-R32ZSPV6.mjs';import {e}from'./chunk-72DR3HF2.mjs';import {s}from'./chunk-DGFO2MH6.mjs';import {a}from'./chunk-55SOBG62.mjs';var y=(t=>(t.COUPON="coupon",t.AUTOMATIC="automatic",t))(y||{}),M=(t=>(t.FLAT="flat",t.PERCENTAGE="percentage",t))(M||{}),b=(t=>(t.SHIPPING="SHIPPING",t.CUSTOMER="CUSTOMER",t))(b||{}),P=(t=>(t.ALL="all",t.FTB="ftb",t))(P||{}),p=class extends a{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(e,t=new Date){if(super(e,t),this.couponCode=e.couponCode,this.name=a$1.deepClone(e.name),this.description=a$1.deepClone(e.description),this.type=e.type,this.customerId=e.customerId,this.validFrom=e.validFrom&&Date.parse(e.validFrom)?new Date(e.validFrom).toISOString():t.toISOString(),this.validTo=e.validTo&&Date.parse(e.validTo)?new Date(e.validTo).toISOString():t.toISOString(),this.minCartValue=Object.keys(e.minCartValue).reduce((o,i)=>{let r=e.minCartValue[i];return r&&(o[i]=new a$2(r)),o},{}),this.maxCartDiscount=Object.keys(e.maxCartDiscount).reduce((o,i)=>{let r=e.maxCartDiscount[i];return r&&(o[i]=new a$2(r)),o},{}),this.discountMethod=e.discountMethod,this.percentageValue=e.percentageValue??0,this.percentageValue>100)throw new s("Percentage value cannot be greater than 100");this.applicableTo=e.applicableTo,this.category=e.category;}getCode(){return this.couponCode}getName(e$1){return e$1?this.name[e$1]??this.name[e[e$1]]??this.name.en:{...this.name}}getDescription(e$1){return e$1?this.description[e$1]??this.description[e[e$1]]??this.description.en:{...this.description}}getType(){return this.type}getCustomerId(){return this.customerId??""}getValidFrom(){return this.validFrom}getValidTo(){return this.validTo}getMinCartValue(e){return e?this.minCartValue[e]:this.minCartValue}getMaxCartDiscount(e){return e?this.maxCartDiscount[e]:this.maxCartDiscount}getDiscountMethod(){return this.discountMethod}getPercentageValue(){return this.percentageValue}getApplicableTo(){return this.applicableTo}getCategory(){return this.category}getDetails(){return {...super.getDetails(),couponCode:this.getCode(),name:this.getName(),description:this.getDescription(),type:this.getType(),customerId:this.getCustomerId(),validFrom:this.getValidFrom(),validTo:this.getValidTo(),minCartValue:Object.keys(this.getMinCartValue()).reduce((e,t)=>{let o=this.getMinCartValue(t);return o&&(e[t]=o.getDetails()),e},{}),maxCartDiscount:Object.keys(this.getMaxCartDiscount()).reduce((e,t)=>{let o=this.getMaxCartDiscount(t);return o&&(e[t]=o.getDetails()),e},{}),discountMethod:this.getDiscountMethod(),percentageValue:this.getPercentageValue(),applicableTo:this.getApplicableTo(),category:this.getCategory()}}isActive(){return new Date(this.validFrom)<=new Date&&new Date(this.validTo)>=new Date}isApplicableTo(e){return this.applicableTo==="all"||this.applicableTo==="ftb"&&e}calculateApplicableCouponDiscount(e,t,o,i,r=!0){let n=new a$2({amount:0,currency:i}),s;if(r&&!this.isActive())return n;let C=this.getMinCartValue(o),c=this.getMaxCartDiscount(o);if(!C||C.compareTo(e)>0||!c)return n;let h=this.getCategory(),D=this.getDiscountMethod(),u=h==="SHIPPING"?t:e;if(u.getAmount()<=0)return n;switch(D){case"flat":let T=c;s=u.min(T);break;case"percentage":s=u.multiply(this.getPercentageValue()/100).round();break;default:return n}return s.min(c)}};export{y as a,M as b,b as c,P as d,p as e};//# sourceMappingURL=chunk-I3IWW4V2.mjs.map
2
- //# sourceMappingURL=chunk-I3IWW4V2.mjs.map
@@ -1,2 +0,0 @@
1
- import {c}from'./chunk-NFRTZM45.mjs';import {a}from'./chunk-K6Q6YDUX.mjs';import {a as a$2}from'./chunk-ZVLJ5BAG.mjs';import {a as a$1}from'./chunk-R32ZSPV6.mjs';import {e}from'./chunk-72DR3HF2.mjs';import {b}from'./chunk-7LEGYAOJ.mjs';import {b as b$1,d,e as e$1,g,h,i}from'./chunk-DGFO2MH6.mjs';var p=class{id;productKey;selectionAttributes;name;specifications;primaryImage;subItems;pricing;state;total;constructor(t){this.id=t.id,this.productKey=t.productKey,this.selectionAttributes=a.deepClone(t.selectionAttributes),this.name=a.deepClone(t.name),this.specifications=a.deepClone(t.specifications),this.primaryImage=new b(t.primaryImage),this.subItems=a.deepClone(t.subItems);let i=new Set;this.subItems.forEach(e=>{if(i.has(e.size))throw new b$1(e.size);i.add(e.size);}),this.pricing={unitPrice:new a$1(t.pricing.unitPrice),tierPricing:new a$2(t.pricing.tierPricing),taxCategory:t.pricing.taxCategory,tax:{taxRuleId:t.pricing.tax.taxRuleId,taxSystem:t.pricing.tax.taxSystem,country:t.pricing.tax.country,rate:t.pricing.tax.rate,taxSlabs:t.pricing.tax.taxSlabs.map(e=>({rate:e.rate,minUnitPrice:new a$1(e.minUnitPrice),maxUnitPrice:e.maxUnitPrice?new a$1(e.maxUnitPrice):void 0}))}},this.state=t.state??"INITIAL",this.total={quantity:t.total.quantity,subtotal:new a$1(t.total.subtotal),discounts:Object.fromEntries(Object.entries(t.total.discounts).map(([e,a])=>[e,new a$1(a)])),taxableAmount:new a$1(t.total.taxableAmount),taxTotal:new a$1(t.total.taxTotal),grandTotal:new a$1(t.total.grandTotal)};}getId(){return this.id}getProductKey(){return this.productKey}getSelectionAttributes(){return a.deepClone(this.selectionAttributes)}getName(t){return t?a.deepClone(this.name[t]??this.name[e[t]]??this.name.en):a.deepClone(this.name)}getSpecifications(t){return t?a.deepClone(this.specifications[t]??this.specifications[e[t]]??this.specifications.en):a.deepClone(this.specifications)}getImage(){return this.primaryImage}getSubItems(){return a.deepClone(this.subItems)}getTotalQuantity(){return this.total.quantity}getPricing(){return {unitPrice:this.pricing.unitPrice,tierPricing:this.pricing.tierPricing,taxCategory:this.pricing.taxCategory,tax:{taxRuleId:this.pricing.tax.taxRuleId,taxSystem:this.pricing.tax.taxSystem,country:this.pricing.tax.country,rate:this.pricing.tax.rate,taxSlabs:this.pricing.tax.taxSlabs}}}getState(){return this.state}getTotal(){return {quantity:this.total.quantity,subtotal:this.total.subtotal,taxableAmount:this.total.taxableAmount,taxTotal:this.total.taxTotal,discounts:Object.fromEntries(Object.entries(this.total.discounts).map(([t,i])=>[t,i])),grandTotal:this.total.grandTotal}}getDetails(){return {id:this.getId(),productKey:this.getProductKey(),selectionAttributes:this.getSelectionAttributes(),name:this.getName(),specifications:this.getSpecifications(),primaryImage:this.getImage().getDetails(),subItems:this.getSubItems(),pricing:{unitPrice:this.getPricing().unitPrice.getDetails(),tierPricing:this.getPricing().tierPricing.getDetails(),taxCategory:this.getPricing().taxCategory,tax:{taxRuleId:this.getPricing().tax.taxRuleId,taxSystem:this.getPricing().tax.taxSystem,country:this.getPricing().tax.country,rate:this.getPricing().tax.rate,taxSlabs:this.getPricing().tax.taxSlabs.map(t=>({rate:t.rate,minUnitPrice:t.minUnitPrice.getDetails(),maxUnitPrice:t.maxUnitPrice?t.maxUnitPrice.getDetails():void 0}))}},state:this.getState(),total:{quantity:this.getTotal().quantity,subtotal:this.getTotal().subtotal.getDetails(),taxableAmount:this.getTotal().taxableAmount.getDetails(),taxTotal:this.getTotal().taxTotal.getDetails(),discounts:Object.fromEntries(Object.entries(this.getTotal().discounts).map(([t,i])=>[t,i.getDetails()])),grandTotal:this.getTotal().grandTotal.getDetails()}}}addSubItems(t,i){t.forEach(e=>{let a=this.subItems.find(n=>n.size===e.size);a?a.quantity=i?a.quantity+e.quantity:e.quantity:this.subItems.push(e);}),this.subItems=this.subItems.filter(e=>e.quantity>0),this.calculateTotals();}updateProductData(t,i,e){if(this.productKey!==t.getKey()||!t.validateSelectionAttribute(this.selectionAttributes))throw new d;if(!t.getIsActive())throw new e$1;this.subItems.forEach(c=>{if(!t.validateSize(c.size))throw new g});let a=t.getPriceDetails(i);if(!a||a.getBaseUnitPrice().getCurrency()!==e)throw new h;this.name=t.getName(),this.specifications=t.getSpecifications(),this.primaryImage=t.getImages(this.selectionAttributes).primary;let n=this.subItems.reduce((c,l)=>c+l.quantity,0),{unitPrice:s}=a.getApplicableTier(n);this.pricing={unitPrice:s,tierPricing:a,taxCategory:a.getTaxCategory(),tax:this.pricing.tax},this.calculateTotals();}updateDiscounts(t){let i={};t.forEach(e=>{i[e.coupon.getCode()]=e.amount;}),this.total.discounts=i,this.calculateTotals();}updateTax(t){if(!t.appliesTo(this.pricing.taxCategory,this.pricing.tax.country))throw new i;let i$1=this.total.quantity>0?this.total.taxableAmount.divide(this.total.quantity):this.total.taxableAmount.zero();this.pricing.tax={taxRuleId:t.getTaxRuleId(),taxSystem:t.getTaxSystem(),country:t.getCountry(),rate:t.getApplicableTaxRate(i$1),taxSlabs:t.getSlabs()},this.calculateTotals();}calculateTotals(){let t=this.pricing.unitPrice.zero(),i=this.subItems.reduce((u,g)=>u+g.quantity,0),{unitPrice:e}=this.pricing.tierPricing.getApplicableTier(i),a=e.multiply(i),n=Object.values(this.total.discounts).reduce((u,g)=>u.add(g),t),s=a.subtract(n),c$1=i>0?s.divide(i):t,l=c.getApplicableTaxRate(c$1,this.pricing.tax.taxSlabs),h=s.multiply(l).round(),C=a.subtract(n).add(h);this.total={quantity:i,subtotal:a,taxableAmount:s,taxTotal:h,discounts:this.total.discounts,grandTotal:C};}clearLineItem(){let t=this.pricing.unitPrice.zero();this.id="",this.productKey="",this.selectionAttributes={color:{name:""}},this.name={en:""},this.primaryImage=new b({sources:{original:""}}),this.subItems=[],this.pricing={unitPrice:t,tierPricing:this.pricing.tierPricing,taxCategory:this.pricing.taxCategory,tax:this.pricing.tax},this.total={quantity:0,subtotal:t,taxableAmount:t,taxTotal:t,discounts:{},grandTotal:t};}};export{p as a};//# sourceMappingURL=chunk-MJBRKWRU.mjs.map
2
- //# sourceMappingURL=chunk-MJBRKWRU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Classes/LineItem.ts"],"names":["LineItemModel","data","Utils_default","ImageInfoModel","uniqueSelectionAttributes","item","DuplicateSizeError","PriceModel","TieredPriceModel","s","couponCode","discount","locale","LocaleLanguageMap","subItems","addQuantity","subItem","existingSubItem","sub","product","cartCountry","cartCurrency","ProductMismatchError","ProductInactiveError","SizeMismatchError","productPricing","PricingNotFoundError","quantity","sum","unitPrice","appliedDiscounts","lineItemDiscounts","taxRule","InvalidTaxRuleError","taxableUnitPrice","zero","totalQuantity","subTotal","discounts","taxableAmount","unitTaxbleAmount","taxRate","TaxRuleModel","taxTotal","grandTotal"],"mappings":"ySAoEA,IAAqBA,CAArB,CAAA,KAAmC,CACvB,EAAA,CACA,UACA,CAAA,mBAAA,CAEA,IACA,CAAA,cAAA,CACA,YACA,CAAA,QAAA,CACA,OAaA,CAAA,KAAA,CACA,KAcV,CAAA,WAAA,CAAYC,CAA0B,CAAA,CACpC,IAAK,CAAA,EAAA,CAAKA,CAAK,CAAA,EAAA,CACf,IAAK,CAAA,UAAA,CAAaA,CAAK,CAAA,UAAA,CACvB,IAAK,CAAA,mBAAA,CAAsBC,CAAM,CAAA,SAA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AAA,QAAA,CAASC,CAAS,CAAA,CAAE,GAAIK,CAAAA,CAAQ,EAE5D,IAAK,CAAA,KAAA,CAAQ,CACX,QAAA,CAAUP,CACV,CAAA,QAAA,CAAUC,CACV,CAAA,aAAA,CAAeE,CACf,CAAA,QAAA,CAAUI,CACV,CAAA,SAAA,CAAW,IAAK,CAAA,KAAA,CAAM,SACtB,CAAA,UAAA,CAAYC,CACd,EACF,CAOA,aAAA,EAAsB,CACpB,IAAMT,CAAO,CAAA,IAAA,CAAK,OAAQ,CAAA,SAAA,CAAU,IAAK,EAAA,CACzC,IAAK,CAAA,EAAA,CAAK,EACV,CAAA,IAAA,CAAK,WAAa,EAClB,CAAA,IAAA,CAAK,mBAAsB,CAAA,CAAE,KAAO,CAAA,CAAE,IAAM,CAAA,EAAG,CAAE,CAAA,CACjD,IAAK,CAAA,IAAA,CAAO,CAAE,EAAA,CAAI,EAAG,CAAA,CACrB,IAAK,CAAA,YAAA,CAAe,IAAIhC,CAAAA,CAAe,CAAE,OAAA,CAAS,CAAE,QAAA,CAAU,EAAG,CAAE,CAAC,CAAA,CACpE,IAAK,CAAA,QAAA,CAAW,EAAC,CACjB,KAAK,OAAU,CAAA,CACb,SAAWgC,CAAAA,CAAAA,CACX,WAAa,CAAA,IAAA,CAAK,OAAQ,CAAA,WAAA,CAC1B,WAAa,CAAA,IAAA,CAAK,OAAQ,CAAA,WAAA,CAC1B,GAAK,CAAA,IAAA,CAAK,OAAQ,CAAA,GACpB,EACA,IAAK,CAAA,KAAA,CAAQ,CACX,QAAA,CAAU,CACV,CAAA,QAAA,CAAUA,CACV,CAAA,aAAA,CAAeA,CACf,CAAA,QAAA,CAAUA,CACV,CAAA,SAAA,CAAW,EAAC,CACZ,UAAYA,CAAAA,CACd,EACF,CACF","file":"chunk-MJBRKWRU.mjs","sourcesContent":["import Utils from \"../Utils\";\r\nimport { Color, CountryCode, CurrencyCode, LocaleCode, LocalizedString, LocalizedValue } from \"./Common\";\r\nimport CouponModel from \"./Coupon\";\r\nimport { LineItemState, LocaleLanguageMap, TaxCategory, TaxSystem } from \"./Enum\";\r\nimport ImageInfoModel, { ImageInfoData } from \"./ImageInfo\";\r\nimport PriceModel, { PriceData } from \"./Price\";\r\nimport ProductModel, { ProductSelectionAttributes, ProductSpecification, SelectionAttributes } from \"./Product\";\r\nimport { TaxRuleModel, TaxSlabModel, TaxSlabs } from \"./TaxRule\";\r\nimport { TieredPriceData, TieredPriceModel } from \"./TieredPrice\";\r\nimport {\r\n DuplicateSizeError,\r\n ProductMismatchError,\r\n ProductInactiveError,\r\n SizeMismatchError,\r\n PricingNotFoundError,\r\n InvalidTaxRuleError\r\n} from \"./Error\";\r\n\r\nexport type SubItem = {\r\n size: string | 'ONESIZE';\r\n quantity: number;\r\n};\r\n\r\nexport type LineItemPricing = {\r\n unitPrice: PriceData;\r\n tierPricing: TieredPriceData;\r\n taxCategory: TaxCategory;\r\n tax: {\r\n taxRuleId: string;\r\n taxSystem: TaxSystem;\r\n country: CountryCode;\r\n rate: number;\r\n taxSlabs: TaxSlabs;\r\n };\r\n};\r\n\r\nexport type LineItemTotals = {\r\n quantity: number;\r\n subtotal: PriceData;\r\n discounts: Record<string, PriceData>; // couponCode -> discount mapping\r\n taxableAmount: PriceData; // subtotal - discount\r\n taxTotal: PriceData;\r\n grandTotal: PriceData;\r\n};\r\n\r\nexport type LineItemAttributes = {\r\n id: string;\r\n\r\n productKey: string;\r\n selectionAttributes: SelectionAttributes;\r\n\r\n name: LocalizedString;\r\n specifications: LocalizedValue<ProductSpecification>;\r\n primaryImage: ImageInfoData;\r\n\r\n subItems: SubItem[];\r\n\r\n pricing: LineItemPricing;\r\n\r\n state?: LineItemState;\r\n total: LineItemTotals;\r\n}\r\n\r\nexport type LineItemData = Required<LineItemAttributes>;\r\n\r\n/**\r\n * Represents a line item within a shopping cart.\r\n */\r\nexport default class LineItemModel {\r\n protected id: string;\r\n protected productKey: string;\r\n protected selectionAttributes: SelectionAttributes;\r\n\r\n protected name: LocalizedString;\r\n protected specifications: LocalizedValue<ProductSpecification>;\r\n protected primaryImage: ImageInfoModel;\r\n protected subItems: SubItem[];\r\n protected pricing: {\r\n unitPrice: PriceModel;\r\n tierPricing: TieredPriceModel;\r\n taxCategory: TaxCategory;\r\n tax: {\r\n taxRuleId: string;\r\n taxSystem: TaxSystem;\r\n country: CountryCode;\r\n taxSlabs: TaxSlabModel[];\r\n rate: number;\r\n };\r\n };\r\n\r\n protected state: LineItemState;\r\n protected total: {\r\n quantity: number;\r\n subtotal: PriceModel;\r\n discounts: Record<string, PriceModel>;\r\n taxableAmount: PriceModel; // subtotal - discount\r\n\r\n taxTotal: PriceModel;\r\n grandTotal: PriceModel;\r\n };\r\n\r\n /**\r\n * Creates an instance of LineItemModel.\r\n * @param data - The initial line item attributes.\r\n */\r\n constructor(data: LineItemAttributes) {\r\n this.id = data.id;\r\n this.productKey = data.productKey;\r\n this.selectionAttributes = Utils.deepClone(data.selectionAttributes);\r\n\r\n this.name = Utils.deepClone(data.name);\r\n this.specifications = Utils.deepClone(data.specifications);\r\n this.primaryImage = new ImageInfoModel(data.primaryImage);\r\n this.subItems = Utils.deepClone(data.subItems);\r\n\r\n let uniqueSelectionAttributes = new Set();\r\n this.subItems.forEach(item => {\r\n if (uniqueSelectionAttributes.has(item.size)) {\r\n throw new DuplicateSizeError(item.size);\r\n }\r\n uniqueSelectionAttributes.add(item.size);\r\n });\r\n\r\n this.pricing = {\r\n unitPrice: new PriceModel(data.pricing.unitPrice),\r\n tierPricing: new TieredPriceModel(data.pricing.tierPricing),\r\n taxCategory: data.pricing.taxCategory,\r\n tax: {\r\n taxRuleId: data.pricing.tax.taxRuleId,\r\n taxSystem: data.pricing.tax.taxSystem,\r\n country: data.pricing.tax.country,\r\n rate: data.pricing.tax.rate,\r\n taxSlabs: data.pricing.tax.taxSlabs.map(s => ({\r\n rate: s.rate,\r\n minUnitPrice: new PriceModel(s.minUnitPrice),\r\n maxUnitPrice: s.maxUnitPrice ? new PriceModel(s.maxUnitPrice) : undefined,\r\n })),\r\n },\r\n }\r\n\r\n this.state = data.state ?? LineItemState.INITIAL;\r\n\r\n this.total = {\r\n quantity: data.total.quantity,\r\n subtotal: new PriceModel(data.total.subtotal),\r\n discounts: Object.fromEntries(\r\n Object.entries(data.total.discounts).map(([couponCode, discount]) => [\r\n couponCode,\r\n new PriceModel(discount),\r\n ])\r\n ),\r\n taxableAmount: new PriceModel(data.total.taxableAmount),\r\n taxTotal: new PriceModel(data.total.taxTotal),\r\n grandTotal: new PriceModel(data.total.grandTotal),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique identifier of the line item.\r\n * @returns The unique ID string.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the product key associated with this line item.\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 * Gets the selection attributes (e.g., size, color) for this line item.\r\n * @returns A copy of the selection attributes object.\r\n */\r\n getSelectionAttributes(): SelectionAttributes {\r\n return Utils.deepClone(this.selectionAttributes);\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 Utils.deepClone(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 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 image information model for this line item.\r\n * @returns The ImageInfoModel instance.\r\n */\r\n getImage(): ImageInfoModel {\r\n return this.primaryImage;\r\n }\r\n\r\n /**\r\n * Gets the sub-items (size/quantity breakdown).\r\n * @returns A copy of the array of SubItems.\r\n */\r\n getSubItems(): SubItem[] {\r\n return Utils.deepClone(this.subItems);\r\n }\r\n\r\n /**\r\n * Gets the total quantity for this line item across all sub-items.\r\n * @returns The total quantity as a number.\r\n */\r\n getTotalQuantity(): number {\r\n return this.total.quantity;\r\n }\r\n\r\n /**\r\n * Gets the pricing information model for this line item.\r\n * @returns An object containing unit price, tiered pricing, tax category, and tax details.\r\n */\r\n getPricing() {\r\n return {\r\n unitPrice: this.pricing.unitPrice,\r\n tierPricing: this.pricing.tierPricing,\r\n taxCategory: this.pricing.taxCategory,\r\n tax: {\r\n taxRuleId: this.pricing.tax.taxRuleId,\r\n taxSystem: this.pricing.tax.taxSystem,\r\n country: this.pricing.tax.country,\r\n rate: this.pricing.tax.rate,\r\n taxSlabs: this.pricing.tax.taxSlabs,\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current state of the line item.\r\n * @returns The LineItemState enum value.\r\n */\r\n getState() {\r\n return this.state;\r\n }\r\n\r\n /**\r\n * Gets the total price for this line item (including all sub-items).\r\n * @returns An object containing line item totals including subtotal, tax, discounts, and grand total.\r\n */\r\n getTotal() {\r\n return {\r\n quantity: this.total.quantity,\r\n subtotal: this.total.subtotal,\r\n taxableAmount: this.total.taxableAmount,\r\n taxTotal: this.total.taxTotal,\r\n discounts: Object.fromEntries(\r\n Object.entries(this.total.discounts).map(([couponCode, discount]) => [\r\n couponCode,\r\n discount,\r\n ])\r\n ),\r\n grandTotal: this.total.grandTotal,\r\n };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the line item's details.\r\n * @returns LineItemData.\r\n */\r\n getDetails(): LineItemData {\r\n return {\r\n id: this.getId(),\r\n productKey: this.getProductKey(),\r\n selectionAttributes: this.getSelectionAttributes(),\r\n name: this.getName(),\r\n specifications: this.getSpecifications(),\r\n primaryImage: this.getImage().getDetails(),\r\n subItems: this.getSubItems(),\r\n pricing: {\r\n unitPrice: this.getPricing().unitPrice.getDetails(),\r\n tierPricing: this.getPricing().tierPricing.getDetails(),\r\n taxCategory: this.getPricing().taxCategory,\r\n tax: {\r\n taxRuleId: this.getPricing().tax.taxRuleId,\r\n taxSystem: this.getPricing().tax.taxSystem,\r\n country: this.getPricing().tax.country,\r\n rate: this.getPricing().tax.rate,\r\n taxSlabs: this.getPricing().tax.taxSlabs.map(s => ({\r\n rate: s.rate,\r\n minUnitPrice: s.minUnitPrice.getDetails(),\r\n maxUnitPrice: s.maxUnitPrice ? s.maxUnitPrice.getDetails() : undefined,\r\n })),\r\n }\r\n },\r\n state: this.getState(),\r\n total: {\r\n quantity: this.getTotal().quantity,\r\n subtotal: this.getTotal().subtotal.getDetails(),\r\n taxableAmount: this.getTotal().taxableAmount.getDetails(),\r\n taxTotal: this.getTotal().taxTotal.getDetails(),\r\n discounts: Object.fromEntries(\r\n Object.entries(this.getTotal().discounts).map(([couponCode, discount]) => [\r\n couponCode,\r\n discount.getDetails(),\r\n ])\r\n ),\r\n grandTotal: this.getTotal().grandTotal.getDetails(),\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Adds or updates sub-items (e.g., sizes with quantities) to the line item.\r\n * If a sub-item with the same size already exists, its quantity is either\r\n * updated by adding the new quantity or replaced entirely, based on the `addQuantity` flag.\r\n * Sub-items with a resulting quantity of 0 are removed.\r\n * @param subItems - An array of `SubItem` objects to add or update.\r\n * @param addQuantity - If true, adds the quantity from `subItem` to the existing quantity.\r\n * If false, replaces the existing quantity with the one from `subItem`.\r\n */\r\n addSubItems(subItems: SubItem[], addQuantity: boolean): void {\r\n subItems.forEach(subItem => {\r\n const existingSubItem = this.subItems.find(item => item.size === subItem.size);\r\n if (existingSubItem) {\r\n existingSubItem.quantity = addQuantity ? existingSubItem.quantity + subItem.quantity : subItem.quantity;\r\n } else {\r\n this.subItems.push(subItem);\r\n }\r\n })\r\n this.subItems = this.subItems.filter(sub => sub.quantity > 0);\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Updates the line item with the latest product data (price, image, name, specifications).\r\n * Validates that the product matches the line item's selection and is active.\r\n * @param product - The product model to update from.\r\n * @param cartCountry - The country code for pricing context.\r\n * @param cartCurrency - The currency code for pricing context.\r\n * @throws {Error} If product mismatch, inactive, size mismatch, or pricing missing.\r\n */\r\n public updateProductData(product: ProductModel, cartCountry: CountryCode, cartCurrency: CurrencyCode): void {\r\n if (this.productKey !== product.getKey() || !product.validateSelectionAttribute(this.selectionAttributes)) {\r\n throw new ProductMismatchError();\r\n } else if (!product.getIsActive()) {\r\n throw new ProductInactiveError();\r\n }\r\n\r\n this.subItems.forEach(subItem => {\r\n if (!product.validateSize(subItem.size)) {\r\n throw new SizeMismatchError();\r\n }\r\n });\r\n\r\n const productPricing = product.getPriceDetails(cartCountry);\r\n if (!productPricing || productPricing.getBaseUnitPrice().getCurrency() !== cartCurrency) {\r\n throw new PricingNotFoundError();\r\n }\r\n this.name = product.getName();\r\n this.specifications = product.getSpecifications();\r\n this.primaryImage = product.getImages(this.selectionAttributes).primary;\r\n\r\n const quantity = this.subItems.reduce((sum, s) => sum + s.quantity, 0);\r\n const { unitPrice } = productPricing.getApplicableTier(quantity);\r\n\r\n this.pricing = {\r\n unitPrice: unitPrice,\r\n tierPricing: productPricing,\r\n taxCategory: productPricing.getTaxCategory(),\r\n tax: this.pricing.tax\r\n }\r\n\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Updates the discounts applied to this line item and recalculates totals.\r\n * @param appliedDiscounts - List of coupons and their allocated discount amounts.\r\n */\r\n public updateDiscounts(appliedDiscounts: { coupon: CouponModel, amount: PriceModel }[]): void {\r\n let lineItemDiscounts = {} as Record<string, PriceModel>;\r\n appliedDiscounts.forEach(discount => {\r\n lineItemDiscounts[discount.coupon.getCode()] = discount.amount;\r\n });\r\n\r\n this.total.discounts = lineItemDiscounts;\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Updates the tax rule for this line item and recalculates totals.\r\n * @param taxRule - The new tax rule to apply.\r\n * @throws {Error} If the tax rule category does not match the item's tax category.\r\n */\r\n public updateTax(taxRule: TaxRuleModel): void {\r\n if (!taxRule.appliesTo(this.pricing.taxCategory, this.pricing.tax.country)) {\r\n throw new InvalidTaxRuleError();\r\n }\r\n\r\n const taxableUnitPrice = this.total.quantity > 0 ? \r\n this.total.taxableAmount.divide(this.total.quantity) \r\n : \r\n this.total.taxableAmount.zero();\r\n\r\n this.pricing.tax = {\r\n taxRuleId: taxRule.getTaxRuleId(),\r\n taxSystem: taxRule.getTaxSystem(),\r\n country: taxRule.getCountry(),\r\n rate: taxRule.getApplicableTaxRate(taxableUnitPrice),\r\n taxSlabs: taxRule.getSlabs(),\r\n };\r\n this.calculateTotals();\r\n }\r\n\r\n /**\r\n * Recalculates the line item totals based on current quantity, unit price, discounts, and tax rates.\r\n */\r\n public calculateTotals(): void {\r\n const zero = this.pricing.unitPrice.zero();\r\n const totalQuantity = this.subItems.reduce((sum, s) => sum + s.quantity, 0);\r\n const { unitPrice } = this.pricing.tierPricing.getApplicableTier(totalQuantity);\r\n const subTotal = unitPrice.multiply(totalQuantity);\r\n const discounts = Object.values(this.total.discounts).reduce((sum, s) => sum.add(s), zero);\r\n const taxableAmount = subTotal.subtract(discounts);\r\n const unitTaxbleAmount = totalQuantity > 0 ? taxableAmount.divide(totalQuantity) : zero;\r\n const taxRate = TaxRuleModel.getApplicableTaxRate(unitTaxbleAmount, this.pricing.tax.taxSlabs);\r\n const taxTotal = taxableAmount.multiply(taxRate).round();\r\n const grandTotal = subTotal.subtract(discounts).add(taxTotal);\r\n\r\n this.total = {\r\n quantity: totalQuantity,\r\n subtotal: subTotal,\r\n taxableAmount: taxableAmount,\r\n taxTotal: taxTotal,\r\n discounts: this.total.discounts,\r\n grandTotal: grandTotal\r\n }\r\n }\r\n\r\n /**\r\n * Resets the line item's properties to their default empty or initial state.\r\n * Useful for clearing out line item data without creating a new instance.\r\n * Recalculates total quantity and price total afterwards (which will be zero).\r\n */\r\n clearLineItem(): void {\r\n const zero = this.pricing.unitPrice.zero()\r\n this.id = '';\r\n this.productKey = '';\r\n this.selectionAttributes = { color: { name: '' } };\r\n this.name = { en: '' };\r\n this.primaryImage = new ImageInfoModel({ sources: { original: '' } });\r\n this.subItems = [];\r\n this.pricing = {\r\n unitPrice: zero,\r\n tierPricing: this.pricing.tierPricing,\r\n taxCategory: this.pricing.taxCategory,\r\n tax: this.pricing.tax\r\n }\r\n this.total = {\r\n quantity: 0,\r\n subtotal: zero,\r\n taxableAmount: zero,\r\n taxTotal: zero,\r\n discounts: {},\r\n grandTotal: zero\r\n };\r\n }\r\n}"]}
@@ -1,3 +0,0 @@
1
- import {a as a$1}from'./chunk-R32ZSPV6.mjs';import {o}from'./chunk-DGFO2MH6.mjs';import {a}from'./chunk-55SOBG62.mjs';var m=class{getBreakdown(t,a,e){let r=t*100,i=r%1===0?r.toString():r.toFixed(2).replace(/\.?0+$/,"");if(a==="IN"&&e?.merchantState&&e?.customerState)if(e.merchantState.toLowerCase().trim()===e.customerState.toLowerCase().trim()){let o=r/2%1===0?(r/2).toString():(r/2).toFixed(2).replace(/\.?0+$/,"");return {totalRate:t,label:`${o}% CGST + ${o}% SGST`,components:[{rate:t/2,label:`${o}% CGST`,type:"CGST"},{rate:t/2,label:`${o}% SGST`,type:"SGST"}]}}else return {totalRate:t,label:`${i}% IGST`,components:[{rate:t,label:`${i}% IGST`,type:"IGST"}]};return {totalRate:t,label:`${i}% GST`,components:[{rate:t,label:`${i}% GST`,type:"GST"}]}}getLongName(){return "Goods and Services Tax"}},T={GST:new m},g=class s extends a{taxRuleId;taxSystem;taxCategory;country;slabs;effectiveFrom;effectiveTo;constructor(t,a=new Date){super(t,a),this.taxRuleId=t.taxRuleId,this.taxSystem=t.taxSystem,this.taxCategory=t.taxCategory,this.country=t.country,this.slabs=t.slabs.map(e=>({rate:e.rate,minUnitPrice:new a$1(e.minUnitPrice),maxUnitPrice:e.maxUnitPrice?new a$1(e.maxUnitPrice):void 0})),this.effectiveFrom=new Date(t.effectiveFrom),this.effectiveTo=t.effectiveTo?new Date(t.effectiveTo):void 0;}getTaxRuleId(){return this.taxRuleId}getTaxSystem(){return this.taxSystem}getTaxCategory(){return this.taxCategory}getCountry(){return this.country}getSlabs(){return this.slabs}getDetails(){return {taxRuleId:this.getTaxRuleId(),taxSystem:this.getTaxSystem(),taxCategory:this.getTaxCategory(),country:this.getCountry(),slabs:this.getSlabs().map(t=>({rate:t.rate,minUnitPrice:t.minUnitPrice.getDetails(),maxUnitPrice:t.maxUnitPrice?t.maxUnitPrice.getDetails():void 0})),effectiveFrom:this.effectiveFrom.toISOString(),effectiveTo:this.effectiveTo?this.effectiveTo.toISOString():void 0,...super.getDetails()}}appliesTo(t,a,e=new Date){return this.taxCategory===t&&this.country===a&&this.effectiveFrom<=e&&(this.effectiveTo?this.effectiveTo>=e:!0)}getApplicableTaxRate(t){return s.getApplicableTaxRate(t,this.slabs)}getTaxRateDisplayString(t,a){let e=this.getApplicableTaxRate(t);return s.getTaxRateDisplayString(e,{taxSystem:this.taxSystem,merchantState:a?.merchantState,customerState:a?.customerState})}getTaxRateBreakdown(t,a){let e=this.getApplicableTaxRate(t),r=T[this.taxSystem];if(r)return r.getBreakdown(e,this.country,a);let i=e*100,n=`${i%1===0?i.toString():i.toFixed(2).replace(/\.?0+$/,"")}% ${this.taxSystem}`;return {totalRate:e,label:n,components:[{rate:e,label:n,type:this.taxSystem}]}}getFormattedTaxRate(t,a={}){let r=this.getApplicableTaxRate(t)*100,i=r%1===0?r.toString():r.toFixed(2).replace(/\.?0+$/,""),o=a.variant||"short",n="";switch(o){case"percentageOnly":n=`${i}%`;break;case"detailed":let u=this.getTaxRateBreakdown(t,a),y=a.separator||(a.multiline?`
2
- `:" + ");n=u.components.map(f=>f.label).join(y);break;case"long":let l=T[this.taxSystem],p=l?l.getLongName(this.country):this.taxSystem.toString();n=`${i}% ${p}`;break;case"short":default:n=`${i}% ${this.taxSystem}`;break}return a.includeTaxesSuffix&&(n+=" (Incl. Taxes)"),n}static getApplicableTaxRate(t,a){let e=a.filter(r=>(r.minUnitPrice===void 0||t.compareTo(r.minUnitPrice)>=0)&&(r.maxUnitPrice===void 0||t.compareTo(r.maxUnitPrice)<0));if(e.length!==1)throw new o;return e[0].rate}static getTaxRateDisplayString(t,a){let e=t*100,r=e%1===0?e.toString():e.toFixed(2).replace(/\.?0+$/,"");if(a.taxSystem==="GST"&&a.merchantState&&a.customerState)if(a.merchantState.toLowerCase().trim()===a.customerState.toLowerCase().trim()){let i=e/2%1===0?(e/2).toString():(e/2).toFixed(2).replace(/\.?0+$/,"");return `${i}% CGST + ${i}% SGST`}else return `${r}% IGST`;return a.taxSystem?`${r}% ${a.taxSystem}`:`${r}%`}};export{m as a,T as b,g as c};//# sourceMappingURL=chunk-NFRTZM45.mjs.map
3
- //# sourceMappingURL=chunk-NFRTZM45.mjs.map