b23-lib 2.2.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Auth/index.js +1 -1
- package/dist/Auth/index.js.map +1 -1
- package/dist/Auth/index.mjs +1 -1
- package/dist/Classes/Cart.d.mts +1 -0
- package/dist/Classes/Cart.d.ts +1 -0
- package/dist/Classes/Cart.js +1 -2
- package/dist/Classes/Cart.js.map +1 -1
- package/dist/Classes/Cart.mjs +1 -1
- package/dist/Classes/Cart.mjs.map +1 -1
- package/dist/Classes/Charge.d.mts +99 -0
- package/dist/Classes/Charge.d.ts +99 -0
- package/dist/Classes/Charge.js +2 -0
- package/dist/Classes/Charge.js.map +1 -0
- package/dist/Classes/Charge.mjs +2 -0
- package/dist/Classes/Charge.mjs.map +1 -0
- package/dist/Classes/Coupon.js +1 -1
- package/dist/Classes/Coupon.js.map +1 -1
- package/dist/Classes/Coupon.mjs +1 -1
- package/dist/Classes/Enum.d.mts +4 -4
- package/dist/Classes/Enum.d.ts +4 -4
- package/dist/Classes/Enum.js +1 -1
- package/dist/Classes/Enum.js.map +1 -1
- package/dist/Classes/Enum.mjs +1 -1
- package/dist/Classes/Error.d.mts +4 -1
- package/dist/Classes/Error.d.ts +4 -1
- package/dist/Classes/Error.js +1 -1
- package/dist/Classes/Error.js.map +1 -1
- package/dist/Classes/Error.mjs +1 -1
- package/dist/Classes/ImageInfo.js.map +1 -1
- package/dist/Classes/ImageInfo.mjs +1 -1
- package/dist/Classes/Inventory.js +1 -1
- package/dist/Classes/Inventory.js.map +1 -1
- package/dist/Classes/Inventory.mjs +1 -1
- package/dist/Classes/LineItem.d.mts +46 -48
- package/dist/Classes/LineItem.d.ts +46 -48
- package/dist/Classes/LineItem.js +1 -2
- package/dist/Classes/LineItem.js.map +1 -1
- package/dist/Classes/LineItem.mjs +1 -1
- package/dist/Classes/Order.d.mts +1 -1
- package/dist/Classes/Order.d.ts +1 -1
- package/dist/Classes/Order.js +1 -2
- package/dist/Classes/Order.js.map +1 -1
- package/dist/Classes/Order.mjs +1 -1
- package/dist/Classes/Order.mjs.map +1 -1
- package/dist/Classes/Price.js +1 -1
- package/dist/Classes/Price.js.map +1 -1
- package/dist/Classes/Price.mjs +1 -1
- package/dist/Classes/Product.js +1 -1
- package/dist/Classes/Product.js.map +1 -1
- package/dist/Classes/Product.mjs +1 -1
- package/dist/Classes/ShoppingContainer.d.mts +98 -40
- package/dist/Classes/ShoppingContainer.d.ts +98 -40
- package/dist/Classes/ShoppingContainer.js +1 -2
- package/dist/Classes/ShoppingContainer.js.map +1 -1
- package/dist/Classes/ShoppingContainer.mjs +1 -1
- package/dist/Classes/TaxCategoryModel.d.mts +42 -0
- package/dist/Classes/TaxCategoryModel.d.ts +42 -0
- package/dist/Classes/TaxCategoryModel.js +2 -0
- package/dist/Classes/TaxCategoryModel.js.map +1 -0
- package/dist/Classes/TaxCategoryModel.mjs +2 -0
- package/dist/Classes/TaxCategoryModel.mjs.map +1 -0
- package/dist/Classes/TaxRule.d.mts +59 -79
- package/dist/Classes/TaxRule.d.ts +59 -79
- package/dist/Classes/TaxRule.js +1 -2
- package/dist/Classes/TaxRule.js.map +1 -1
- package/dist/Classes/TaxRule.mjs +1 -1
- package/dist/Classes/TieredPrice.d.mts +4 -4
- package/dist/Classes/TieredPrice.d.ts +4 -4
- package/dist/Classes/TieredPrice.js +1 -1
- package/dist/Classes/TieredPrice.js.map +1 -1
- package/dist/Classes/TieredPrice.mjs +1 -1
- package/dist/{chunk-EV4HUBJL.mjs → chunk-6X5O25W5.mjs} +2 -2
- package/dist/chunk-6X5O25W5.mjs.map +1 -0
- package/dist/chunk-FC4P26U3.mjs +2 -0
- package/dist/chunk-FC4P26U3.mjs.map +1 -0
- package/dist/chunk-IIPG3DTO.mjs +2 -0
- package/dist/chunk-IIPG3DTO.mjs.map +1 -0
- package/dist/{chunk-LEHPVA3Q.mjs → chunk-JE7BAYI5.mjs} +2 -2
- package/dist/{chunk-LEHPVA3Q.mjs.map → chunk-JE7BAYI5.mjs.map} +1 -1
- package/dist/chunk-KKQLCW6A.mjs +2 -0
- package/dist/chunk-KKQLCW6A.mjs.map +1 -0
- package/dist/chunk-PTIPDRB4.mjs +2 -0
- package/dist/chunk-PTIPDRB4.mjs.map +1 -0
- package/dist/{chunk-GF427QWC.mjs → chunk-RSMXGZD4.mjs} +2 -2
- package/dist/{chunk-GF427QWC.mjs.map → chunk-RSMXGZD4.mjs.map} +1 -1
- package/dist/{chunk-WSUPVXRZ.mjs → chunk-RSTZJZSQ.mjs} +2 -2
- package/dist/{chunk-WSUPVXRZ.mjs.map → chunk-RSTZJZSQ.mjs.map} +1 -1
- package/dist/chunk-U7DES3CI.mjs +2 -0
- package/dist/chunk-U7DES3CI.mjs.map +1 -0
- package/dist/{chunk-JHELVQYY.mjs → chunk-XPKK6DFA.mjs} +2 -2
- package/dist/chunk-XPKK6DFA.mjs.map +1 -0
- package/dist/chunk-XXETAAL4.mjs +2 -0
- package/dist/chunk-XXETAAL4.mjs.map +1 -0
- package/dist/index.d.mts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -1
- package/dist/chunk-43SMYXYL.mjs +0 -2
- package/dist/chunk-43SMYXYL.mjs.map +0 -1
- package/dist/chunk-5VI4V3SF.mjs +0 -2
- package/dist/chunk-5VI4V3SF.mjs.map +0 -1
- package/dist/chunk-72DR3HF2.mjs +0 -2
- package/dist/chunk-72DR3HF2.mjs.map +0 -1
- package/dist/chunk-CKJONVT3.mjs +0 -2
- package/dist/chunk-CKJONVT3.mjs.map +0 -1
- package/dist/chunk-EV4HUBJL.mjs.map +0 -1
- package/dist/chunk-JHELVQYY.mjs.map +0 -1
- package/dist/chunk-RQC4PNOV.mjs +0 -3
- package/dist/chunk-RQC4PNOV.mjs.map +0 -1
package/dist/Classes/Enum.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var R=(n=>(n.IN="IN",n))(R||{}),p=(n=>(n.INR="INR",n))(p||{}),r=(I=>(I["en-IN"]="en-IN",I["kn-IN"]="kn-IN",I))(r||{}),D=(N=>(N.en="en",N.kn="kn",N))(D||{}),A={"en-IN":"en","kn-IN":"kn"},T={"en-IN":"IN","kn-IN":"IN"},x={IN:"INR"},U={INR:"\u20B9"},M={INR:"en-IN"},l=(o=>(o.MALE="Male",o.FEMALE="Female",o.UNISEX="Unisex",o.KIDS="Kids",o.BOY="Boy",o.GIRL="Girl",o.GENERAL="General",o))(l||{}),u=(N=>(N.PRIMARY="PRIMARY",N.GALLERY="GALLERY",N))(u||{}),c=(N=>(N.SHIPPING="SHIPPING",N.ADJUSTMENT="ADJUSTMENT",N))(c||{}),a=(n=>(n.GST="GST",n))(a||{}),L=(E=>(E.INITIAL="INITIAL",E.PROCESSING="PROCESSING",E.SHIPPED="SHIPPED",E.DELIVERED="DELIVERED",E.CANCELLED="CANCELLED",E.RETURN_REQUESTED="RETURN_REQUESTED",E.RETURNED="RETURNED",E.REFUND_INITIATED="REFUND_INITIATED",E.REFUNDED="REFUNDED",E.ON_HOLD="ON_HOLD",E))(L||{});exports.ChargeType=c;exports.CountryCurrencyMap=x;exports.CurrencyLocaleMap=M;exports.CurrencySymbolMap=U;exports.GenderCategory=l;exports.ImageCategory=u;exports.LineItemState=L;exports.LocaleCountryMap=T;exports.LocaleLanguageMap=A;exports.OperationalCountry=R;exports.OperationalCountryCurrency=p;exports.OperationalLanguage=D;exports.OperationalLocale=r;exports.TaxSystem=a;//# sourceMappingURL=Enum.js.map
|
|
2
2
|
//# sourceMappingURL=Enum.js.map
|
package/dist/Classes/Enum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Classes/Enum.ts"],"names":["OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","LocaleLanguageMap","LocaleCountryMap","CountryCurrencyMap","CurrencySymbolMap","CurrencyLocaleMap","GenderCategory","ImageCategory","
|
|
1
|
+
{"version":3,"sources":["../../src/Classes/Enum.ts"],"names":["OperationalCountry","OperationalCountryCurrency","OperationalLocale","OperationalLanguage","LocaleLanguageMap","LocaleCountryMap","CountryCurrencyMap","CurrencySymbolMap","CurrencyLocaleMap","GenderCategory","ImageCategory","ChargeType","TaxSystem","LineItemState"],"mappings":"aAGO,IAAKA,CACGA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,EAAK,CAAA,IAAA,CADRA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAIAC,CACGA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,GAAM,CAAA,KAAA,CADTA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAIAC,OACGA,CAAA,CAAA,OAAA,CAAA,CAAU,OACCA,CAAAA,CAAAA,CAAA,OAAU,CAAA,CAAA,OAAA,CAFxBA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,EAAA,CAAK,IACLA,CAAAA,CAAAA,CAAA,EAAK,CAAA,IAAA,CAFKA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKCC,EAAoE,CAC9E,OAAA,CAA6B,IAC7B,CAAA,OAAA,CAA6B,IAChC,CAAA,CAEaC,CAAkE,CAAA,CAC5E,QAA6B,IAC7B,CAAA,OAAA,CAA6B,IAChC,CAAA,CAKaC,CAAqB,CAAA,CACnB,EAAwB,CAAA,KACvC,EAEaC,CAAoB,CAAA,CAC9B,GAAiC,CAAA,QACpC,CAEaC,CAAAA,CAAAA,CAAoB,CAC9B,GAAA,CAAiC,OACpC,CAKYC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAA,CAAA,IAAA,CAAO,MACPA,CAAAA,CAAAA,CAAA,MAAS,CAAA,QAAA,CACTA,EAAA,MAAS,CAAA,QAAA,CACTA,CAAA,CAAA,IAAA,CAAO,MACPA,CAAAA,CAAAA,CAAA,GAAM,CAAA,KAAA,CACNA,CAAA,CAAA,IAAA,CAAO,MACPA,CAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CAPAA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAUAC,OACVA,CAAA,CAAA,OAAA,CAAU,SACVA,CAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CAFAA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,QAAA,CAAW,UACXA,CAAAA,CAAAA,CAAA,UAAa,CAAA,YAAA,CAFHA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,GAAA,CAAM,KADIA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAkBAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAA,CAAA,OAAA,CAAU,UACVA,CAAA,CAAA,UAAA,CAAa,YACbA,CAAAA,CAAAA,CAAA,OAAU,CAAA,SAAA,CACVA,CAAA,CAAA,SAAA,CAAY,YACZA,CAAA,CAAA,SAAA,CAAY,WACZA,CAAAA,CAAAA,CAAA,gBAAmB,CAAA,kBAAA,CACnBA,CAAA,CAAA,QAAA,CAAW,WACXA,CAAA,CAAA,gBAAA,CAAmB,kBACnBA,CAAAA,CAAAA,CAAA,QAAW,CAAA,UAAA,CACXA,CAAA,CAAA,OAAA,CAAU,UAVAA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA","file":"Enum.js","sourcesContent":["/**\r\n * Represents the countries where the application operates or products are available.\r\n */\r\nexport enum OperationalCountry {\r\n /** India */ IN = 'IN',\r\n}\r\n\r\nexport enum OperationalCountryCurrency {\r\n /** India */ INR = 'INR',\r\n}\r\n\r\nexport enum OperationalLocale {\r\n /** India */ 'en-IN' = 'en-IN',\r\n /** India ( Kannada) */ 'kn-IN' = 'kn-IN'\r\n}\r\n\r\nexport enum OperationalLanguage {\r\n en = 'en',\r\n kn = 'kn'\r\n}\r\n\r\nexport const LocaleLanguageMap: Record<OperationalLocale, OperationalLanguage> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalLanguage.en,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalLanguage.kn,\r\n}\r\n\r\nexport const LocaleCountryMap: Record<OperationalLocale, OperationalCountry> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalCountry.IN,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalCountry.IN,\r\n}\r\n\r\n/**\r\n * Defines the supported ISO 4217 currency codes as an enumeration.\r\n */\r\nexport const CountryCurrencyMap = {\r\n /** India */[OperationalCountry.IN]: OperationalCountryCurrency.INR,\r\n};\r\n\r\nexport const CurrencySymbolMap = {\r\n [OperationalCountryCurrency.INR]: '₹',\r\n}\r\n\r\nexport const CurrencyLocaleMap = {\r\n [OperationalCountryCurrency.INR]: OperationalLocale[\"en-IN\"],\r\n}\r\n\r\n/**\r\n * Defines standard gender categories for product targeting.\r\n */\r\nexport enum GenderCategory {\r\n MALE = 'Male',\r\n FEMALE = 'Female',\r\n UNISEX = 'Unisex',\r\n KIDS = 'Kids',\r\n BOY = 'Boy',\r\n GIRL = 'Girl',\r\n GENERAL = 'General',\r\n}\r\n\r\nexport enum ImageCategory {\r\n PRIMARY = 'PRIMARY',\r\n GALLERY = 'GALLERY'\r\n}\r\n\r\nexport enum ChargeType {\r\n SHIPPING = 'SHIPPING',\r\n ADJUSTMENT = 'ADJUSTMENT'\r\n}\r\n\r\nexport enum TaxSystem {\r\n GST = 'GST',\r\n}\r\n\r\n/**\r\n * LineItemState\r\n * \r\n * INITIAL: Item added to order, not yet processed.\r\n * PROCESSING: Item is being prepared for shipment.\r\n * SHIPPED: Item dispatched to customer.\r\n * DELIVERED: Item delivered to customer.\r\n * CANCELLED: Item cancelled before shipment or delivery.\r\n * RETURN_REQUESTED: Customer requests to return item.\r\n * RETURNED: Item received back from customer.\r\n * REFUND_INITIATED: Refund initiated for item.\r\n * REFUNDED: Refund processed for item.\r\n * ON_HOLD: Item is paused due to payment, inventory, or other issues.\r\n */\r\nexport enum LineItemState {\r\n INITIAL = \"INITIAL\",\r\n PROCESSING = \"PROCESSING\",\r\n SHIPPED = \"SHIPPED\",\r\n DELIVERED = \"DELIVERED\",\r\n CANCELLED = \"CANCELLED\",\r\n RETURN_REQUESTED = \"RETURN_REQUESTED\",\r\n RETURNED = \"RETURNED\",\r\n REFUND_INITIATED = \"REFUND_INITIATED\",\r\n REFUNDED = \"REFUNDED\",\r\n ON_HOLD = \"ON_HOLD\",\r\n}"]}
|
package/dist/Classes/Enum.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{g as CountryCurrencyMap,i as CurrencyLocaleMap,h as CurrencySymbolMap,j as GenderCategory,k as ImageCategory,n as LineItemState,f as LocaleCountryMap,e as LocaleLanguageMap,a as OperationalCountry,b as OperationalCountryCurrency,d as OperationalLanguage,c as OperationalLocale,
|
|
1
|
+
export{l as ChargeType,g as CountryCurrencyMap,i as CurrencyLocaleMap,h as CurrencySymbolMap,j as GenderCategory,k as ImageCategory,n as LineItemState,f as LocaleCountryMap,e as LocaleLanguageMap,a as OperationalCountry,b as OperationalCountryCurrency,d as OperationalLanguage,c as OperationalLocale,m as TaxSystem}from'../chunk-FC4P26U3.mjs';//# sourceMappingURL=Enum.mjs.map
|
|
2
2
|
//# sourceMappingURL=Enum.mjs.map
|
package/dist/Classes/Error.d.mts
CHANGED
|
@@ -61,5 +61,8 @@ declare class InvalidArgumentError extends Error {
|
|
|
61
61
|
declare class InvalidImageSourceError extends Error {
|
|
62
62
|
constructor(message?: string);
|
|
63
63
|
}
|
|
64
|
+
declare class InvalidChargeError extends Error {
|
|
65
|
+
constructor(message?: string);
|
|
66
|
+
}
|
|
64
67
|
|
|
65
|
-
export { CurrencyMismatchError, DuplicateSelectionAttributeError, DuplicateSizeError, InvalidArgumentError, InvalidCurrencyCodeError, InvalidImageSourceError, InvalidLineItemStateError, InvalidMinQuantityError, InvalidPriceAmountError, InvalidQuantityError, InvalidTaxCategoryError, InvalidTaxRuleError, InvalidTieredPriceError, LineItemNotFoundError, NoApplicableTierError, PricingNotFoundError, ProductInactiveError, ProductMismatchError, SelectionAttributeParseError, SizeMismatchError, TaxSlabNotFoundError };
|
|
68
|
+
export { CurrencyMismatchError, DuplicateSelectionAttributeError, DuplicateSizeError, InvalidArgumentError, InvalidChargeError, InvalidCurrencyCodeError, InvalidImageSourceError, InvalidLineItemStateError, InvalidMinQuantityError, InvalidPriceAmountError, InvalidQuantityError, InvalidTaxCategoryError, InvalidTaxRuleError, InvalidTieredPriceError, LineItemNotFoundError, NoApplicableTierError, PricingNotFoundError, ProductInactiveError, ProductMismatchError, SelectionAttributeParseError, SizeMismatchError, TaxSlabNotFoundError };
|
package/dist/Classes/Error.d.ts
CHANGED
|
@@ -61,5 +61,8 @@ declare class InvalidArgumentError extends Error {
|
|
|
61
61
|
declare class InvalidImageSourceError extends Error {
|
|
62
62
|
constructor(message?: string);
|
|
63
63
|
}
|
|
64
|
+
declare class InvalidChargeError extends Error {
|
|
65
|
+
constructor(message?: string);
|
|
66
|
+
}
|
|
64
67
|
|
|
65
|
-
export { CurrencyMismatchError, DuplicateSelectionAttributeError, DuplicateSizeError, InvalidArgumentError, InvalidCurrencyCodeError, InvalidImageSourceError, InvalidLineItemStateError, InvalidMinQuantityError, InvalidPriceAmountError, InvalidQuantityError, InvalidTaxCategoryError, InvalidTaxRuleError, InvalidTieredPriceError, LineItemNotFoundError, NoApplicableTierError, PricingNotFoundError, ProductInactiveError, ProductMismatchError, SelectionAttributeParseError, SizeMismatchError, TaxSlabNotFoundError };
|
|
68
|
+
export { CurrencyMismatchError, DuplicateSelectionAttributeError, DuplicateSizeError, InvalidArgumentError, InvalidChargeError, InvalidCurrencyCodeError, InvalidImageSourceError, InvalidLineItemStateError, InvalidMinQuantityError, InvalidPriceAmountError, InvalidQuantityError, InvalidTaxCategoryError, InvalidTaxRuleError, InvalidTieredPriceError, LineItemNotFoundError, NoApplicableTierError, PricingNotFoundError, ProductInactiveError, ProductMismatchError, SelectionAttributeParseError, SizeMismatchError, TaxSlabNotFoundError };
|
package/dist/Classes/Error.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var e=class extends Error{constructor(r){super(`Line item with ID '${r}' not found in the cart.`),this.name="LineItemNotFoundError";}},s=class extends Error{constructor(r){super(`Invalid line item state: ${r}`),this.name="InvalidLineItemStateError";}},n=class extends Error{constructor(r){super(`Duplicate size found: ${r}`),this.name="DuplicateSizeError";}},o=class extends Error{constructor(r){super(`Duplicate selection attribute found: ${r}`),this.name="DuplicateSelectionAttributeError";}},i=class extends Error{constructor(r="Product and selection attributes do not match."){super(`ProductMismatch: ${r}`),this.name="ProductMismatchError";}},a=class extends Error{constructor(r="Product is not active."){super(`ProductInactive: ${r}`),this.name="ProductInactiveError";}},c=class extends Error{constructor(r="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${r}`),this.name="SelectionAttributeParseError";}},u=class extends Error{constructor(r="Size does not match."){super(`SizeMismatch: ${r}`),this.name="SizeMismatchError";}},
|
|
1
|
+
'use strict';var e=class extends Error{constructor(r){super(`Line item with ID '${r}' not found in the cart.`),this.name="LineItemNotFoundError";}},s=class extends Error{constructor(r){super(`Invalid line item state: ${r}`),this.name="InvalidLineItemStateError";}},n=class extends Error{constructor(r){super(`Duplicate size found: ${r}`),this.name="DuplicateSizeError";}},o=class extends Error{constructor(r){super(`Duplicate selection attribute found: ${r}`),this.name="DuplicateSelectionAttributeError";}},i=class extends Error{constructor(r="Product and selection attributes do not match."){super(`ProductMismatch: ${r}`),this.name="ProductMismatchError";}},a=class extends Error{constructor(r="Product is not active."){super(`ProductInactive: ${r}`),this.name="ProductInactiveError";}},c=class extends Error{constructor(r="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${r}`),this.name="SelectionAttributeParseError";}},u=class extends Error{constructor(r="Size does not match."){super(`SizeMismatch: ${r}`),this.name="SizeMismatchError";}},d=class extends Error{constructor(r="Pricing details not available for the product"){super(`NotFound: ${r}`),this.name="PricingNotFoundError";}},l=class extends Error{constructor(r="Tax rule category mismatch."){super(`InvalidTaxRule: ${r}`),this.name="InvalidTaxRuleError";}},p=class extends Error{constructor(r="Tax category is not valid."){super(`InvalidTaxCategory: ${r}`),this.name="InvalidTaxCategoryError";}},x=class extends Error{constructor(r="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${r}`),this.name="InvalidMinQuantityError";}},m=class extends Error{constructor(r){super(`InvalidTieredPrice: ${r}`),this.name="InvalidTieredPriceError";}},h=class extends Error{constructor(r="Quantity must be greater than zero."){super(`InvalidQuantity: ${r}`),this.name="InvalidQuantityError";}},g=class extends Error{constructor(r){super(`NoApplicableTier: Quantity ${r} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}},E=class extends Error{constructor(r="No applicable tax slab or multiple slabs found for the given unit price."){super(`TaxSlabNotFound: ${r}`),this.name="TaxSlabNotFoundError";}},$=class extends Error{constructor(r="Amount cannot be negative."){super(`InvalidAmount: ${r}`),this.name="InvalidPriceAmountError";}},v=class extends Error{constructor(r="Currency code is required."){super(`InvalidCurrency: ${r}`),this.name="InvalidCurrencyCodeError";}},I=class extends Error{constructor(r="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${r}`),this.name="CurrencyMismatchError";}},b=class extends Error{constructor(r){super(`InvalidArgument: ${r}`),this.name="InvalidArgumentError";}},y=class extends Error{constructor(r="Invalid image source configuration."){super(`InvalidImageSource: ${r}`),this.name="InvalidImageSourceError";}},f=class extends Error{constructor(r="Invalid charge data."){super(`InvalidCharge: ${r}`),this.name="InvalidChargeError";}};exports.CurrencyMismatchError=I;exports.DuplicateSelectionAttributeError=o;exports.DuplicateSizeError=n;exports.InvalidArgumentError=b;exports.InvalidChargeError=f;exports.InvalidCurrencyCodeError=v;exports.InvalidImageSourceError=y;exports.InvalidLineItemStateError=s;exports.InvalidMinQuantityError=x;exports.InvalidPriceAmountError=$;exports.InvalidQuantityError=h;exports.InvalidTaxCategoryError=p;exports.InvalidTaxRuleError=l;exports.InvalidTieredPriceError=m;exports.LineItemNotFoundError=e;exports.NoApplicableTierError=g;exports.PricingNotFoundError=d;exports.ProductInactiveError=a;exports.ProductMismatchError=i;exports.SelectionAttributeParseError=c;exports.SizeMismatchError=u;exports.TaxSlabNotFoundError=E;//# sourceMappingURL=Error.js.map
|
|
2
2
|
//# sourceMappingURL=Error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Classes/Error.ts"],"names":["LineItemNotFoundError","lineItemId","InvalidLineItemStateError","state","DuplicateSizeError","size","DuplicateSelectionAttributeError","attribute","ProductMismatchError","message","ProductInactiveError","SelectionAttributeParseError","SizeMismatchError","PricingNotFoundError","InvalidTaxRuleError","InvalidTaxCategoryError","InvalidMinQuantityError","InvalidTieredPriceError","InvalidQuantityError","NoApplicableTierError","quantity","TaxSlabNotFoundError","InvalidPriceAmountError","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","InvalidImageSourceError"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Classes/Error.ts"],"names":["LineItemNotFoundError","lineItemId","InvalidLineItemStateError","state","DuplicateSizeError","size","DuplicateSelectionAttributeError","attribute","ProductMismatchError","message","ProductInactiveError","SelectionAttributeParseError","SizeMismatchError","PricingNotFoundError","InvalidTaxRuleError","InvalidTaxCategoryError","InvalidMinQuantityError","InvalidTieredPriceError","InvalidQuantityError","NoApplicableTierError","quantity","TaxSlabNotFoundError","InvalidPriceAmountError","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","InvalidImageSourceError","InvalidChargeError"],"mappings":"aAAaA,IAAAA,CAAAA,CAAN,cAAoC,KAAM,CAC7C,YAAYC,CAAoB,CAAA,CAC5B,MAAM,CAAsBA,mBAAAA,EAAAA,CAAU,0BAA0B,CAChE,CAAA,IAAA,CAAK,KAAO,wBAChB,CACJ,EAEaC,CAAN,CAAA,cAAwC,KAAM,CACjD,WAAA,CAAYC,EAAe,CACvB,KAAA,CAAM,4BAA4BA,CAAK,CAAA,CAAE,EACzC,IAAK,CAAA,IAAA,CAAO,4BAChB,CACJ,CAAA,CAEaC,EAAN,cAAiC,KAAM,CAC1C,WAAYC,CAAAA,CAAAA,CAAc,CACtB,KAAM,CAAA,CAAA,sBAAA,EAAyBA,CAAI,CAAE,CAAA,CAAA,CACrC,KAAK,IAAO,CAAA,qBAChB,CACJ,CAEaC,CAAAA,CAAAA,CAAN,cAA+C,KAAM,CACxD,YAAYC,CAAmB,CAAA,CAC3B,MAAM,CAAwCA,qCAAAA,EAAAA,CAAS,EAAE,CACzD,CAAA,IAAA,CAAK,KAAO,mCAChB,CACJ,EAEaC,CAAN,CAAA,cAAmC,KAAM,CAC5C,WAAA,CAAYC,EAAkB,gDAAkD,CAAA,CAC5E,MAAM,CAAoBA,iBAAAA,EAAAA,CAAO,EAAE,CACnC,CAAA,IAAA,CAAK,KAAO,uBAChB,CACJ,EAEaC,CAAN,CAAA,cAAmC,KAAM,CAC5C,WAAA,CAAYD,CAAkB,CAAA,wBAAA,CAA0B,CACpD,KAAA,CAAM,oBAAoBA,CAAO,CAAA,CAAE,EACnC,IAAK,CAAA,IAAA,CAAO,uBAChB,CACJ,CAAA,CAEaE,EAAN,cAA2C,KAAM,CACpD,WAAYF,CAAAA,CAAAA,CAAkB,4CAA6C,CACvE,KAAA,CAAM,iCAAiCA,CAAO,CAAA,CAAE,EAChD,IAAK,CAAA,IAAA,CAAO,+BAChB,CACJ,CAAA,CAEaG,EAAN,cAAgC,KAAM,CACzC,WAAYH,CAAAA,CAAAA,CAAkB,uBAAwB,CAClD,KAAA,CAAM,iBAAiBA,CAAO,CAAA,CAAE,EAChC,IAAK,CAAA,IAAA,CAAO,oBAChB,CACJ,CAAA,CAEaI,CAAN,CAAA,cAAmC,KAAM,CAC5C,YAAYJ,CAAkB,CAAA,+CAAA,CAAiD,CAC3E,KAAM,CAAA,CAAA,UAAA,EAAaA,CAAO,CAAE,CAAA,CAAA,CAC5B,KAAK,IAAO,CAAA,uBAChB,CACJ,CAEaK,CAAAA,CAAAA,CAAN,cAAkC,KAAM,CAC3C,YAAYL,CAAkB,CAAA,6BAAA,CAA+B,CACzD,KAAM,CAAA,CAAA,gBAAA,EAAmBA,CAAO,CAAE,CAAA,CAAA,CAClC,KAAK,IAAO,CAAA,sBAChB,CACJ,CAEaM,CAAAA,CAAAA,CAAN,cAAsC,KAAM,CAC/C,YAAYN,CAAkB,CAAA,4BAAA,CAA8B,CACxD,KAAM,CAAA,CAAA,oBAAA,EAAuBA,CAAO,CAAE,CAAA,CAAA,CACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,EAEaO,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAA,CAAYP,EAAkB,6CAA+C,CAAA,CACzE,MAAM,CAAuBA,oBAAAA,EAAAA,CAAO,EAAE,CACtC,CAAA,IAAA,CAAK,KAAO,0BAChB,CACJ,EAEaQ,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAA,CAAYR,EAAiB,CACzB,KAAA,CAAM,uBAAuBA,CAAO,CAAA,CAAE,EACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,CAAA,CAEaS,EAAN,cAAmC,KAAM,CAC5C,WAAYT,CAAAA,CAAAA,CAAkB,sCAAuC,CACjE,KAAA,CAAM,CAAoBA,iBAAAA,EAAAA,CAAO,CAAE,CAAA,CAAA,CACnC,KAAK,IAAO,CAAA,uBAChB,CACJ,CAEaU,CAAAA,CAAAA,CAAN,cAAoC,KAAM,CAC7C,YAAYC,CAAkB,CAAA,CAC1B,MAAM,CAA8BA,2BAAAA,EAAAA,CAAQ,kDAAkD,CAC9F,CAAA,IAAA,CAAK,KAAO,wBAChB,CACJ,EAEaC,CAAN,CAAA,cAAmC,KAAM,CAC5C,WAAA,CAAYZ,EAAkB,0EAA4E,CAAA,CACtG,MAAM,CAAoBA,iBAAAA,EAAAA,CAAO,EAAE,CACnC,CAAA,IAAA,CAAK,KAAO,uBAChB,CACJ,EAEaa,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAA,CAAYb,CAAkB,CAAA,4BAAA,CAA8B,CACxD,KAAA,CAAM,kBAAkBA,CAAO,CAAA,CAAE,EACjC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,CAAA,CAEac,EAAN,cAAuC,KAAM,CAChD,WAAYd,CAAAA,CAAAA,CAAkB,6BAA8B,CACxD,KAAA,CAAM,oBAAoBA,CAAO,CAAA,CAAE,EACnC,IAAK,CAAA,IAAA,CAAO,2BAChB,CACJ,CAAA,CAEae,EAAN,cAAoC,KAAM,CAC7C,WAAYf,CAAAA,CAAAA,CAAkB,gEAAiE,CAC3F,KAAA,CAAM,qBAAqBA,CAAO,CAAA,CAAE,EACpC,IAAK,CAAA,IAAA,CAAO,wBAChB,CACJ,CAAA,CAEagB,CAAN,CAAA,cAAmC,KAAM,CAC5C,YAAYhB,CAAiB,CAAA,CACzB,MAAM,CAAoBA,iBAAAA,EAAAA,CAAO,EAAE,CACnC,CAAA,IAAA,CAAK,KAAO,uBAChB,CACJ,EAEaiB,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAA,CAAYjB,EAAkB,qCAAuC,CAAA,CACjE,MAAM,CAAuBA,oBAAAA,EAAAA,CAAO,EAAE,CACtC,CAAA,IAAA,CAAK,KAAO,0BAChB,CACJ,EAEakB,CAAN,CAAA,cAAiC,KAAM,CAC1C,WAAA,CAAYlB,EAAkB,sBAAwB,CAAA,CAClD,MAAM,CAAkBA,eAAAA,EAAAA,CAAO,EAAE,CACjC,CAAA,IAAA,CAAK,IAAO,CAAA,qBAChB,CACJ","file":"Error.js","sourcesContent":["export class LineItemNotFoundError extends Error {\r\n constructor(lineItemId: string) {\r\n super(`Line item with ID '${lineItemId}' not found in the cart.`);\r\n this.name = 'LineItemNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidLineItemStateError extends Error {\r\n constructor(state: string) {\r\n super(`Invalid line item state: ${state}`);\r\n this.name = 'InvalidLineItemStateError';\r\n }\r\n}\r\n\r\nexport class DuplicateSizeError extends Error {\r\n constructor(size: string) {\r\n super(`Duplicate size found: ${size}`);\r\n this.name = 'DuplicateSizeError';\r\n }\r\n}\r\n\r\nexport class DuplicateSelectionAttributeError extends Error {\r\n constructor(attribute: string) {\r\n super(`Duplicate selection attribute found: ${attribute}`);\r\n this.name = 'DuplicateSelectionAttributeError';\r\n }\r\n}\r\n\r\nexport class ProductMismatchError extends Error {\r\n constructor(message: string = \"Product and selection attributes do not match.\") {\r\n super(`ProductMismatch: ${message}`);\r\n this.name = 'ProductMismatchError';\r\n }\r\n}\r\n\r\nexport class ProductInactiveError extends Error {\r\n constructor(message: string = \"Product is not active.\") {\r\n super(`ProductInactive: ${message}`);\r\n this.name = 'ProductInactiveError';\r\n }\r\n}\r\n\r\nexport class SelectionAttributeParseError extends Error {\r\n constructor(message: string = \"Failed to parse selection attributes key.\") {\r\n super(`SelectionAttributeParseError: ${message}`);\r\n this.name = 'SelectionAttributeParseError';\r\n }\r\n}\r\n\r\nexport class SizeMismatchError extends Error {\r\n constructor(message: string = \"Size does not match.\") {\r\n super(`SizeMismatch: ${message}`);\r\n this.name = 'SizeMismatchError';\r\n }\r\n}\r\n\r\nexport class PricingNotFoundError extends Error {\r\n constructor(message: string = \"Pricing details not available for the product\") {\r\n super(`NotFound: ${message}`);\r\n this.name = 'PricingNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxRuleError extends Error {\r\n constructor(message: string = \"Tax rule category mismatch.\") {\r\n super(`InvalidTaxRule: ${message}`);\r\n this.name = 'InvalidTaxRuleError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxCategoryError extends Error {\r\n constructor(message: string = \"Tax category is not valid.\") {\r\n super(`InvalidTaxCategory: ${message}`);\r\n this.name = 'InvalidTaxCategoryError';\r\n }\r\n}\r\n\r\nexport class InvalidMinQuantityError extends Error {\r\n constructor(message: string = \"Minimum quantity must be greater than zero.\") {\r\n super(`InvalidMinQuantity: ${message}`);\r\n this.name = 'InvalidMinQuantityError';\r\n }\r\n}\r\n\r\nexport class InvalidTieredPriceError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidTieredPrice: ${message}`);\r\n this.name = 'InvalidTieredPriceError';\r\n }\r\n}\r\n\r\nexport class InvalidQuantityError extends Error {\r\n constructor(message: string = \"Quantity must be greater than zero.\") {\r\n super(`InvalidQuantity: ${message}`);\r\n this.name = 'InvalidQuantityError';\r\n }\r\n}\r\n\r\nexport class NoApplicableTierError extends Error {\r\n constructor(quantity: number) {\r\n super(`NoApplicableTier: Quantity ${quantity} does not meet the minimum purchase requirement.`);\r\n this.name = 'NoApplicableTierError';\r\n }\r\n}\r\n\r\nexport class TaxSlabNotFoundError extends Error {\r\n constructor(message: string = \"No applicable tax slab or multiple slabs found for the given unit price.\") {\r\n super(`TaxSlabNotFound: ${message}`);\r\n this.name = 'TaxSlabNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidPriceAmountError extends Error {\r\n constructor(message: string = \"Amount cannot be negative.\") {\r\n super(`InvalidAmount: ${message}`);\r\n this.name = 'InvalidPriceAmountError';\r\n }\r\n}\r\n\r\nexport class InvalidCurrencyCodeError extends Error {\r\n constructor(message: string = \"Currency code is required.\") {\r\n super(`InvalidCurrency: ${message}`);\r\n this.name = 'InvalidCurrencyCodeError';\r\n }\r\n}\r\n\r\nexport class CurrencyMismatchError extends Error {\r\n constructor(message: string = \"Cannot perform operation on prices with different currencies.\") {\r\n super(`CurrencyMismatch: ${message}`);\r\n this.name = 'CurrencyMismatchError';\r\n }\r\n}\r\n\r\nexport class InvalidArgumentError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidArgument: ${message}`);\r\n this.name = 'InvalidArgumentError';\r\n }\r\n}\r\n\r\nexport class InvalidImageSourceError extends Error {\r\n constructor(message: string = \"Invalid image source configuration.\") {\r\n super(`InvalidImageSource: ${message}`);\r\n this.name = 'InvalidImageSourceError';\r\n }\r\n}\r\n\r\nexport class InvalidChargeError extends Error {\r\n constructor(message: string = \"Invalid charge data.\") {\r\n super(`InvalidCharge: ${message}`);\r\n this.name = 'InvalidChargeError';\r\n }\r\n}\r\n"]}
|
package/dist/Classes/Error.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{s as CurrencyMismatchError,d as DuplicateSelectionAttributeError,c as DuplicateSizeError,t as InvalidArgumentError,r as InvalidCurrencyCodeError,u as InvalidImageSourceError,b as InvalidLineItemStateError,l as InvalidMinQuantityError,q as InvalidPriceAmountError,n as InvalidQuantityError,k as InvalidTaxCategoryError,j as InvalidTaxRuleError,m as InvalidTieredPriceError,a as LineItemNotFoundError,o as NoApplicableTierError,i as PricingNotFoundError,f as ProductInactiveError,e as ProductMismatchError,g as SelectionAttributeParseError,h as SizeMismatchError,p as TaxSlabNotFoundError}from'../chunk-
|
|
1
|
+
export{s as CurrencyMismatchError,d as DuplicateSelectionAttributeError,c as DuplicateSizeError,t as InvalidArgumentError,v as InvalidChargeError,r as InvalidCurrencyCodeError,u as InvalidImageSourceError,b as InvalidLineItemStateError,l as InvalidMinQuantityError,q as InvalidPriceAmountError,n as InvalidQuantityError,k as InvalidTaxCategoryError,j as InvalidTaxRuleError,m as InvalidTieredPriceError,a as LineItemNotFoundError,o as NoApplicableTierError,i as PricingNotFoundError,f as ProductInactiveError,e as ProductMismatchError,g as SelectionAttributeParseError,h as SizeMismatchError,p as TaxSlabNotFoundError}from'../chunk-XPKK6DFA.mjs';//# sourceMappingURL=Error.mjs.map
|
|
2
2
|
//# sourceMappingURL=Error.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Classes/Error.ts","../../src/Classes/ImageInfo.ts"],"names":["InvalidImageSourceError","message","ImageResolution","ImageInfoModel","data","resolutionKey","altText","order","label","url"],"mappings":"sEA4IO,IAAMA,EAAN,cAAsC,KAAM,CAC/C,WAAYC,CAAAA,CAAAA,CAAkB,sCAAuC,CACjE,KAAA,CAAM,uBAAuBA,CAAO,CAAA,CAAE,EACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,CAAA,KCjJYC,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,UAAY,WACZA,CAAAA,CAAAA,CAAA,MAAQ,OACRA,CAAAA,CAAAA,CAAA,OAAS,QACTA,CAAAA,CAAAA,CAAA,MAAQ,OACRA,CAAAA,CAAAA,CAAA,SAAW,UALDA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,IAsBSC,CAArB,CAAA,KAAoC,CACxB,OACA,CAAA,GAAA,CACA,MACA,KAMV,CAAA,WAAA,CAAYC,EAA0B,CAMpC,GALA,KAAK,OAAU,CAAA,CAAE,GAAGA,CAAK,CAAA,OAAQ,EACjC,IAAK,CAAA,GAAA,CAAMA,EAAK,GAChB,CAAA,IAAA,CAAK,MAAQA,CAAK,CAAA,KAAA,CAClB,KAAK,KAAQA,CAAAA,CAAAA,CAAK,MAEd,CAAC,IAAA,CAAK,QAAQ,QAChB,CAAA,MAAM,IAAIJ,CAAwB,CAAA,oEAAoE,CAE1G,CAMA,UAAA,EAAa,CACX,OAAO,CAAE,GAAG,IAAK,CAAA,OAAQ,CAC3B,CAOA,SAAA,CAAUK,EAAwC,CAChD,OAAO,KAAK,OAAQA,CAAAA,CAAa,CAAK,EAAA,IAAA,CAAK,QAAQ,QACrD,CAKA,QAA6B,CAC3B,OAAO,KAAK,GACd,CAKA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAKA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAMA,OAAOC,CAAmC,CAAA,CACxC,KAAK,GAAMA,CAAAA,EAEb,CAMA,QAASC,CAAAA,CAAAA,CAAiC,CACxC,IAAK,CAAA,KAAA,CAAQA,EACf,CAMA,QAAA,CAASC,EAAiC,CACxC,IAAA,CAAK,MAAQA,EACf,CAOA,UAAUH,CAAgCI,CAAAA,CAAAA,CAA+B,CACvE,GAAIA,CAAAA,GAAQ,OAAW,CAErB,GAAIJ,IAAkB,UACpB,CAAA,MAAM,IAAIL,CAAwB,CAAA,4CAA4C,EAEhF,OAAO,IAAA,CAAK,QAAQK,CAAa,EACnC,MACE,IAAK,CAAA,OAAA,CAAQA,CAAa,CAAII,CAAAA,EAElC,CAKA,UAA4B,EAAA,CAC1B,OAAO,CACL,OAAA,CAAS,KAAK,UAAW,EAAA,CACzB,IAAK,IAAK,CAAA,MAAA,GACV,KAAO,CAAA,IAAA,CAAK,UACZ,CAAA,KAAA,CAAO,KAAK,QAAS,EACvB,CACF,CACF","file":"ImageInfo.js","sourcesContent":["export class LineItemNotFoundError extends Error {\r\n constructor(lineItemId: string) {\r\n super(`Line item with ID '${lineItemId}' not found in the cart.`);\r\n this.name = 'LineItemNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidLineItemStateError extends Error {\r\n constructor(state: string) {\r\n super(`Invalid line item state: ${state}`);\r\n this.name = 'InvalidLineItemStateError';\r\n }\r\n}\r\n\r\nexport class DuplicateSizeError extends Error {\r\n constructor(size: string) {\r\n super(`Duplicate size found: ${size}`);\r\n this.name = 'DuplicateSizeError';\r\n }\r\n}\r\n\r\nexport class DuplicateSelectionAttributeError extends Error {\r\n constructor(attribute: string) {\r\n super(`Duplicate selection attribute found: ${attribute}`);\r\n this.name = 'DuplicateSelectionAttributeError';\r\n }\r\n}\r\n\r\nexport class ProductMismatchError extends Error {\r\n constructor(message: string = \"Product and selection attributes do not match.\") {\r\n super(`ProductMismatch: ${message}`);\r\n this.name = 'ProductMismatchError';\r\n }\r\n}\r\n\r\nexport class ProductInactiveError extends Error {\r\n constructor(message: string = \"Product is not active.\") {\r\n super(`ProductInactive: ${message}`);\r\n this.name = 'ProductInactiveError';\r\n }\r\n}\r\n\r\nexport class SelectionAttributeParseError extends Error {\r\n constructor(message: string = \"Failed to parse selection attributes key.\") {\r\n super(`SelectionAttributeParseError: ${message}`);\r\n this.name = 'SelectionAttributeParseError';\r\n }\r\n}\r\n\r\nexport class SizeMismatchError extends Error {\r\n constructor(message: string = \"Size does not match.\") {\r\n super(`SizeMismatch: ${message}`);\r\n this.name = 'SizeMismatchError';\r\n }\r\n}\r\n\r\nexport class PricingNotFoundError extends Error {\r\n constructor(message: string = \"Pricing details not available for the product\") {\r\n super(`NotFound: ${message}`);\r\n this.name = 'PricingNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxRuleError extends Error {\r\n constructor(message: string = \"Tax rule category mismatch.\") {\r\n super(`InvalidTaxRule: ${message}`);\r\n this.name = 'InvalidTaxRuleError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxCategoryError extends Error {\r\n constructor(message: string = \"Tax category is not valid.\") {\r\n super(`InvalidTaxCategory: ${message}`);\r\n this.name = 'InvalidTaxCategoryError';\r\n }\r\n}\r\n\r\nexport class InvalidMinQuantityError extends Error {\r\n constructor(message: string = \"Minimum quantity must be greater than zero.\") {\r\n super(`InvalidMinQuantity: ${message}`);\r\n this.name = 'InvalidMinQuantityError';\r\n }\r\n}\r\n\r\nexport class InvalidTieredPriceError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidTieredPrice: ${message}`);\r\n this.name = 'InvalidTieredPriceError';\r\n }\r\n}\r\n\r\nexport class InvalidQuantityError extends Error {\r\n constructor(message: string = \"Quantity must be greater than zero.\") {\r\n super(`InvalidQuantity: ${message}`);\r\n this.name = 'InvalidQuantityError';\r\n }\r\n}\r\n\r\nexport class NoApplicableTierError extends Error {\r\n constructor(quantity: number) {\r\n super(`NoApplicableTier: Quantity ${quantity} does not meet the minimum purchase requirement.`);\r\n this.name = 'NoApplicableTierError';\r\n }\r\n}\r\n\r\nexport class TaxSlabNotFoundError extends Error {\r\n constructor(message: string = \"No applicable tax slab or multiple slabs found for the given unit price.\") {\r\n super(`TaxSlabNotFound: ${message}`);\r\n this.name = 'TaxSlabNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidPriceAmountError extends Error {\r\n constructor(message: string = \"Amount cannot be negative.\") {\r\n super(`InvalidAmount: ${message}`);\r\n this.name = 'InvalidPriceAmountError';\r\n }\r\n}\r\n\r\nexport class InvalidCurrencyCodeError extends Error {\r\n constructor(message: string = \"Currency code is required.\") {\r\n super(`InvalidCurrency: ${message}`);\r\n this.name = 'InvalidCurrencyCodeError';\r\n }\r\n}\r\n\r\nexport class CurrencyMismatchError extends Error {\r\n constructor(message: string = \"Cannot perform operation on prices with different currencies.\") {\r\n super(`CurrencyMismatch: ${message}`);\r\n this.name = 'CurrencyMismatchError';\r\n }\r\n}\r\n\r\nexport class InvalidArgumentError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidArgument: ${message}`);\r\n this.name = 'InvalidArgumentError';\r\n }\r\n}\r\n\r\nexport class InvalidImageSourceError extends Error {\r\n constructor(message: string = \"Invalid image source configuration.\") {\r\n super(`InvalidImageSource: ${message}`);\r\n this.name = 'InvalidImageSourceError';\r\n }\r\n}","export enum ImageResolution {\r\n THUMBNAIL = 'thumbnail',\r\n SMALL = 'small',\r\n MEDIUM = 'medium',\r\n LARGE = 'large',\r\n ORIGINAL = 'original',\r\n}\r\n\r\nimport { InvalidImageSourceError } from \"./Error\";\r\n\r\nexport type ImageInfoAttribute = {\r\n sources: { [key in ImageResolution]?: string } & { original: string };\r\n alt?: string;\r\n order?: number;\r\n label?: string;\r\n};\r\n\r\nexport type ImageInfoData = ImageInfoAttribute;\r\n\r\n/**\r\n * Represents and manages structured image data, including multiple resolutions.\r\n */\r\nexport default class ImageInfoModel {\r\n protected sources: { [key in ImageResolution]?: string } & { original: string };\r\n protected alt?: string;\r\n protected order?: number;\r\n protected label?: string;\r\n\r\n /**\r\n * Creates an instance of ImageInfoModel.\r\n * @param data - The initial image data.\r\n */\r\n constructor(data: ImageInfoAttribute) {\r\n this.sources = { ...data.sources };\r\n this.alt = data.alt;\r\n this.order = data.order;\r\n this.label = data.label;\r\n\r\n if (!this.sources.original) {\r\n throw new InvalidImageSourceError(\"ImageInfoModel cannot be created without an 'original' source URL.\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sources object containing URLs for different resolutions.\r\n * Returns a copy to prevent external modification.\r\n */\r\n getSources() {\r\n return { ...this.sources };\r\n }\r\n\r\n /**\r\n * Gets the URL for a specific resolution key.\r\n * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').\r\n * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.\r\n */\r\n getSource(resolutionKey: ImageResolution): string {\r\n return this.sources[resolutionKey] || this.sources.original;\r\n }\r\n\r\n /**\r\n * Gets the alternative text for the image.\r\n */\r\n getAlt(): string | undefined {\r\n return this.alt;\r\n }\r\n\r\n /**\r\n * Gets the display order number for the image.\r\n */\r\n getOrder(): number | undefined {\r\n return this.order;\r\n }\r\n\r\n /**\r\n * Gets the display label or caption for the image.\r\n */\r\n getLabel(): string | undefined {\r\n return this.label;\r\n }\r\n\r\n /**\r\n * Sets the alternative text for the image.\r\n * @param altText - The new alt text.\r\n */\r\n setAlt(altText: string | undefined): void {\r\n this.alt = altText;\r\n // Potentially add logic here to trigger updates if needed\r\n }\r\n\r\n /**\r\n * Sets the display order for the image.\r\n * @param order - The new order number.\r\n */\r\n setOrder(order: number | undefined): void {\r\n this.order = order;\r\n }\r\n\r\n /**\r\n * Sets the display label for the image.\r\n * @param label - The new label text.\r\n */\r\n setLabel(label: string | undefined): void {\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Updates or adds a URL for a specific resolution.\r\n * @param resolutionKey - The key of the resolution to update/add.\r\n * @param url - The URL for the resolution. Set to undefined to remove.\r\n */\r\n setSource(resolutionKey: ImageResolution, url: string | undefined): void {\r\n if (url === undefined) {\r\n // Prevent deleting the 'original' key if it's required\r\n if (resolutionKey === 'original') {\r\n throw new InvalidImageSourceError(\"Cannot remove the 'original' image source.\");\r\n }\r\n delete this.sources[resolutionKey];\r\n } else {\r\n this.sources[resolutionKey] = url;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a plain JavaScript object representation of the image info.\r\n */\r\n getDetails(): ImageInfoData {\r\n return {\r\n sources: this.getSources(),\r\n alt: this.getAlt(),\r\n order: this.getOrder(),\r\n label: this.getLabel(),\r\n };\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Classes/Error.ts","../../src/Classes/ImageInfo.ts"],"names":["InvalidImageSourceError","message","ImageResolution","ImageInfoModel","data","resolutionKey","altText","order","label","url"],"mappings":"sEA4IO,IAAMA,EAAN,cAAsC,KAAM,CAC/C,WAAYC,CAAAA,CAAAA,CAAkB,sCAAuC,CACjE,KAAA,CAAM,uBAAuBA,CAAO,CAAA,CAAE,EACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,CAAA,KCjJYC,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,UAAY,WACZA,CAAAA,CAAAA,CAAA,MAAQ,OACRA,CAAAA,CAAAA,CAAA,OAAS,QACTA,CAAAA,CAAAA,CAAA,MAAQ,OACRA,CAAAA,CAAAA,CAAA,SAAW,UALDA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,IAsBSC,CAArB,CAAA,KAAoC,CACxB,OACA,CAAA,GAAA,CACA,MACA,KAMV,CAAA,WAAA,CAAYC,EAA0B,CAMpC,GALA,KAAK,OAAU,CAAA,CAAE,GAAGA,CAAK,CAAA,OAAQ,EACjC,IAAK,CAAA,GAAA,CAAMA,EAAK,GAChB,CAAA,IAAA,CAAK,MAAQA,CAAK,CAAA,KAAA,CAClB,KAAK,KAAQA,CAAAA,CAAAA,CAAK,MAEd,CAAC,IAAA,CAAK,QAAQ,QAChB,CAAA,MAAM,IAAIJ,CAAwB,CAAA,oEAAoE,CAE1G,CAMA,UAAA,EAAa,CACX,OAAO,CAAE,GAAG,IAAK,CAAA,OAAQ,CAC3B,CAOA,SAAA,CAAUK,EAAwC,CAChD,OAAO,KAAK,OAAQA,CAAAA,CAAa,CAAK,EAAA,IAAA,CAAK,QAAQ,QACrD,CAKA,QAA6B,CAC3B,OAAO,KAAK,GACd,CAKA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAKA,UAA+B,CAC7B,OAAO,KAAK,KACd,CAMA,OAAOC,CAAmC,CAAA,CACxC,KAAK,GAAMA,CAAAA,EAEb,CAMA,QAASC,CAAAA,CAAAA,CAAiC,CACxC,IAAK,CAAA,KAAA,CAAQA,EACf,CAMA,QAAA,CAASC,EAAiC,CACxC,IAAA,CAAK,MAAQA,EACf,CAOA,UAAUH,CAAgCI,CAAAA,CAAAA,CAA+B,CACvE,GAAIA,CAAAA,GAAQ,OAAW,CAErB,GAAIJ,IAAkB,UACpB,CAAA,MAAM,IAAIL,CAAwB,CAAA,4CAA4C,EAEhF,OAAO,IAAA,CAAK,QAAQK,CAAa,EACnC,MACE,IAAK,CAAA,OAAA,CAAQA,CAAa,CAAII,CAAAA,EAElC,CAKA,UAA4B,EAAA,CAC1B,OAAO,CACL,OAAA,CAAS,KAAK,UAAW,EAAA,CACzB,IAAK,IAAK,CAAA,MAAA,GACV,KAAO,CAAA,IAAA,CAAK,UACZ,CAAA,KAAA,CAAO,KAAK,QAAS,EACvB,CACF,CACF","file":"ImageInfo.js","sourcesContent":["export class LineItemNotFoundError extends Error {\r\n constructor(lineItemId: string) {\r\n super(`Line item with ID '${lineItemId}' not found in the cart.`);\r\n this.name = 'LineItemNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidLineItemStateError extends Error {\r\n constructor(state: string) {\r\n super(`Invalid line item state: ${state}`);\r\n this.name = 'InvalidLineItemStateError';\r\n }\r\n}\r\n\r\nexport class DuplicateSizeError extends Error {\r\n constructor(size: string) {\r\n super(`Duplicate size found: ${size}`);\r\n this.name = 'DuplicateSizeError';\r\n }\r\n}\r\n\r\nexport class DuplicateSelectionAttributeError extends Error {\r\n constructor(attribute: string) {\r\n super(`Duplicate selection attribute found: ${attribute}`);\r\n this.name = 'DuplicateSelectionAttributeError';\r\n }\r\n}\r\n\r\nexport class ProductMismatchError extends Error {\r\n constructor(message: string = \"Product and selection attributes do not match.\") {\r\n super(`ProductMismatch: ${message}`);\r\n this.name = 'ProductMismatchError';\r\n }\r\n}\r\n\r\nexport class ProductInactiveError extends Error {\r\n constructor(message: string = \"Product is not active.\") {\r\n super(`ProductInactive: ${message}`);\r\n this.name = 'ProductInactiveError';\r\n }\r\n}\r\n\r\nexport class SelectionAttributeParseError extends Error {\r\n constructor(message: string = \"Failed to parse selection attributes key.\") {\r\n super(`SelectionAttributeParseError: ${message}`);\r\n this.name = 'SelectionAttributeParseError';\r\n }\r\n}\r\n\r\nexport class SizeMismatchError extends Error {\r\n constructor(message: string = \"Size does not match.\") {\r\n super(`SizeMismatch: ${message}`);\r\n this.name = 'SizeMismatchError';\r\n }\r\n}\r\n\r\nexport class PricingNotFoundError extends Error {\r\n constructor(message: string = \"Pricing details not available for the product\") {\r\n super(`NotFound: ${message}`);\r\n this.name = 'PricingNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxRuleError extends Error {\r\n constructor(message: string = \"Tax rule category mismatch.\") {\r\n super(`InvalidTaxRule: ${message}`);\r\n this.name = 'InvalidTaxRuleError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxCategoryError extends Error {\r\n constructor(message: string = \"Tax category is not valid.\") {\r\n super(`InvalidTaxCategory: ${message}`);\r\n this.name = 'InvalidTaxCategoryError';\r\n }\r\n}\r\n\r\nexport class InvalidMinQuantityError extends Error {\r\n constructor(message: string = \"Minimum quantity must be greater than zero.\") {\r\n super(`InvalidMinQuantity: ${message}`);\r\n this.name = 'InvalidMinQuantityError';\r\n }\r\n}\r\n\r\nexport class InvalidTieredPriceError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidTieredPrice: ${message}`);\r\n this.name = 'InvalidTieredPriceError';\r\n }\r\n}\r\n\r\nexport class InvalidQuantityError extends Error {\r\n constructor(message: string = \"Quantity must be greater than zero.\") {\r\n super(`InvalidQuantity: ${message}`);\r\n this.name = 'InvalidQuantityError';\r\n }\r\n}\r\n\r\nexport class NoApplicableTierError extends Error {\r\n constructor(quantity: number) {\r\n super(`NoApplicableTier: Quantity ${quantity} does not meet the minimum purchase requirement.`);\r\n this.name = 'NoApplicableTierError';\r\n }\r\n}\r\n\r\nexport class TaxSlabNotFoundError extends Error {\r\n constructor(message: string = \"No applicable tax slab or multiple slabs found for the given unit price.\") {\r\n super(`TaxSlabNotFound: ${message}`);\r\n this.name = 'TaxSlabNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidPriceAmountError extends Error {\r\n constructor(message: string = \"Amount cannot be negative.\") {\r\n super(`InvalidAmount: ${message}`);\r\n this.name = 'InvalidPriceAmountError';\r\n }\r\n}\r\n\r\nexport class InvalidCurrencyCodeError extends Error {\r\n constructor(message: string = \"Currency code is required.\") {\r\n super(`InvalidCurrency: ${message}`);\r\n this.name = 'InvalidCurrencyCodeError';\r\n }\r\n}\r\n\r\nexport class CurrencyMismatchError extends Error {\r\n constructor(message: string = \"Cannot perform operation on prices with different currencies.\") {\r\n super(`CurrencyMismatch: ${message}`);\r\n this.name = 'CurrencyMismatchError';\r\n }\r\n}\r\n\r\nexport class InvalidArgumentError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidArgument: ${message}`);\r\n this.name = 'InvalidArgumentError';\r\n }\r\n}\r\n\r\nexport class InvalidImageSourceError extends Error {\r\n constructor(message: string = \"Invalid image source configuration.\") {\r\n super(`InvalidImageSource: ${message}`);\r\n this.name = 'InvalidImageSourceError';\r\n }\r\n}\r\n\r\nexport class InvalidChargeError extends Error {\r\n constructor(message: string = \"Invalid charge data.\") {\r\n super(`InvalidCharge: ${message}`);\r\n this.name = 'InvalidChargeError';\r\n }\r\n}\r\n","export enum ImageResolution {\r\n THUMBNAIL = 'thumbnail',\r\n SMALL = 'small',\r\n MEDIUM = 'medium',\r\n LARGE = 'large',\r\n ORIGINAL = 'original',\r\n}\r\n\r\nimport { InvalidImageSourceError } from \"./Error\";\r\n\r\nexport type ImageInfoAttribute = {\r\n sources: { [key in ImageResolution]?: string } & { original: string };\r\n alt?: string;\r\n order?: number;\r\n label?: string;\r\n};\r\n\r\nexport type ImageInfoData = ImageInfoAttribute;\r\n\r\n/**\r\n * Represents and manages structured image data, including multiple resolutions.\r\n */\r\nexport default class ImageInfoModel {\r\n protected sources: { [key in ImageResolution]?: string } & { original: string };\r\n protected alt?: string;\r\n protected order?: number;\r\n protected label?: string;\r\n\r\n /**\r\n * Creates an instance of ImageInfoModel.\r\n * @param data - The initial image data.\r\n */\r\n constructor(data: ImageInfoAttribute) {\r\n this.sources = { ...data.sources };\r\n this.alt = data.alt;\r\n this.order = data.order;\r\n this.label = data.label;\r\n\r\n if (!this.sources.original) {\r\n throw new InvalidImageSourceError(\"ImageInfoModel cannot be created without an 'original' source URL.\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sources object containing URLs for different resolutions.\r\n * Returns a copy to prevent external modification.\r\n */\r\n getSources() {\r\n return { ...this.sources };\r\n }\r\n\r\n /**\r\n * Gets the URL for a specific resolution key.\r\n * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').\r\n * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.\r\n */\r\n getSource(resolutionKey: ImageResolution): string {\r\n return this.sources[resolutionKey] || this.sources.original;\r\n }\r\n\r\n /**\r\n * Gets the alternative text for the image.\r\n */\r\n getAlt(): string | undefined {\r\n return this.alt;\r\n }\r\n\r\n /**\r\n * Gets the display order number for the image.\r\n */\r\n getOrder(): number | undefined {\r\n return this.order;\r\n }\r\n\r\n /**\r\n * Gets the display label or caption for the image.\r\n */\r\n getLabel(): string | undefined {\r\n return this.label;\r\n }\r\n\r\n /**\r\n * Sets the alternative text for the image.\r\n * @param altText - The new alt text.\r\n */\r\n setAlt(altText: string | undefined): void {\r\n this.alt = altText;\r\n // Potentially add logic here to trigger updates if needed\r\n }\r\n\r\n /**\r\n * Sets the display order for the image.\r\n * @param order - The new order number.\r\n */\r\n setOrder(order: number | undefined): void {\r\n this.order = order;\r\n }\r\n\r\n /**\r\n * Sets the display label for the image.\r\n * @param label - The new label text.\r\n */\r\n setLabel(label: string | undefined): void {\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Updates or adds a URL for a specific resolution.\r\n * @param resolutionKey - The key of the resolution to update/add.\r\n * @param url - The URL for the resolution. Set to undefined to remove.\r\n */\r\n setSource(resolutionKey: ImageResolution, url: string | undefined): void {\r\n if (url === undefined) {\r\n // Prevent deleting the 'original' key if it's required\r\n if (resolutionKey === 'original') {\r\n throw new InvalidImageSourceError(\"Cannot remove the 'original' image source.\");\r\n }\r\n delete this.sources[resolutionKey];\r\n } else {\r\n this.sources[resolutionKey] = url;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a plain JavaScript object representation of the image info.\r\n */\r\n getDetails(): ImageInfoData {\r\n return {\r\n sources: this.getSources(),\r\n alt: this.getAlt(),\r\n order: this.getOrder(),\r\n label: this.getLabel(),\r\n };\r\n }\r\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as ImageResolution,b as default}from'../chunk-
|
|
1
|
+
export{a as ImageResolution,b as default}from'../chunk-RSTZJZSQ.mjs';import'../chunk-XPKK6DFA.mjs';//# sourceMappingURL=ImageInfo.mjs.map
|
|
2
2
|
//# sourceMappingURL=ImageInfo.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var H=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);var w=new Uint8Array(256),D=w.length;function k(){return D>w.length-16&&(H__default.default.randomFillSync(w),D=0),w.slice(D,D+=16)}var K=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Z(r){return typeof r=="string"&&K.test(r)}var V=Z;var a=[];for(let r=0;r<256;++r)a.push((r+256).toString(16).slice(1));function M(r,e=0){return a[r[e+0]]+a[r[e+1]]+a[r[e+2]]+a[r[e+3]]+"-"+a[r[e+4]]+a[r[e+5]]+"-"+a[r[e+6]]+a[r[e+7]]+"-"+a[r[e+8]]+a[r[e+9]]+"-"+a[r[e+10]]+a[r[e+11]]+a[r[e+12]]+a[r[e+13]]+a[r[e+14]]+a[r[e+15]]}function X(r){if(!V(r))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var Q=X;function W(r){r=unescape(encodeURIComponent(r));let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var J="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function $(r,e,t){function i(n,s,l,f){var u;if(typeof n=="string"&&(n=W(n)),typeof s=="string"&&(s=Q(s)),((u=s)===null||u===void 0?void 0:u.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let d=new Uint8Array(16+n.length);if(d.set(s),d.set(n,s.length),d=t(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,l){f=f||0;for(let P=0;P<16;++P)l[f+P]=d[P];return l}return M(d)}try{i.name=r;}catch{}return i.DNS=J,i.URL=_,i}var z={randomUUID:H__default.default.randomUUID};function te(r,e,t){if(z.randomUUID&&!e&&!r)return z.randomUUID();r=r||{};let i=r.random||(r.rng||k)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return M(i)}var B=te;function ie(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),H__default.default.createHash("sha1").update(r).digest()}var G=ie;var ne=$("v5",80,G),F=ne;var O=class{customFields;constructor(e,t=new Date){this.customFields={...e.customFields};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}},y=class extends O{version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){super(e),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,i,n){this.modifiedBy={id:e,authType:t,requestId:i,lambdaName:n};}};var b={"en-IN":"en","kn-IN":"kn"};var j={INR:"\u20B9"},Y={INR:"en-IN"};var T=class extends Error{constructor(e){super(`Duplicate selection attribute found: ${e}`),this.name="DuplicateSelectionAttributeError";}};var p=class extends Error{constructor(e="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${e}`),this.name="SelectionAttributeParseError";}};var E=class extends Error{constructor(e="Tax category is not valid."){super(`InvalidTaxCategory: ${e}`),this.name="InvalidTaxCategoryError";}},v=class extends Error{constructor(e="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${e}`),this.name="InvalidMinQuantityError";}},L=class extends Error{constructor(e){super(`InvalidTieredPrice: ${e}`),this.name="InvalidTieredPriceError";}},R=class extends Error{constructor(e="Quantity must be greater than zero."){super(`InvalidQuantity: ${e}`),this.name="InvalidQuantityError";}},N=class extends Error{constructor(e){super(`NoApplicableTier: Quantity ${e} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}};var I=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},A=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},m=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},g=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}},S=class extends Error{constructor(e="Invalid image source configuration."){super(`InvalidImageSource: ${e}`),this.name="InvalidImageSourceError";}};var C=class{sources;alt;order;label;constructor(e){if(this.sources={...e.sources},this.alt=e.alt,this.order=e.order,this.label=e.label,!this.sources.original)throw new S("ImageInfoModel cannot be created without an 'original' source URL.")}getSources(){return {...this.sources}}getSource(e){return this.sources[e]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(e){this.alt=e;}setOrder(e){this.order=e;}setLabel(e){this.label=e;}setSource(e,t){if(t===void 0){if(e==="original")throw new S("Cannot remove the 'original' image source.");delete this.sources[e];}else this.sources[e]=t;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var x=class r{#e;amount;currency;constructor(e){if(this.#e="PriceModel",e.amount<0)throw new I("Amount cannot be negative.");if(!e.currency)throw new A("Currency code is required.");this.amount=e.amount,this.currency=e.currency;}get kind(){return this.#e}static isPriceModel(e){return typeof e=="object"&&e!==null&&e.kind==="PriceModel"}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}compareTo(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot add prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return new r({amount:this.amount+e.getAmount(),currency:this.currency})}subtract(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot subtract prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return new r({amount:this.amount-e.getAmount(),currency:this.currency})}multiply(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot multiply prices in different currencies.");return new r({amount:this.amount*e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new r({amount:this.amount*e,currency:this.currency});throw new g("Must be a non-negative number.")}divide(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot divide prices in different currencies.");return new r({amount:this.amount/e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>0)return new r({amount:this.amount/e,currency:this.currency});throw new g("Must be a positive number.")}min(...e){if(e.length===0)throw new g("Must provide at least one PriceModel.");return e.reduce((t,i)=>{if(r.isPriceModel(i)){if(t.getCurrency()!==i.getCurrency())throw new m("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return t.compareTo(i)<0?t:i},this)}max(...e){if(e.length===0)throw new g("Must provide at least one PriceModel.");return e.reduce((t,i)=>{if(r.isPriceModel(i)){if(t.getCurrency()!==i.getCurrency())throw new m("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return t.compareTo(i)>0?t:i},this)}zero(){return new r({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new r({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return r.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return r.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(e,t,i={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let n=Y[t];if(!t||!n)throw new A("Invalid currency code for formatting.");let s=e,l=i.displayAsInteger?0:r.getDecimalPlaces(t),f={style:i.style??"currency",currency:t,signDisplay:"never",currencyDisplay:i.currencyDisplay,minimumFractionDigits:l,maximumFractionDigits:l};i.displayAsInteger&&(s=Math.ceil(s));try{return new Intl.NumberFormat(n,f).format(s)}catch(u){return console.error(`Error formatting price for currency "${t}" and locale "${n}":`,u),`${j[t]??t} ${r.addThousandSeparators(s.toFixed(l))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let t=e.split("."),i=t[0],n=t.length>1?"."+t[1]:"";return i.replace(/\B(?=(\d{3})+(?!\d))/g,",")+n}static getRoundedAmount(e,t){if(e<0)throw new I("Amount cannot be negative for rounding.");if(t===void 0)throw new A("Invalid currency code for rounding.");let i=r.getDecimalPlaces(t),n=Math.pow(10,i);return Math.round(e*n)/n}};var U=class{baseUnitPrice;taxCategory;tiers;constructor(e){let t=new x(e.baseUnitPrice);if(!e.taxCategory)throw new E;let i=(e.tiers??[]).map(u=>({minQuantity:u.minQuantity,unitPrice:new x(u.unitPrice)})).sort((u,d)=>u.minQuantity-d.minQuantity);if(i.some(u=>u.minQuantity<=0))throw new v;let s=i.some(u=>u.unitPrice.getCurrency()!==t.getCurrency()),l=i.some((u,d)=>d>0&&u.unitPrice.compareTo(i[d-1].unitPrice)>0),f=i[0]?.unitPrice.compareTo(t)>0;if(s||l||f)throw new L("Tiers must share the same currency and must not increase in unit price.");this.baseUnitPrice=t,this.taxCategory=e.taxCategory,this.tiers=i;}getBaseUnitPrice(){return this.baseUnitPrice}getTaxCategory(){return this.taxCategory}getTiers(){return this.tiers}getDetails(){return {baseUnitPrice:this.baseUnitPrice.getDetails(),taxCategory:this.taxCategory,tiers:this.tiers.map(e=>({minQuantity:e.minQuantity,unitPrice:e.unitPrice.getDetails()}))}}getApplicableTier(e){if(e<=0)throw new R;for(let t=this.tiers.length-1;t>=0;t--)if(e>=this.tiers[t].minQuantity)return this.tiers[t];throw new N(e)}getMinQuantity(){return this.tiers[0]?.minQuantity??1}getMaxDiscountPercent(){if(!this.tiers.length)return 0;let e=this.tiers[this.tiers.length-1].unitPrice.getAmount(),t=this.baseUnitPrice.getAmount();return (t-e)/t*100}};var h=class r extends y{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(e){if(typeof e!="object")throw new p("Selection attributes must be an object");return Object.keys(e).filter(i=>e[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>e[i].name?`${i}:c+${e[i].name}`:`${i}:${e[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(e){try{let t={},i=e.split("|");for(let n of i){let[s,l]=n.split(":");l.startsWith("c+")?t[s]={name:l.slice(2)}:t[s]=l;}return t}catch(t){throw new p(t?.message)}}constructor(e,t=new Date){super(e,t),this.id=e.id,this.key=e.key,this.name={...e.name},this.description={...e.description},this.slug={...e.slug},this.brand=e.brand,this.pricing=Object.keys(e.pricing).reduce((n,s)=>(e.pricing[s]&&(n[s]=new U(e.pricing[s])),n),{}),this.targetGender=e.targetGender,this.attributes=c.deepClone(e.attributes),this.specifications=c.deepClone(e.specifications),this.categories=c.deepClone(e.categories);let i=new Set;this.variants=(e.variants||[]).map(n=>{if(!n.selectionAttributes||typeof n.selectionAttributes!="object")throw new p("Selection attributes are required");this.checkSelectionAttributes(n.selectionAttributes);let s=r.generateSelectionAttributesKey(n.selectionAttributes);if(i.has(s))throw new T(s);return i.add(s),{sku:n.sku,selectionAttributes:n.selectionAttributes,images:{primary:new C(n.images.primary),gallery:(n.images.gallery||[]).map(l=>new C(l))}}}),this.isActive=e.isActive,this.searchTags=e.searchTags?c.deepClone(e.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(e){return e?this.name[e]??this.name[b[e]]??this.name.en:c.deepClone(this.name)}getDescription(e){return e?this.description[e]??this.description[b[e]]??this.description.en:c.deepClone(this.description)}getSlug(e){return e?this.slug[e]??this.slug[b[e]]??this.slug.en:c.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:this.pricing}getAttributes(){return c.deepClone(this.attributes)}getVariants(){return this.variants.map(e=>({sku:e.sku,selectionAttributes:e.selectionAttributes,images:{primary:e.images.primary,gallery:e.images.gallery}}))}getImagesBySelectionAttributes(e){let t=r.generateSelectionAttributesKey(e),i=this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t);return i?i.images:null}getImages(e,t){switch(t){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return c.deepClone(this.categories)}getSpecifications(e){return e?c.deepClone(this.specifications[e]??this.specifications[b[e]]??this.specifications.en):c.deepClone(this.specifications)}getSearchTags(e){return e?c.deepClone(this.searchTags[e]??this.searchTags[b[e]]??this.searchTags.en):c.deepClone(this.searchTags)}getDetails(){let e=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((t,i)=>(this.pricing[i]&&(t[i]=this.pricing[i]?.getDetails()),t),{}),attributes:this.getAttributes(),variants:this.variants.map(t=>({sku:t.sku,selectionAttributes:c.deepClone(t.selectionAttributes),images:{primary:t.images.primary.getDetails(),gallery:t.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}checkSelectionAttributes(e){if(!e||typeof e!="object")throw new p("Selection attributes are required");Object.keys(this.attributes).forEach(t=>{if(t.toLowerCase()==="size")return;let i=this.attributes[t],n=e[t];if(n===void 0)throw new p(`Selection attribute '${t}' is missing`);if(typeof i=="string"){if(typeof n!="string"||i!==n)throw new p(`Selection attribute '${t}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof n!="string"||!i.includes(n))throw new p(`Selection attribute '${t}' is invalid`)}else if(typeof n!="object"||!("name"in n)||i.findIndex(s=>s.name===n.name)<0)throw new p(`Selection attribute '${t}' is invalid`)}});}validateSelectionAttribute(e){let t=r.generateSelectionAttributesKey(e);return this.variants.some(i=>r.generateSelectionAttributesKey(i.selectionAttributes)===t)}validateSize(e){return this.attributes.size.includes(e)}};var se={isUUID:r=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(r),isEmail:r=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r),isURL:r=>/^(http|https):\/\/[^ "]+$/.test(r),generateUUID:(r,e)=>e&&r?F(r,e):B(),generateSearchId:(r,e)=>`${r}#${h.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:r=>{let[e,t]=r.split("#");return {key:e,selectionAttributes:h.parseSelectionAttributesKey(t)}},deepClone(r){return structuredClone(r)}},c=se;var q=class extends y{productKey;stocks;constructor(e,t=new Date){super(e,t),this.productKey=e.productKey,this.stocks=e.stocks.map(i=>({selectionAttributes:c.deepClone(i.selectionAttributes),size:i.size,available:i.available,country:i.country}));}getProductKey(){return this.productKey}getStockData(e,t,i){let n=e?h.generateSelectionAttributesKey(e):void 0;return this.stocks.filter(s=>!(n&&h.generateSelectionAttributesKey(s.selectionAttributes)!==n||t&&s.size!==t||i&&s.country!==i))}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),stocks:this.getStockData()}}};exports.InventoryModel=q;//# sourceMappingURL=Inventory.js.map
|
|
1
|
+
'use strict';var q=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var q__default=/*#__PURE__*/_interopDefault(q);var w=new Uint8Array(256),D=w.length;function k(){return D>w.length-16&&(q__default.default.randomFillSync(w),D=0),w.slice(D,D+=16)}var K=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Z(r){return typeof r=="string"&&K.test(r)}var V=Z;var a=[];for(let r=0;r<256;++r)a.push((r+256).toString(16).slice(1));function M(r,e=0){return a[r[e+0]]+a[r[e+1]]+a[r[e+2]]+a[r[e+3]]+"-"+a[r[e+4]]+a[r[e+5]]+"-"+a[r[e+6]]+a[r[e+7]]+"-"+a[r[e+8]]+a[r[e+9]]+"-"+a[r[e+10]]+a[r[e+11]]+a[r[e+12]]+a[r[e+13]]+a[r[e+14]]+a[r[e+15]]}function J(r){if(!V(r))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var G=J;function X(r){r=unescape(encodeURIComponent(r));let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var W="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function $(r,e,t){function i(n,s,l,f){var u;if(typeof n=="string"&&(n=X(n)),typeof s=="string"&&(s=G(s)),((u=s)===null||u===void 0?void 0:u.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let d=new Uint8Array(16+n.length);if(d.set(s),d.set(n,s.length),d=t(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,l){f=f||0;for(let P=0;P<16;++P)l[f+P]=d[P];return l}return M(d)}try{i.name=r;}catch{}return i.DNS=W,i.URL=_,i}var z={randomUUID:q__default.default.randomUUID};function te(r,e,t){if(z.randomUUID&&!e&&!r)return z.randomUUID();r=r||{};let i=r.random||(r.rng||k)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return M(i)}var B=te;function ie(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),q__default.default.createHash("sha1").update(r).digest()}var Q=ie;var ne=$("v5",80,Q),F=ne;var O=class{customFields;constructor(e,t=new Date){this.customFields={...e.customFields};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}},y=class extends O{version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){super(e),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,i,n){this.modifiedBy={id:e,authType:t,requestId:i,lambdaName:n};}};var b={"en-IN":"en","kn-IN":"kn"};var j={INR:"\u20B9"},H={INR:"en-IN"};var T=class extends Error{constructor(e){super(`Duplicate selection attribute found: ${e}`),this.name="DuplicateSelectionAttributeError";}};var p=class extends Error{constructor(e="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${e}`),this.name="SelectionAttributeParseError";}};var v=class extends Error{constructor(e="Tax category is not valid."){super(`InvalidTaxCategory: ${e}`),this.name="InvalidTaxCategoryError";}},E=class extends Error{constructor(e="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${e}`),this.name="InvalidMinQuantityError";}},L=class extends Error{constructor(e){super(`InvalidTieredPrice: ${e}`),this.name="InvalidTieredPriceError";}},N=class extends Error{constructor(e="Quantity must be greater than zero."){super(`InvalidQuantity: ${e}`),this.name="InvalidQuantityError";}},R=class extends Error{constructor(e){super(`NoApplicableTier: Quantity ${e} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}};var C=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},A=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},m=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},g=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}},S=class extends Error{constructor(e="Invalid image source configuration."){super(`InvalidImageSource: ${e}`),this.name="InvalidImageSourceError";}};var I=class{sources;alt;order;label;constructor(e){if(this.sources={...e.sources},this.alt=e.alt,this.order=e.order,this.label=e.label,!this.sources.original)throw new S("ImageInfoModel cannot be created without an 'original' source URL.")}getSources(){return {...this.sources}}getSource(e){return this.sources[e]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(e){this.alt=e;}setOrder(e){this.order=e;}setLabel(e){this.label=e;}setSource(e,t){if(t===void 0){if(e==="original")throw new S("Cannot remove the 'original' image source.");delete this.sources[e];}else this.sources[e]=t;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var x=class r{#e;amount;currency;constructor(e){if(this.#e="PriceModel",e.amount<0)throw new C("Amount cannot be negative.");if(!e.currency)throw new A("Currency code is required.");this.amount=e.amount,this.currency=e.currency;}get kind(){return this.#e}static isPriceModel(e){return typeof e=="object"&&e!==null&&e.kind==="PriceModel"}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}compareTo(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot add prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return new r({amount:this.amount+e.getAmount(),currency:this.currency})}subtract(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot subtract prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return new r({amount:this.amount-e.getAmount(),currency:this.currency})}multiply(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot multiply prices in different currencies.");return new r({amount:this.amount*e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new r({amount:this.amount*e,currency:this.currency});throw new g("Must be a non-negative number.")}divide(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new m("Cannot divide prices in different currencies.");return new r({amount:this.amount/e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>0)return new r({amount:this.amount/e,currency:this.currency});throw new g("Must be a positive number.")}min(...e){if(e.length===0)throw new g("Must provide at least one PriceModel.");return e.reduce((t,i)=>{if(r.isPriceModel(i)){if(t.getCurrency()!==i.getCurrency())throw new m("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return t.compareTo(i)<0?t:i},this)}max(...e){if(e.length===0)throw new g("Must provide at least one PriceModel.");return e.reduce((t,i)=>{if(r.isPriceModel(i)){if(t.getCurrency()!==i.getCurrency())throw new m("Cannot compare prices in different currencies.")}else throw new g("Must be a PriceModel instance.");return t.compareTo(i)>0?t:i},this)}zero(){return new r({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new r({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return r.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return r.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(e,t,i={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let n=H[t];if(!t||!n)throw new A("Invalid currency code for formatting.");let s=e,l=i.displayAsInteger?0:r.getDecimalPlaces(t),f={style:i.style??"currency",currency:t,signDisplay:"never",currencyDisplay:i.currencyDisplay,minimumFractionDigits:l,maximumFractionDigits:l};i.displayAsInteger&&(s=Math.ceil(s));try{return new Intl.NumberFormat(n,f).format(s)}catch(u){return console.error(`Error formatting price for currency "${t}" and locale "${n}":`,u),`${j[t]??t} ${r.addThousandSeparators(s.toFixed(l))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let t=e.split("."),i=t[0],n=t.length>1?"."+t[1]:"";return i.replace(/\B(?=(\d{3})+(?!\d))/g,",")+n}static getRoundedAmount(e,t){if(e<0)throw new C("Amount cannot be negative for rounding.");if(t===void 0)throw new A("Invalid currency code for rounding.");let i=r.getDecimalPlaces(t),n=Math.pow(10,i);return Math.round(e*n)/n}};var U=class{baseUnitPrice;taxCategory;tiers;constructor(e){let t=new x(e.baseUnitPrice);if(!e.taxCategory)throw new v;let i=(e.tiers??[]).map(u=>({minQuantity:u.minQuantity,unitPrice:new x(u.unitPrice)})).sort((u,d)=>u.minQuantity-d.minQuantity);if(i.some(u=>u.minQuantity<=0))throw new E;let s=i.some(u=>u.unitPrice.getCurrency()!==t.getCurrency()),l=i.some((u,d)=>d>0&&u.unitPrice.compareTo(i[d-1].unitPrice)>0),f=i[0]?.unitPrice.compareTo(t)>0;if(s||l||f)throw new L("Tiers must share the same currency and must not increase in unit price.");this.baseUnitPrice=t,this.taxCategory=e.taxCategory,this.tiers=i;}getBaseUnitPrice(){return this.baseUnitPrice}getTaxCategory(){return this.taxCategory}getTiers(){return this.tiers}getDetails(){return {baseUnitPrice:this.baseUnitPrice.getDetails(),taxCategory:this.taxCategory,tiers:this.tiers.map(e=>({minQuantity:e.minQuantity,unitPrice:e.unitPrice.getDetails()}))}}getApplicableTier(e){if(e<=0)throw new N;for(let t=this.tiers.length-1;t>=0;t--)if(e>=this.tiers[t].minQuantity)return this.tiers[t];throw new R(e)}getMinQuantity(){return this.tiers[0]?.minQuantity??1}getMaxDiscountPercent(){if(!this.tiers.length)return 0;let e=this.tiers[this.tiers.length-1].unitPrice.getAmount(),t=this.baseUnitPrice.getAmount();return (t-e)/t*100}};var h=class r extends y{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(e){if(typeof e!="object")throw new p("Selection attributes must be an object");return Object.keys(e).filter(i=>e[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>e[i].name?`${i}:c+${e[i].name}`:`${i}:${e[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(e){try{let t={},i=e.split("|");for(let n of i){let[s,l]=n.split(":");l.startsWith("c+")?t[s]={name:l.slice(2)}:t[s]=l;}return t}catch(t){throw new p(t?.message)}}constructor(e,t=new Date){super(e,t),this.id=e.id,this.key=e.key,this.name={...e.name},this.description={...e.description},this.slug={...e.slug},this.brand=e.brand,this.pricing=Object.keys(e.pricing).reduce((n,s)=>(e.pricing[s]&&(n[s]=new U(e.pricing[s])),n),{}),this.targetGender=e.targetGender,this.attributes=c.deepClone(e.attributes),this.specifications=c.deepClone(e.specifications),this.categories=c.deepClone(e.categories);let i=new Set;this.variants=(e.variants||[]).map(n=>{if(!n.selectionAttributes||typeof n.selectionAttributes!="object")throw new p("Selection attributes are required");this.checkSelectionAttributes(n.selectionAttributes);let s=r.generateSelectionAttributesKey(n.selectionAttributes);if(i.has(s))throw new T(s);return i.add(s),{sku:n.sku,selectionAttributes:n.selectionAttributes,images:{primary:new I(n.images.primary),gallery:(n.images.gallery||[]).map(l=>new I(l))}}}),this.isActive=e.isActive,this.searchTags=e.searchTags?c.deepClone(e.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(e){return e?this.name[e]??this.name[b[e]]??this.name.en:c.deepClone(this.name)}getDescription(e){return e?this.description[e]??this.description[b[e]]??this.description.en:c.deepClone(this.description)}getSlug(e){return e?this.slug[e]??this.slug[b[e]]??this.slug.en:c.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:this.pricing}getAttributes(){return c.deepClone(this.attributes)}getVariants(){return this.variants.map(e=>({sku:e.sku,selectionAttributes:e.selectionAttributes,images:{primary:e.images.primary,gallery:e.images.gallery}}))}getImagesBySelectionAttributes(e){let t=r.generateSelectionAttributesKey(e),i=this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t);return i?i.images:null}getImages(e,t){switch(t){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return c.deepClone(this.categories)}getSpecifications(e){return e?c.deepClone(this.specifications[e]??this.specifications[b[e]]??this.specifications.en):c.deepClone(this.specifications)}getSearchTags(e){return e?c.deepClone(this.searchTags[e]??this.searchTags[b[e]]??this.searchTags.en):c.deepClone(this.searchTags)}getDetails(){let e=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((t,i)=>(this.pricing[i]&&(t[i]=this.pricing[i]?.getDetails()),t),{}),attributes:this.getAttributes(),variants:this.variants.map(t=>({sku:t.sku,selectionAttributes:c.deepClone(t.selectionAttributes),images:{primary:t.images.primary.getDetails(),gallery:t.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}checkSelectionAttributes(e){if(!e||typeof e!="object")throw new p("Selection attributes are required");Object.keys(this.attributes).forEach(t=>{if(t.toLowerCase()==="size")return;let i=this.attributes[t],n=e[t];if(n===void 0)throw new p(`Selection attribute '${t}' is missing`);if(typeof i=="string"){if(typeof n!="string"||i!==n)throw new p(`Selection attribute '${t}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof n!="string"||!i.includes(n))throw new p(`Selection attribute '${t}' is invalid`)}else if(typeof n!="object"||!("name"in n)||i.findIndex(s=>s.name===n.name)<0)throw new p(`Selection attribute '${t}' is invalid`)}});}validateSelectionAttribute(e){let t=r.generateSelectionAttributesKey(e);return this.variants.some(i=>r.generateSelectionAttributesKey(i.selectionAttributes)===t)}validateSize(e){return this.attributes.size.includes(e)}};var se={isUUID:r=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(r),isEmail:r=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r),isURL:r=>/^(http|https):\/\/[^ "]+$/.test(r),generateUUID:(r,e)=>e&&r?F(r,e):B(),generateSearchId:(r,e)=>`${r}#${h.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:r=>{let[e,t]=r.split("#");return {key:e,selectionAttributes:h.parseSelectionAttributesKey(t)}},deepClone(r){return structuredClone(r)}},c=se;var Y=class extends y{productKey;stocks;constructor(e,t=new Date){super(e,t),this.productKey=e.productKey,this.stocks=e.stocks.map(i=>({selectionAttributes:c.deepClone(i.selectionAttributes),size:i.size,available:i.available,country:i.country}));}getProductKey(){return this.productKey}getStockData(e,t,i){let n=e?h.generateSelectionAttributesKey(e):void 0;return this.stocks.filter(s=>!(n&&h.generateSelectionAttributesKey(s.selectionAttributes)!==n||t&&s.size!==t||i&&s.country!==i))}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),stocks:this.getStockData()}}};exports.InventoryModel=Y;//# sourceMappingURL=Inventory.js.map
|
|
2
2
|
//# sourceMappingURL=Inventory.js.map
|