b23-lib 1.9.3 → 1.9.4

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 (42) hide show
  1. package/dist/Classes/Cart.js +1 -1
  2. package/dist/Classes/Cart.js.map +1 -1
  3. package/dist/Classes/Cart.mjs +1 -1
  4. package/dist/Classes/Coupon.js +1 -1
  5. package/dist/Classes/Coupon.js.map +1 -1
  6. package/dist/Classes/Coupon.mjs +1 -1
  7. package/dist/Classes/Enum.d.mts +2 -2
  8. package/dist/Classes/Enum.d.ts +2 -2
  9. package/dist/Classes/Enum.js +1 -1
  10. package/dist/Classes/Enum.js.map +1 -1
  11. package/dist/Classes/Enum.mjs +1 -1
  12. package/dist/Classes/LineItem.js +1 -1
  13. package/dist/Classes/LineItem.js.map +1 -1
  14. package/dist/Classes/LineItem.mjs +1 -1
  15. package/dist/Classes/Order.js +1 -1
  16. package/dist/Classes/Order.js.map +1 -1
  17. package/dist/Classes/Order.mjs +1 -1
  18. package/dist/Classes/Price.js.map +1 -1
  19. package/dist/Classes/Price.mjs +1 -1
  20. package/dist/Classes/Product.js +1 -1
  21. package/dist/Classes/Product.js.map +1 -1
  22. package/dist/Classes/Product.mjs +1 -1
  23. package/dist/Classes/ShoppingContainer.js +1 -1
  24. package/dist/Classes/ShoppingContainer.js.map +1 -1
  25. package/dist/Classes/ShoppingContainer.mjs +1 -1
  26. package/dist/chunk-6PDP4ETM.mjs +2 -0
  27. package/dist/{chunk-G6EL2Y7V.mjs.map → chunk-6PDP4ETM.mjs.map} +1 -1
  28. package/dist/{chunk-7T4QJTIJ.mjs → chunk-7MCLT4SV.mjs} +2 -2
  29. package/dist/{chunk-7T4QJTIJ.mjs.map → chunk-7MCLT4SV.mjs.map} +1 -1
  30. package/dist/{chunk-SY36ZFQ6.mjs → chunk-K3AXPTGG.mjs} +2 -2
  31. package/dist/{chunk-SY36ZFQ6.mjs.map → chunk-K3AXPTGG.mjs.map} +1 -1
  32. package/dist/{chunk-KUUS5GQR.mjs → chunk-MEVX32L7.mjs} +2 -2
  33. package/dist/{chunk-KUUS5GQR.mjs.map → chunk-MEVX32L7.mjs.map} +1 -1
  34. package/dist/{chunk-GTH5SKQK.mjs → chunk-RWBNLNQ6.mjs} +2 -2
  35. package/dist/{chunk-GTH5SKQK.mjs.map → chunk-RWBNLNQ6.mjs.map} +1 -1
  36. package/dist/{chunk-DJHX4EUG.mjs → chunk-V4H3X4PI.mjs} +2 -2
  37. package/dist/{chunk-DJHX4EUG.mjs.map → chunk-V4H3X4PI.mjs.map} +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-G6EL2Y7V.mjs +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Classes/ShoppingContainer.ts"],"names":["BaseShoppingContainerModel","BaseModel","data","date","item","LineItemModel","AddressModel","coupon","CouponModel","PriceModel","sum","minCartValueReq","maxCartDiscountCap","couponCategory","discountMethod","potentialDiscount","targetValue","flatAmount","finalDiscount","totalDiscount","discount","shippingCouponDiscount","c","nonShippingCouponDiscount","grossTotal","details"],"mappings":"uMAmDA,IAA8BA,EAA9B,cAAiEC,CAAU,CAC/D,EACA,CAAA,UAAA,CACA,cACA,WACA,CAAA,SAAA,CACA,gBACA,eACA,CAAA,cAAA,CAGA,QAGA,KASA,CAAA,OAAA,CACA,SACA,MAQV,CAAA,WAAA,CAAYC,EAAuCC,GAAa,CAAA,IAAI,IAAQ,CAAA,CAC1E,MAAMD,CAAMC,CAAAA,GAAI,EAChB,IAAK,CAAA,EAAA,CAAKD,EAAK,EACf,CAAA,IAAA,CAAK,WAAaA,CAAK,CAAA,UAAA,CACvB,KAAK,aAAgBA,CAAAA,CAAAA,CAAK,cAC1B,IAAK,CAAA,WAAA,CAAcA,EAAK,WACxB,CAAA,IAAA,CAAK,OAAUA,CAAAA,CAAAA,CAAK,QACpB,IAAK,CAAA,QA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Y,CAC5D,CAAA,KAAA,CAAO,KAAK,QAAS,EAAA,CACrB,QAAS,IAAK,CAAA,UAAA,GACd,QAAU,CAAA,IAAA,CAAK,aACf,CAAA,MAAA,CAAQ,KAAK,SAAU,EACzB,CACF,CACH","file":"chunk-KUUS5GQR.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport AddressModel, { AddressData } from \"./Address\";\r\nimport LineItemModel, { LineItemData } from \"./LineItem\";\r\nimport { CountryCode, CurrencyCode, LocaleCode, ShippingDetails } from \"./Common\";\r\nimport PriceModel from \"./Price\";\r\nimport CouponModel, { CouponCategory, CouponData, CouponDiscountMethod } from \"./Coupon\";\r\n\r\nexport type ShoppingContainerTotal = {\r\n shipping?: number;\r\n effectiveShipping?: number;\r\n subtotal?: number;\r\n mrpTotal?: number;\r\n couponTotal?: { [key: string]: number };\r\n grandTotal?: number;\r\n}\r\n\r\nexport type BaseShoppingContainerAttributes = BaseAttributes & {\r\n id: string;\r\n customerId?: string;\r\n customerEmail?: string;\r\n anonymousId?: string;\r\n lineItems: LineItemData[];\r\n shippingDetails: ShippingDetails | null;\r\n shippingAddress?: AddressData | null;\r\n billingAddress?: AddressData | null;\r\n coupons?: CouponData[];\r\n total?: ShoppingContainerTotal;\r\n country: CountryCode;\r\n currency: CurrencyCode;\r\n locale: LocaleCode;\r\n};\r\n\r\nexport type BaseShoppingContainerData = Omit<BaseShoppingContainerAttributes, 'coupons' | 'total'>\r\n& BaseData\r\n& {\r\n coupons: CouponData[],\r\n total: {\r\n shipping: number,\r\n effectiveShipping: number,\r\n subtotal: number,\r\n mrpTotal: number,\r\n couponTotal: { [key: string]: number },\r\n grandTotal: number\r\n };\r\n };\r\n\r\n\r\n/**\r\n * Abstract base class for shopping-related containers like carts and orders.\r\n * Manages common elements such as line items, addresses, coupons, and totals.\r\n */\r\nexport default abstract class BaseShoppingContainerModel extends BaseModel {\r\n protected id: string;\r\n protected customerId?: string;\r\n protected customerEmail?: string;\r\n protected anonymousId?: string;\r\n protected lineItems: LineItemModel[];\r\n protected shippingDetails: ShippingDetails | null;\r\n protected shippingAddress: AddressModel | null;\r\n protected billingAddress: AddressModel | null;\r\n\r\n // CouponsCodes\r\n protected coupons: CouponModel[];\r\n\r\n // Cart Totals\r\n protected total: {\r\n shipping: number;\r\n effectiveShipping: number;\r\n subtotal: number;\r\n mrpTotal: number;\r\n couponTotal: { [key: string]: number; };\r\n grandTotal: number;\r\n };\r\n\r\n protected country: CountryCode;\r\n protected currency: CurrencyCode;\r\n protected locale: LocaleCode;\r\n\r\n /**\r\n * Creates an instance of BaseShoppingContainerModel.\r\n * Initializes common properties and calculates initial base totals.\r\n * @param data - The initial attributes for the shopping container.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: BaseShoppingContainerAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.customerId = data.customerId;\r\n this.customerEmail = data.customerEmail;\r\n this.anonymousId = data.anonymousId;\r\n this.country = data.country;\r\n this.currency = data.currency;\r\n this.locale = data.locale;\r\n this.lineItems = (data.lineItems ?? []).map(item => new LineItemModel(item));\r\n this.billingAddress = data.billingAddress ? new AddressModel(data.billingAddress, date) : null;\r\n this.shippingAddress = data.shippingAddress ? new AddressModel(data.shippingAddress, date) : null;\r\n this.coupons = (data.coupons || []).map(coupon => new CouponModel(coupon));\r\n\r\n this.shippingDetails = data.shippingDetails ? { ...data.shippingDetails } : null;\r\n\r\n this.total = {\r\n shipping: data.total?.shipping || 0,\r\n effectiveShipping: data.total?.effectiveShipping ?? data.total?.shipping ?? 0,\r\n subtotal: 0, // Will be calculated\r\n mrpTotal: 0, // Will be calculated\r\n couponTotal: data.total?.couponTotal || {},\r\n grandTotal: data.total?.grandTotal || 0, // Will be recalculated\r\n };\r\n\r\n this.recalculateBaseTotals();\r\n }\r\n\r\n /**\r\n * Recalculates the subtotal and mrpTotal based on the current line items.\r\n * Uses PriceModel for rounding based on the country.\r\n */\r\n protected recalculateBaseTotals(): void {\r\n this.total.subtotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().subtotal, 0), this.country);\r\n this.total.mrpTotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().mrpTotal, 0), this.country);\r\n }\r\n\r\n /**\r\n * Gets the unique identifier for this shopping container (cart ID or order ID).\r\n * @returns The ID string.\r\n */\r\n public getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the customer ID associated with this container, if available.\r\n * @returns The customer ID string, or undefined.\r\n */\r\n public getCustomerId(): string | undefined {\r\n return this.customerId;\r\n }\r\n\r\n /**\r\n * Gets the customer email associated with this container, if available.\r\n * @returns The customer email string, or undefined.\r\n */\r\n public getCustomerEmail(): string | undefined {\r\n return this.customerEmail;\r\n }\r\n\r\n /**\r\n * Gets the anonymous user ID associated with this container, if available.\r\n * @returns The anonymous ID string, or undefined.\r\n */\r\n public getAnonymousId(): string | undefined {\r\n return this.anonymousId;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the line items in the container.\r\n * Each item is a new LineItemModel instance created from the original's details.\r\n * @returns An array of LineItemModel instances.\r\n */\r\n public getLineItems(): LineItemModel[] {\r\n // Return new instances to prevent modification of internal state\r\n return this.lineItems.map(item => new LineItemModel(item.getDetails()));\r\n }\r\n\r\n /**\r\n * Gets current number of line items in the container\r\n * @returns \r\n */\r\n public getLineItemsCount(): number {\r\n return this.lineItems.length;\r\n }\r\n\r\n /**\r\n * Gets a copy of the shipping details associated with the container.\r\n * @returns A ShippingDetails object, or null if none are set.\r\n */\r\n public getShippingDetails(): ShippingDetails | null {\r\n // Return a shallow copy if details exist\r\n return this.shippingDetails ? { ...this.shippingDetails } : null;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the shipping address associated with the container.\r\n * Returns a new AddressModel instance created from the original's details.\r\n * @returns An AddressModel instance, or null if no shipping address is set.\r\n */\r\n public getShippingAddress(): AddressModel | null {\r\n return this.shippingAddress ? new AddressModel(this.shippingAddress.getDetails()) : null;\r\n }\r\n\r\n /**\r\n * Checks if a shipping address is associated with this container.\r\n * @returns True if a shipping address is set, false otherwise.\r\n */\r\n public hasShippingAddress(): boolean {\r\n return !!this.shippingAddress;\r\n }\r\n\r\n /**\r\n * Checks if a billing address is associated with this container.\r\n * @returns True if a billing address is set, false otherwise.\r\n */\r\n public hasBillingAddress(): boolean {\r\n return !!this.billingAddress;\r\n }\r\n \r\n /**\r\n * Gets a defensive copy of the billing address associated with the container.\r\n * Returns a new AddressModel instance created from the original's details.\r\n * @returns An AddressModel instance, or null if no billing address is set.\r\n */\r\n public getBillingAddress(): AddressModel | null {\r\n return this.billingAddress ? new AddressModel(this.billingAddress.getDetails()) : null;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the coupons applied to the container.\r\n * Each item is a new CouponModel instance created from the original's details.\r\n * @returns An array of CouponModel instances.\r\n */\r\n public getCoupons(): CouponModel[] {\r\n return this.coupons.map(coupon => new CouponModel(coupon.getDetails()));\r\n }\r\n\r\n /**\r\n * Gets the country code associated with this container.\r\n * @returns The CountryCode enum value.\r\n */\r\n public getCountry(): CountryCode {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Gets the currency code associated with this container.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Gets the locale code associated with this container.\r\n * @returns The LocaleCode enum value.\r\n */\r\n public getLocale(): LocaleCode {\r\n return this.locale;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the calculated totals for the container.\r\n * @returns An object containing shipping, subtotal, coupon, and grand totals.\r\n */\r\n public getTotal() {\r\n return { ...this.total, couponTotal: { ...this.total.couponTotal } };\r\n }\r\n\r\n /**\r\n * Calculates the discount value for a given coupon based on the current container state.\r\n * Returns 0 if the coupon is invalid, expired, or not applicable based on cart value or target category.\r\n * @param coupon - The CouponModel instance to evaluate.\r\n * @returns The calculated discount amount (rounded according to country rules).\r\n */\r\n public calculateApplicableCouponDiscount(coupon: CouponModel): number {\r\n // 1. Basic validation (active)\r\n if (!coupon.isActive()) {\r\n return 0;\r\n }\r\n\r\n // 2. Check regional requirements (min cart value, max discount)\r\n const minCartValueReq = coupon.getMinCartValue(this.country);\r\n const maxCartDiscountCap = coupon.getMaxCartDiscount(this.country);\r\n\r\n // Ensure minCartValueReq exists and subtotal meets the requirement\r\n if (!minCartValueReq || this.total.subtotal < minCartValueReq.price) {\r\n return 0;\r\n }\r\n\r\n // Ensure maxCartDiscountCap exists and is non-negative\r\n if (!maxCartDiscountCap || maxCartDiscountCap.price < 0) {\r\n return 0;\r\n }\r\n\r\n // 3. Calculate potential discount based on method and category\r\n const couponCategory = coupon.getCategory();\r\n const discountMethod = coupon.getDiscountMethod();\r\n let potentialDiscount = 0;\r\n // Determine the value the coupon applies to (shipping cost or subtotal)\r\n const targetValue = couponCategory === CouponCategory.SHIPPING ? this.total.shipping : this.total.subtotal;\r\n\r\n // No discount if the target value is zero or less\r\n if (targetValue <= 0) return 0;\r\n\r\n switch (discountMethod) {\r\n case CouponDiscountMethod.FLAT:\r\n // Flat discount is capped by the target value itself and the max discount cap\r\n const flatAmount = maxCartDiscountCap?.price ?? 0; // Use cap as the flat amount source? Or coupon.value? Needs clarification. Assuming cap IS the flat amount here.\r\n potentialDiscount = Math.min(targetValue, flatAmount);\r\n break;\r\n case CouponDiscountMethod.PERCENTAGE:\r\n // Calculate percentage discount based on the target value\r\n potentialDiscount = targetValue * (coupon.getPercentageValue() / 100);\r\n break;\r\n default:\r\n // Unknown discount method\r\n return 0;\r\n }\r\n\r\n // 4. Apply maximum discount cap to the calculated potential discount\r\n const finalDiscount = Math.min(potentialDiscount, maxCartDiscountCap.price);\r\n\r\n // 5. Round the final discount, ensuring it's not negative\r\n return PriceModel.getRoundedPrice(Math.max(0, finalDiscount), this.country);\r\n }\r\n\r\n /**\r\n * Recalculates the `couponTotal` map based on currently applied coupons.\r\n * Iterates through coupons, calculates their applicable discount, and stores it.\r\n * @returns The total discount amount from all valid and applicable coupons (rounded).\r\n */\r\n public recalculateCouponTotals(): number {\r\n this.total.couponTotal = {}; // Reset the map\r\n let totalDiscount = 0;\r\n\r\n this.coupons.forEach(coupon => {\r\n const discount = this.calculateApplicableCouponDiscount(coupon);\r\n if (discount > 0) {\r\n this.total.couponTotal[coupon.getCode()] = discount; // Store per-coupon discount\r\n totalDiscount += discount; // Accumulate total discount\r\n }\r\n });\r\n // Return the rounded total discount\r\n return PriceModel.getRoundedPrice(totalDiscount, this.country);\r\n }\r\n\r\n /**\r\n * Recalculates all container totals (subtotal, mrpTotal, coupons, shipping, grandTotal).\r\n * Should be called whenever line items, coupons, or base shipping cost change.\r\n */\r\n public updateCartTotals(): void {\r\n // 1. Calculate line item totals (subtotal, mrpTotal)\r\n this.total.subtotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().subtotal, 0), this.country);\r\n this.total.mrpTotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().mrpTotal, 0), this.country);\r\n\r\n // 2. Calculate total coupon discount and update the per-coupon discount map\r\n this.recalculateCouponTotals(); // This updates this.total.couponTotal\r\n\r\n // 3. Calculate effective shipping cost after applying shipping-specific coupons\r\n const shippingCouponDiscount = this.coupons\r\n .filter(c => c.getCategory() === CouponCategory.SHIPPING)\r\n .reduce((sum, c) => sum + (this.total.couponTotal[c.getCode()] ?? 0), 0);\r\n this.total.effectiveShipping = PriceModel.getRoundedPrice(Math.max(0, this.total.shipping - shippingCouponDiscount), this.country);\r\n\r\n // 4. Calculate total discount from non-shipping coupons\r\n const nonShippingCouponDiscount = this.coupons\r\n .filter(c => c.getCategory() !== CouponCategory.SHIPPING)\r\n .reduce((sum, c) => sum + (this.total.couponTotal[c.getCode()] ?? 0), 0);\r\n\r\n // 5. Calculate final grand total: (subtotal + effective shipping) - non-shipping discounts\r\n const grossTotal = this.total.subtotal + this.total.effectiveShipping;\r\n this.total.grandTotal = PriceModel.getRoundedPrice(Math.max(0, grossTotal - nonShippingCouponDiscount), this.country);\r\n }\r\n\r\n /**\r\n * Updates the shipping details (including estimated cost) for the container and recalculates totals.\r\n * @param details - The new ShippingDetails object, or null to clear shipping details and cost.\r\n */\r\n public setShippingDetails(details: ShippingDetails | null): void {\r\n // Store a copy of the details or null\r\n this.shippingDetails = details ? { ...details } : null;\r\n\r\n // Update the base shipping cost based on the new details\r\n this.total.shipping = PriceModel.getRoundedPrice(this.shippingDetails?.estimatedCost ?? 0, this.country);\r\n // Recalculate all totals as shipping cost affects effective shipping and grand total\r\n this.updateCartTotals();\r\n }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the shopping container's current state.\r\n * Includes details from the base model and specific container properties.\r\n * @returns BaseShoppingContainerData object suitable for serialization or API responses.\r\n */\r\n getDetails(): BaseShoppingContainerData {\r\n return {\r\n ...super.getDetails(),\r\n id: this.getId(),\r\n customerId: this.getCustomerId(),\r\n customerEmail: this.getCustomerEmail(),\r\n anonymousId: this.getAnonymousId(),\r\n lineItems: this.getLineItems().map(item => item.getDetails()),\r\n shippingDetails: this.getShippingDetails(),\r\n shippingAddress: this.getShippingAddress()?.getDetails() || null,\r\n billingAddress: this.getBillingAddress()?.getDetails() || null,\r\n coupons: this.getCoupons().map(coupon => coupon.getDetails()),\r\n total: this.getTotal(),\r\n country: this.getCountry(),\r\n currency: this.getCurrency(),\r\n locale: this.getLocale(),\r\n }\r\n };\r\n}\r\n"]}
1
+ {"version":3,"sources":["../src/Classes/ShoppingContainer.ts"],"names":["BaseShoppingContainerModel","BaseModel","data","date","item","LineItemModel","AddressModel","coupon","CouponModel","PriceModel","sum","minCartValueReq","maxCartDiscountCap","couponCategory","discountMethod","potentialDiscount","targetValue","flatAmount","finalDiscount","totalDiscount","discount","shippingCouponDiscount","c","nonShippingCouponDiscount","grossTotal","details"],"mappings":"uMAmDA,IAA8BA,EAA9B,cAAiEC,CAAU,CAC/D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ACT,CAAA,UAAA,CAAY,KAAK,aAAc,EAAA,CAC/B,cAAe,IAAK,CAAA,gBAAA,GACpB,WAAa,CAAA,IAAA,CAAK,gBAClB,CAAA,SAAA,CAAW,KAAK,YAAa,EAAA,CAAE,IAAIL,CAAQA,EAAAA,CAAAA,CAAK,YAAY,CAAA,CAC5D,eAAiB,CAAA,IAAA,CAAK,oBACtB,CAAA,eAAA,CAAiB,KAAK,kBAAmB,EAAA,EAAG,YAAgB,EAAA,IAAA,CAC5D,eAAgB,IAAK,CAAA,iBAAA,IAAqB,UAAW,EAAA,EAAK,KAC1D,OAAS,CAAA,IAAA,CAAK,YAAa,CAAA,GAAA,CAAIG,GAAUA,CAAO,CAAA,UAAA,EAAY,CAC5D,CAAA,KAAA,CAAO,KAAK,QAAS,EAAA,CACrB,QAAS,IAAK,CAAA,UAAA,GACd,QAAU,CAAA,IAAA,CAAK,aACf,CAAA,MAAA,CAAQ,KAAK,SAAU,EACzB,CACF,CACH","file":"chunk-MEVX32L7.mjs","sourcesContent":["import BaseModel, { BaseAttributes, BaseData } from \"./Base\";\r\nimport AddressModel, { AddressData } from \"./Address\";\r\nimport LineItemModel, { LineItemData } from \"./LineItem\";\r\nimport { CountryCode, CurrencyCode, LocaleCode, ShippingDetails } from \"./Common\";\r\nimport PriceModel from \"./Price\";\r\nimport CouponModel, { CouponCategory, CouponData, CouponDiscountMethod } from \"./Coupon\";\r\n\r\nexport type ShoppingContainerTotal = {\r\n shipping?: number;\r\n effectiveShipping?: number;\r\n subtotal?: number;\r\n mrpTotal?: number;\r\n couponTotal?: { [key: string]: number };\r\n grandTotal?: number;\r\n}\r\n\r\nexport type BaseShoppingContainerAttributes = BaseAttributes & {\r\n id: string;\r\n customerId?: string;\r\n customerEmail?: string;\r\n anonymousId?: string;\r\n lineItems: LineItemData[];\r\n shippingDetails: ShippingDetails | null;\r\n shippingAddress?: AddressData | null;\r\n billingAddress?: AddressData | null;\r\n coupons?: CouponData[];\r\n total?: ShoppingContainerTotal;\r\n country: CountryCode;\r\n currency: CurrencyCode;\r\n locale: LocaleCode;\r\n};\r\n\r\nexport type BaseShoppingContainerData = Omit<BaseShoppingContainerAttributes, 'coupons' | 'total'>\r\n& BaseData\r\n& {\r\n coupons: CouponData[],\r\n total: {\r\n shipping: number,\r\n effectiveShipping: number,\r\n subtotal: number,\r\n mrpTotal: number,\r\n couponTotal: { [key: string]: number },\r\n grandTotal: number\r\n };\r\n };\r\n\r\n\r\n/**\r\n * Abstract base class for shopping-related containers like carts and orders.\r\n * Manages common elements such as line items, addresses, coupons, and totals.\r\n */\r\nexport default abstract class BaseShoppingContainerModel extends BaseModel {\r\n protected id: string;\r\n protected customerId?: string;\r\n protected customerEmail?: string;\r\n protected anonymousId?: string;\r\n protected lineItems: LineItemModel[];\r\n protected shippingDetails: ShippingDetails | null;\r\n protected shippingAddress: AddressModel | null;\r\n protected billingAddress: AddressModel | null;\r\n\r\n // CouponsCodes\r\n protected coupons: CouponModel[];\r\n\r\n // Cart Totals\r\n protected total: {\r\n shipping: number;\r\n effectiveShipping: number;\r\n subtotal: number;\r\n mrpTotal: number;\r\n couponTotal: { [key: string]: number; };\r\n grandTotal: number;\r\n };\r\n\r\n protected country: CountryCode;\r\n protected currency: CurrencyCode;\r\n protected locale: LocaleCode;\r\n\r\n /**\r\n * Creates an instance of BaseShoppingContainerModel.\r\n * Initializes common properties and calculates initial base totals.\r\n * @param data - The initial attributes for the shopping container.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: BaseShoppingContainerAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.customerId = data.customerId;\r\n this.customerEmail = data.customerEmail;\r\n this.anonymousId = data.anonymousId;\r\n this.country = data.country;\r\n this.currency = data.currency;\r\n this.locale = data.locale;\r\n this.lineItems = (data.lineItems ?? []).map(item => new LineItemModel(item));\r\n this.billingAddress = data.billingAddress ? new AddressModel(data.billingAddress, date) : null;\r\n this.shippingAddress = data.shippingAddress ? new AddressModel(data.shippingAddress, date) : null;\r\n this.coupons = (data.coupons || []).map(coupon => new CouponModel(coupon));\r\n\r\n this.shippingDetails = data.shippingDetails ? { ...data.shippingDetails } : null;\r\n\r\n this.total = {\r\n shipping: data.total?.shipping || 0,\r\n effectiveShipping: data.total?.effectiveShipping ?? data.total?.shipping ?? 0,\r\n subtotal: 0, // Will be calculated\r\n mrpTotal: 0, // Will be calculated\r\n couponTotal: data.total?.couponTotal || {},\r\n grandTotal: data.total?.grandTotal || 0, // Will be recalculated\r\n };\r\n\r\n this.recalculateBaseTotals();\r\n }\r\n\r\n /**\r\n * Recalculates the subtotal and mrpTotal based on the current line items.\r\n * Uses PriceModel for rounding based on the country.\r\n */\r\n protected recalculateBaseTotals(): void {\r\n this.total.subtotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().subtotal, 0), this.country);\r\n this.total.mrpTotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().mrpTotal, 0), this.country);\r\n }\r\n\r\n /**\r\n * Gets the unique identifier for this shopping container (cart ID or order ID).\r\n * @returns The ID string.\r\n */\r\n public getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the customer ID associated with this container, if available.\r\n * @returns The customer ID string, or undefined.\r\n */\r\n public getCustomerId(): string | undefined {\r\n return this.customerId;\r\n }\r\n\r\n /**\r\n * Gets the customer email associated with this container, if available.\r\n * @returns The customer email string, or undefined.\r\n */\r\n public getCustomerEmail(): string | undefined {\r\n return this.customerEmail;\r\n }\r\n\r\n /**\r\n * Gets the anonymous user ID associated with this container, if available.\r\n * @returns The anonymous ID string, or undefined.\r\n */\r\n public getAnonymousId(): string | undefined {\r\n return this.anonymousId;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the line items in the container.\r\n * Each item is a new LineItemModel instance created from the original's details.\r\n * @returns An array of LineItemModel instances.\r\n */\r\n public getLineItems(): LineItemModel[] {\r\n // Return new instances to prevent modification of internal state\r\n return this.lineItems.map(item => new LineItemModel(item.getDetails()));\r\n }\r\n\r\n /**\r\n * Gets current number of line items in the container\r\n * @returns \r\n */\r\n public getLineItemsCount(): number {\r\n return this.lineItems.length;\r\n }\r\n\r\n /**\r\n * Gets a copy of the shipping details associated with the container.\r\n * @returns A ShippingDetails object, or null if none are set.\r\n */\r\n public getShippingDetails(): ShippingDetails | null {\r\n // Return a shallow copy if details exist\r\n return this.shippingDetails ? { ...this.shippingDetails } : null;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the shipping address associated with the container.\r\n * Returns a new AddressModel instance created from the original's details.\r\n * @returns An AddressModel instance, or null if no shipping address is set.\r\n */\r\n public getShippingAddress(): AddressModel | null {\r\n return this.shippingAddress ? new AddressModel(this.shippingAddress.getDetails()) : null;\r\n }\r\n\r\n /**\r\n * Checks if a shipping address is associated with this container.\r\n * @returns True if a shipping address is set, false otherwise.\r\n */\r\n public hasShippingAddress(): boolean {\r\n return !!this.shippingAddress;\r\n }\r\n\r\n /**\r\n * Checks if a billing address is associated with this container.\r\n * @returns True if a billing address is set, false otherwise.\r\n */\r\n public hasBillingAddress(): boolean {\r\n return !!this.billingAddress;\r\n }\r\n \r\n /**\r\n * Gets a defensive copy of the billing address associated with the container.\r\n * Returns a new AddressModel instance created from the original's details.\r\n * @returns An AddressModel instance, or null if no billing address is set.\r\n */\r\n public getBillingAddress(): AddressModel | null {\r\n return this.billingAddress ? new AddressModel(this.billingAddress.getDetails()) : null;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the coupons applied to the container.\r\n * Each item is a new CouponModel instance created from the original's details.\r\n * @returns An array of CouponModel instances.\r\n */\r\n public getCoupons(): CouponModel[] {\r\n return this.coupons.map(coupon => new CouponModel(coupon.getDetails()));\r\n }\r\n\r\n /**\r\n * Gets the country code associated with this container.\r\n * @returns The CountryCode enum value.\r\n */\r\n public getCountry(): CountryCode {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Gets the currency code associated with this container.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Gets the locale code associated with this container.\r\n * @returns The LocaleCode enum value.\r\n */\r\n public getLocale(): LocaleCode {\r\n return this.locale;\r\n }\r\n\r\n /**\r\n * Gets a defensive copy of the calculated totals for the container.\r\n * @returns An object containing shipping, subtotal, coupon, and grand totals.\r\n */\r\n public getTotal() {\r\n return { ...this.total, couponTotal: { ...this.total.couponTotal } };\r\n }\r\n\r\n /**\r\n * Calculates the discount value for a given coupon based on the current container state.\r\n * Returns 0 if the coupon is invalid, expired, or not applicable based on cart value or target category.\r\n * @param coupon - The CouponModel instance to evaluate.\r\n * @returns The calculated discount amount (rounded according to country rules).\r\n */\r\n public calculateApplicableCouponDiscount(coupon: CouponModel): number {\r\n // 1. Basic validation (active)\r\n if (!coupon.isActive()) {\r\n return 0;\r\n }\r\n\r\n // 2. Check regional requirements (min cart value, max discount)\r\n const minCartValueReq = coupon.getMinCartValue(this.country);\r\n const maxCartDiscountCap = coupon.getMaxCartDiscount(this.country);\r\n\r\n // Ensure minCartValueReq exists and subtotal meets the requirement\r\n if (!minCartValueReq || this.total.subtotal < minCartValueReq.price) {\r\n return 0;\r\n }\r\n\r\n // Ensure maxCartDiscountCap exists and is non-negative\r\n if (!maxCartDiscountCap || maxCartDiscountCap.price < 0) {\r\n return 0;\r\n }\r\n\r\n // 3. Calculate potential discount based on method and category\r\n const couponCategory = coupon.getCategory();\r\n const discountMethod = coupon.getDiscountMethod();\r\n let potentialDiscount = 0;\r\n // Determine the value the coupon applies to (shipping cost or subtotal)\r\n const targetValue = couponCategory === CouponCategory.SHIPPING ? this.total.shipping : this.total.subtotal;\r\n\r\n // No discount if the target value is zero or less\r\n if (targetValue <= 0) return 0;\r\n\r\n switch (discountMethod) {\r\n case CouponDiscountMethod.FLAT:\r\n // Flat discount is capped by the target value itself and the max discount cap\r\n const flatAmount = maxCartDiscountCap?.price ?? 0; // Use cap as the flat amount source? Or coupon.value? Needs clarification. Assuming cap IS the flat amount here.\r\n potentialDiscount = Math.min(targetValue, flatAmount);\r\n break;\r\n case CouponDiscountMethod.PERCENTAGE:\r\n // Calculate percentage discount based on the target value\r\n potentialDiscount = targetValue * (coupon.getPercentageValue() / 100);\r\n break;\r\n default:\r\n // Unknown discount method\r\n return 0;\r\n }\r\n\r\n // 4. Apply maximum discount cap to the calculated potential discount\r\n const finalDiscount = Math.min(potentialDiscount, maxCartDiscountCap.price);\r\n\r\n // 5. Round the final discount, ensuring it's not negative\r\n return PriceModel.getRoundedPrice(Math.max(0, finalDiscount), this.country);\r\n }\r\n\r\n /**\r\n * Recalculates the `couponTotal` map based on currently applied coupons.\r\n * Iterates through coupons, calculates their applicable discount, and stores it.\r\n * @returns The total discount amount from all valid and applicable coupons (rounded).\r\n */\r\n public recalculateCouponTotals(): number {\r\n this.total.couponTotal = {}; // Reset the map\r\n let totalDiscount = 0;\r\n\r\n this.coupons.forEach(coupon => {\r\n const discount = this.calculateApplicableCouponDiscount(coupon);\r\n if (discount > 0) {\r\n this.total.couponTotal[coupon.getCode()] = discount; // Store per-coupon discount\r\n totalDiscount += discount; // Accumulate total discount\r\n }\r\n });\r\n // Return the rounded total discount\r\n return PriceModel.getRoundedPrice(totalDiscount, this.country);\r\n }\r\n\r\n /**\r\n * Recalculates all container totals (subtotal, mrpTotal, coupons, shipping, grandTotal).\r\n * Should be called whenever line items, coupons, or base shipping cost change.\r\n */\r\n public updateCartTotals(): void {\r\n // 1. Calculate line item totals (subtotal, mrpTotal)\r\n this.total.subtotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().subtotal, 0), this.country);\r\n this.total.mrpTotal = PriceModel.getRoundedPrice(this.lineItems.reduce((sum, item) => sum + item.getPriceTotals().mrpTotal, 0), this.country);\r\n\r\n // 2. Calculate total coupon discount and update the per-coupon discount map\r\n this.recalculateCouponTotals(); // This updates this.total.couponTotal\r\n\r\n // 3. Calculate effective shipping cost after applying shipping-specific coupons\r\n const shippingCouponDiscount = this.coupons\r\n .filter(c => c.getCategory() === CouponCategory.SHIPPING)\r\n .reduce((sum, c) => sum + (this.total.couponTotal[c.getCode()] ?? 0), 0);\r\n this.total.effectiveShipping = PriceModel.getRoundedPrice(Math.max(0, this.total.shipping - shippingCouponDiscount), this.country);\r\n\r\n // 4. Calculate total discount from non-shipping coupons\r\n const nonShippingCouponDiscount = this.coupons\r\n .filter(c => c.getCategory() !== CouponCategory.SHIPPING)\r\n .reduce((sum, c) => sum + (this.total.couponTotal[c.getCode()] ?? 0), 0);\r\n\r\n // 5. Calculate final grand total: (subtotal + effective shipping) - non-shipping discounts\r\n const grossTotal = this.total.subtotal + this.total.effectiveShipping;\r\n this.total.grandTotal = PriceModel.getRoundedPrice(Math.max(0, grossTotal - nonShippingCouponDiscount), this.country);\r\n }\r\n\r\n /**\r\n * Updates the shipping details (including estimated cost) for the container and recalculates totals.\r\n * @param details - The new ShippingDetails object, or null to clear shipping details and cost.\r\n */\r\n public setShippingDetails(details: ShippingDetails | null): void {\r\n // Store a copy of the details or null\r\n this.shippingDetails = details ? { ...details } : null;\r\n\r\n // Update the base shipping cost based on the new details\r\n this.total.shipping = PriceModel.getRoundedPrice(this.shippingDetails?.estimatedCost ?? 0, this.country);\r\n // Recalculate all totals as shipping cost affects effective shipping and grand total\r\n this.updateCartTotals();\r\n }\r\n\r\n\r\n /**\r\n * Gets a plain data object representing the shopping container's current state.\r\n * Includes details from the base model and specific container properties.\r\n * @returns BaseShoppingContainerData object suitable for serialization or API responses.\r\n */\r\n getDetails(): BaseShoppingContainerData {\r\n return {\r\n ...super.getDetails(),\r\n id: this.getId(),\r\n customerId: this.getCustomerId(),\r\n customerEmail: this.getCustomerEmail(),\r\n anonymousId: this.getAnonymousId(),\r\n lineItems: this.getLineItems().map(item => item.getDetails()),\r\n shippingDetails: this.getShippingDetails(),\r\n shippingAddress: this.getShippingAddress()?.getDetails() || null,\r\n billingAddress: this.getBillingAddress()?.getDetails() || null,\r\n coupons: this.getCoupons().map(coupon => coupon.getDetails()),\r\n total: this.getTotal(),\r\n country: this.getCountry(),\r\n currency: this.getCurrency(),\r\n locale: this.getLocale(),\r\n }\r\n };\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- import {e}from'./chunk-G6EL2Y7V.mjs';import {a as a$1}from'./chunk-ATUUYYQT.mjs';var a=(t=>(t.COUPON="coupon",t.AUTOMATIC="automatic",t))(a||{}),s=(t=>(t.FLAT="flat",t.PERCENTAGE="percentage",t))(s||{}),c=(t=>(t.SHIPPING="SHIPPING",t.CUSTOMER="CUSTOMER",t))(c||{}),u=(t=>(t.ALL="all",t.FTB="ftb",t))(u||{}),r=class extends a$1{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(e,t=new Date){super(e,t),this.couponCode=e.couponCode,this.name={...e.name},this.description={...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=e.minCartValue.map(i=>({...i})),this.maxCartDiscount=e.maxCartDiscount.map(i=>({...i})),this.discountMethod=e.discountMethod,this.percentageValue=e.percentageValue??0,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.find(t=>t.country===e):this.minCartValue}getMaxCartDiscount(e){return e?this.maxCartDiscount.find(t=>t.country===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:this.getMinCartValue(),maxCartDiscount:this.getMaxCartDiscount(),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}};export{a,s as b,c,u as d,r as e};//# sourceMappingURL=chunk-GTH5SKQK.mjs.map
2
- //# sourceMappingURL=chunk-GTH5SKQK.mjs.map
1
+ import {e}from'./chunk-6PDP4ETM.mjs';import {a as a$1}from'./chunk-ATUUYYQT.mjs';var a=(t=>(t.COUPON="coupon",t.AUTOMATIC="automatic",t))(a||{}),s=(t=>(t.FLAT="flat",t.PERCENTAGE="percentage",t))(s||{}),c=(t=>(t.SHIPPING="SHIPPING",t.CUSTOMER="CUSTOMER",t))(c||{}),u=(t=>(t.ALL="all",t.FTB="ftb",t))(u||{}),r=class extends a$1{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(e,t=new Date){super(e,t),this.couponCode=e.couponCode,this.name={...e.name},this.description={...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=e.minCartValue.map(i=>({...i})),this.maxCartDiscount=e.maxCartDiscount.map(i=>({...i})),this.discountMethod=e.discountMethod,this.percentageValue=e.percentageValue??0,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.find(t=>t.country===e):this.minCartValue}getMaxCartDiscount(e){return e?this.maxCartDiscount.find(t=>t.country===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:this.getMinCartValue(),maxCartDiscount:this.getMaxCartDiscount(),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}};export{a,s as b,c,u as d,r as e};//# sourceMappingURL=chunk-RWBNLNQ6.mjs.map
2
+ //# sourceMappingURL=chunk-RWBNLNQ6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Classes/Coupon.ts"],"names":["CouponType","CouponDiscountMethod","CouponCategory","ApplicableTo","CouponModel","BaseModel","data","date","price","locale","LocaleLanguageMap","country","ftbCustomer"],"mappings":"iFAIYA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,MAAS,CAAA,QAAA,CACTA,EAAA,SAAY,CAAA,WAAA,CAFFA,OAAA,EAKAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,IAAO,CAAA,MAAA,CACPA,EAAA,UAAa,CAAA,YAAA,CAFHA,OAAA,EAKAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,QAAW,CAAA,UAAA,CACXA,EAAA,QAAW,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,IAAA,CAAK,cACd,CAGA,kBAAA,EAA6B,CAC3B,OAAO,IAAA,CAAK,eACd,CAGA,eAAA,EAAgC,CAC9B,OAAO,IAAK,CAAA,YACd,CAGA,WAA8B,EAAA,CAC5B,OAAO,IAAK,CAAA,QACd,CAMA,UAAyB,EAAA,CACvB,OAAO,CACH,GAAG,MAAM,UAAW,EAAA,CACpB,WAAY,IAAK,CAAA,OAAA,GACjB,IAAM,CAAA,IAAA,CAAK,OAAQ,EAAA,CACnB,WAAa,CAAA,IAAA,CAAK,gBAClB,CAAA,IAAA,CAAM,KAAK,OAAQ,EAAA,CACnB,WAAY,IAAK,CAAA,aAAA,GACjB,SAAW,CAAA,IAAA,CAAK,cAChB,CAAA,OAAA,CAAS,KAAK,UAAW,EAAA,CACzB,aAAc,IAAK,CAAA,eAAA,EACnB,CAAA,eAAA,CAAiB,IAAK,CAAA,kBAAA,GACtB,cAAgB,CAAA,IAAA,CAAK,mBACrB,CAAA,eAAA,CAAiB,KAAK,kBAAmB,EAAA,CACzC,aAAc,IAAK,CAAA,eAAA,GACnB,QAAU,CAAA,IAAA,CAAK,aACnB,CACF,CAMA,QAAoB,EAAA,CAClB,OAAO,IAAI,IAAK,CAAA,IAAA,CAAK,SAAS,CAAK,EAAA,IAAI,MAAU,IAAI,IAAA,CAAK,KAAK,OAAO,CAAA,EAAK,IAAI,IACjF,CAQA,eAAeC,CAA+B,CAAA,CAC5C,OAAO,IAAK,CAAA,YAAA,GAAiB,OAAqB,IAAK,CAAA,YAAA,GAAiB,KAAoBA,EAAAA,CAC9F,CACF","file":"chunk-GTH5SKQK.mjs","sourcesContent":["import BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTime, LocaleCode, LocalizedString, RegionalPrice, RegionalPriceList } from \"./Common\";\r\nimport { LocaleLanguageMap } from \"./Enum\";\r\n\r\nexport enum CouponType {\r\n COUPON = \"coupon\",\r\n AUTOMATIC = \"automatic\",\r\n}\r\n\r\nexport enum CouponDiscountMethod {\r\n FLAT = \"flat\",\r\n PERCENTAGE = \"percentage\",\r\n}\r\n\r\nexport enum CouponCategory {\r\n SHIPPING = \"SHIPPING\",\r\n CUSTOMER = \"CUSTOMER\",\r\n}\r\n\r\nexport enum ApplicableTo {\r\n ALL = \"all\",\r\n FTB = \"ftb\",\r\n}\r\n\r\nexport type CouponAttribute = BaseAttributes & {\r\n couponCode: string;\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n type: CouponType;\r\n customerId?: string;\r\n validFrom: ISODateTime;\r\n validTo: ISODateTime;\r\n minCartValue: RegionalPriceList;\r\n maxCartDiscount: RegionalPriceList;\r\n discountMethod: CouponDiscountMethod;\r\n percentageValue?: number;\r\n applicableTo: ApplicableTo;\r\n category: CouponCategory;\r\n};\r\n\r\nexport type CouponData = Required<CouponAttribute>\r\n\r\n/**\r\n * Represents a discount coupon, extending BaseModel.\r\n */\r\nexport default class CouponModel extends BaseModel {\r\n protected couponCode: string;\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected type: CouponType;\r\n protected customerId?: string;\r\n protected validFrom: ISODateTime;\r\n protected validTo: ISODateTime;\r\n protected minCartValue: RegionalPriceList;\r\n protected maxCartDiscount: RegionalPriceList;\r\n protected discountMethod: CouponDiscountMethod;\r\n protected percentageValue: number;\r\n protected applicableTo: ApplicableTo;\r\n protected category: CouponCategory;\r\n\r\n /**\r\n * Creates an instance of CouponModel.\r\n * @param data - The initial coupon attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CouponAttribute, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.couponCode = data.couponCode;\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.type = data.type;\r\n this.customerId = data.customerId;\r\n this.validFrom = data.validFrom && Date.parse(data.validFrom) ? new Date(data.validFrom).toISOString() : date.toISOString();\r\n this.validTo = data.validTo && Date.parse(data.validTo) ? new Date(data.validTo).toISOString() : date.toISOString();\r\n this.minCartValue = data.minCartValue.map(price => ({ ...price }));\r\n this.maxCartDiscount = data.maxCartDiscount.map(price => ({ ...price }));\r\n this.discountMethod = data.discountMethod;\r\n this.percentageValue = data.percentageValue ?? 0;\r\n this.applicableTo = data.applicableTo;\r\n this.category = data.category;\r\n }\r\n\r\n /** Gets the unique coupon code. */\r\n getCode(): string {\r\n return this.couponCode;\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon 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 coupon name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return { ...this.name };\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon description object.\r\n * @returns A copy of the LocalizedString object for the description, or undefined.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the coupon description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return { ...this.description };\r\n }\r\n }\r\n\r\n /** Gets the type of coupon (COUPON or AUTOMATIC). */\r\n getType(): CouponType {\r\n return this.type;\r\n }\r\n\r\n /** Gets the specific customer ID this coupon is limited to, if any. */\r\n getCustomerId(): string {\r\n return this.customerId ?? '';\r\n }\r\n\r\n /** Gets the ISO date string from when the coupon is valid. */\r\n getValidFrom(): ISODateTime {\r\n return this.validFrom;\r\n }\r\n\r\n /** Gets the ISO date string until when the coupon is valid. */\r\n getValidTo(): ISODateTime {\r\n return this.validTo;\r\n }\r\n\r\n /**\r\n * Gets the list of minimum cart values required for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional minimum cart values.\r\n */\r\n getMinCartValue(): RegionalPriceList\r\n /**\r\n * Gets the minimum cart value required for the coupon for a specific country.\r\n * @param country - The country code to filter the minimum value for.\r\n * @returns The regional minimum cart value for the specified country, or undefined if not set for that country.\r\n */\r\n getMinCartValue(country: CountryCode): RegionalPrice | undefined\r\n getMinCartValue(country?: CountryCode){\r\n if(country) {\r\n return this.minCartValue.find(price => price.country === country);\r\n }\r\n return this.minCartValue;\r\n }\r\n\r\n /**\r\n * Gets the list of maximum discount amounts allowed for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional maximum discount caps.\r\n */\r\n getMaxCartDiscount(): RegionalPriceList\r\n /**\r\n * Gets the maximum discount amount allowed for the coupon for a specific country.\r\n * @param country - The country code to filter the maximum discount for.\r\n * @returns The regional maximum discount cap for the specified country, or undefined if not set for that country.\r\n */\r\n getMaxCartDiscount(country: CountryCode): RegionalPrice | undefined\r\n getMaxCartDiscount(country?: CountryCode){\r\n if(country) {\r\n return this.maxCartDiscount.find(price => price.country === country);\r\n }\r\n return this.maxCartDiscount;\r\n }\r\n\r\n /** Gets the discount method (FLAT or PERCENTAGE). */\r\n getDiscountMethod(): CouponDiscountMethod {\r\n return this.discountMethod;\r\n }\r\n\r\n /** Gets the percentage discount value (0-100). */\r\n getPercentageValue(): number {\r\n return this.percentageValue;\r\n }\r\n\r\n /** Gets the customer applicability rule (ALL or FTB). */\r\n getApplicableTo(): ApplicableTo {\r\n return this.applicableTo;\r\n }\r\n\r\n /** Gets the category of the coupon (SHIPPING or CUSTOMER). */\r\n getCategory(): CouponCategory {\r\n return this.category;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the coupon's details.\r\n * @returns A CouponData object.\r\n */\r\n getDetails(): CouponData {\r\n return {\r\n ...super.getDetails(),\r\n couponCode: this.getCode(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n type: this.getType(),\r\n customerId: this.getCustomerId(),\r\n validFrom: this.getValidFrom(),\r\n validTo: this.getValidTo(),\r\n minCartValue: this.getMinCartValue(),\r\n maxCartDiscount: this.getMaxCartDiscount(),\r\n discountMethod: this.getDiscountMethod(),\r\n percentageValue: this.getPercentageValue(),\r\n applicableTo: this.getApplicableTo(),\r\n category: this.getCategory(),\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the coupon is currently active based on its validity dates.\r\n * @returns True if the coupon is currently within its validity period, false otherwise.\r\n */\r\n isActive(): boolean {\r\n return new Date(this.validFrom) <= new Date() && new Date(this.validTo) >= new Date();\r\n }\r\n\r\n \r\n /**\r\n * Checks if the coupon is applicable to a customer based on their status (e.g., first-time buyer).\r\n * @param ftbCustomer - A boolean indicating whether the customer is a first-time buyer.\r\n * @returns True if the coupon's applicability rule matches the customer's status, false otherwise.\r\n */\r\n isApplicableTo(ftbCustomer: boolean): boolean {\r\n return this.applicableTo === ApplicableTo.ALL || (this.applicableTo === ApplicableTo.FTB && ftbCustomer);\r\n }\r\n}"]}
1
+ {"version":3,"sources":["../src/Classes/Coupon.ts"],"names":["CouponType","CouponDiscountMethod","CouponCategory","ApplicableTo","CouponModel","BaseModel","data","date","price","locale","LocaleLanguageMap","country","ftbCustomer"],"mappings":"iFAIYA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,MAAS,CAAA,QAAA,CACTA,EAAA,SAAY,CAAA,WAAA,CAFFA,OAAA,EAKAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,IAAO,CAAA,MAAA,CACPA,EAAA,UAAa,CAAA,YAAA,CAFHA,OAAA,EAKAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,QAAW,CAAA,UAAA,CACXA,EAAA,QAAW,CAAA,UAAA,CAFDA,OAAA,EAKAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,GAAM,CAAA,KAAA,C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CAAA,YACd,CAGA,WAA8B,EAAA,CAC5B,OAAO,IAAK,CAAA,QACd,CAMA,UAAyB,EAAA,CACvB,OAAO,CACH,GAAG,MAAM,UAAW,EAAA,CACpB,WAAY,IAAK,CAAA,OAAA,GACjB,IAAM,CAAA,IAAA,CAAK,OAAQ,EAAA,CACnB,WAAa,CAAA,IAAA,CAAK,gBAClB,CAAA,IAAA,CAAM,KAAK,OAAQ,EAAA,CACnB,WAAY,IAAK,CAAA,aAAA,GACjB,SAAW,CAAA,IAAA,CAAK,cAChB,CAAA,OAAA,CAAS,KAAK,UAAW,EAAA,CACzB,aAAc,IAAK,CAAA,eAAA,EACnB,CAAA,eAAA,CAAiB,IAAK,CAAA,kBAAA,GACtB,cAAgB,CAAA,IAAA,CAAK,mBACrB,CAAA,eAAA,CAAiB,KAAK,kBAAmB,EAAA,CACzC,aAAc,IAAK,CAAA,eAAA,GACnB,QAAU,CAAA,IAAA,CAAK,aACnB,CACF,CAMA,QAAoB,EAAA,CAClB,OAAO,IAAI,IAAK,CAAA,IAAA,CAAK,SAAS,CAAK,EAAA,IAAI,MAAU,IAAI,IAAA,CAAK,KAAK,OAAO,CAAA,EAAK,IAAI,IACjF,CAQA,eAAeC,CAA+B,CAAA,CAC5C,OAAO,IAAK,CAAA,YAAA,GAAiB,OAAqB,IAAK,CAAA,YAAA,GAAiB,KAAoBA,EAAAA,CAC9F,CACF","file":"chunk-RWBNLNQ6.mjs","sourcesContent":["import BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTime, LocaleCode, LocalizedString, RegionalPrice, RegionalPriceList } from \"./Common\";\r\nimport { LocaleLanguageMap } from \"./Enum\";\r\n\r\nexport enum CouponType {\r\n COUPON = \"coupon\",\r\n AUTOMATIC = \"automatic\",\r\n}\r\n\r\nexport enum CouponDiscountMethod {\r\n FLAT = \"flat\",\r\n PERCENTAGE = \"percentage\",\r\n}\r\n\r\nexport enum CouponCategory {\r\n SHIPPING = \"SHIPPING\",\r\n CUSTOMER = \"CUSTOMER\",\r\n}\r\n\r\nexport enum ApplicableTo {\r\n ALL = \"all\",\r\n FTB = \"ftb\",\r\n}\r\n\r\nexport type CouponAttribute = BaseAttributes & {\r\n couponCode: string;\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n type: CouponType;\r\n customerId?: string;\r\n validFrom: ISODateTime;\r\n validTo: ISODateTime;\r\n minCartValue: RegionalPriceList;\r\n maxCartDiscount: RegionalPriceList;\r\n discountMethod: CouponDiscountMethod;\r\n percentageValue?: number;\r\n applicableTo: ApplicableTo;\r\n category: CouponCategory;\r\n};\r\n\r\nexport type CouponData = Required<CouponAttribute>\r\n\r\n/**\r\n * Represents a discount coupon, extending BaseModel.\r\n */\r\nexport default class CouponModel extends BaseModel {\r\n protected couponCode: string;\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected type: CouponType;\r\n protected customerId?: string;\r\n protected validFrom: ISODateTime;\r\n protected validTo: ISODateTime;\r\n protected minCartValue: RegionalPriceList;\r\n protected maxCartDiscount: RegionalPriceList;\r\n protected discountMethod: CouponDiscountMethod;\r\n protected percentageValue: number;\r\n protected applicableTo: ApplicableTo;\r\n protected category: CouponCategory;\r\n\r\n /**\r\n * Creates an instance of CouponModel.\r\n * @param data - The initial coupon attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CouponAttribute, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.couponCode = data.couponCode;\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.type = data.type;\r\n this.customerId = data.customerId;\r\n this.validFrom = data.validFrom && Date.parse(data.validFrom) ? new Date(data.validFrom).toISOString() : date.toISOString();\r\n this.validTo = data.validTo && Date.parse(data.validTo) ? new Date(data.validTo).toISOString() : date.toISOString();\r\n this.minCartValue = data.minCartValue.map(price => ({ ...price }));\r\n this.maxCartDiscount = data.maxCartDiscount.map(price => ({ ...price }));\r\n this.discountMethod = data.discountMethod;\r\n this.percentageValue = data.percentageValue ?? 0;\r\n this.applicableTo = data.applicableTo;\r\n this.category = data.category;\r\n }\r\n\r\n /** Gets the unique coupon code. */\r\n getCode(): string {\r\n return this.couponCode;\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon 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 coupon name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return { ...this.name };\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon description object.\r\n * @returns A copy of the LocalizedString object for the description, or undefined.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the coupon description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return { ...this.description };\r\n }\r\n }\r\n\r\n /** Gets the type of coupon (COUPON or AUTOMATIC). */\r\n getType(): CouponType {\r\n return this.type;\r\n }\r\n\r\n /** Gets the specific customer ID this coupon is limited to, if any. */\r\n getCustomerId(): string {\r\n return this.customerId ?? '';\r\n }\r\n\r\n /** Gets the ISO date string from when the coupon is valid. */\r\n getValidFrom(): ISODateTime {\r\n return this.validFrom;\r\n }\r\n\r\n /** Gets the ISO date string until when the coupon is valid. */\r\n getValidTo(): ISODateTime {\r\n return this.validTo;\r\n }\r\n\r\n /**\r\n * Gets the list of minimum cart values required for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional minimum cart values.\r\n */\r\n getMinCartValue(): RegionalPriceList\r\n /**\r\n * Gets the minimum cart value required for the coupon for a specific country.\r\n * @param country - The country code to filter the minimum value for.\r\n * @returns The regional minimum cart value for the specified country, or undefined if not set for that country.\r\n */\r\n getMinCartValue(country: CountryCode): RegionalPrice | undefined\r\n getMinCartValue(country?: CountryCode){\r\n if(country) {\r\n return this.minCartValue.find(price => price.country === country);\r\n }\r\n return this.minCartValue;\r\n }\r\n\r\n /**\r\n * Gets the list of maximum discount amounts allowed for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional maximum discount caps.\r\n */\r\n getMaxCartDiscount(): RegionalPriceList\r\n /**\r\n * Gets the maximum discount amount allowed for the coupon for a specific country.\r\n * @param country - The country code to filter the maximum discount for.\r\n * @returns The regional maximum discount cap for the specified country, or undefined if not set for that country.\r\n */\r\n getMaxCartDiscount(country: CountryCode): RegionalPrice | undefined\r\n getMaxCartDiscount(country?: CountryCode){\r\n if(country) {\r\n return this.maxCartDiscount.find(price => price.country === country);\r\n }\r\n return this.maxCartDiscount;\r\n }\r\n\r\n /** Gets the discount method (FLAT or PERCENTAGE). */\r\n getDiscountMethod(): CouponDiscountMethod {\r\n return this.discountMethod;\r\n }\r\n\r\n /** Gets the percentage discount value (0-100). */\r\n getPercentageValue(): number {\r\n return this.percentageValue;\r\n }\r\n\r\n /** Gets the customer applicability rule (ALL or FTB). */\r\n getApplicableTo(): ApplicableTo {\r\n return this.applicableTo;\r\n }\r\n\r\n /** Gets the category of the coupon (SHIPPING or CUSTOMER). */\r\n getCategory(): CouponCategory {\r\n return this.category;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the coupon's details.\r\n * @returns A CouponData object.\r\n */\r\n getDetails(): CouponData {\r\n return {\r\n ...super.getDetails(),\r\n couponCode: this.getCode(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n type: this.getType(),\r\n customerId: this.getCustomerId(),\r\n validFrom: this.getValidFrom(),\r\n validTo: this.getValidTo(),\r\n minCartValue: this.getMinCartValue(),\r\n maxCartDiscount: this.getMaxCartDiscount(),\r\n discountMethod: this.getDiscountMethod(),\r\n percentageValue: this.getPercentageValue(),\r\n applicableTo: this.getApplicableTo(),\r\n category: this.getCategory(),\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the coupon is currently active based on its validity dates.\r\n * @returns True if the coupon is currently within its validity period, false otherwise.\r\n */\r\n isActive(): boolean {\r\n return new Date(this.validFrom) <= new Date() && new Date(this.validTo) >= new Date();\r\n }\r\n\r\n \r\n /**\r\n * Checks if the coupon is applicable to a customer based on their status (e.g., first-time buyer).\r\n * @param ftbCustomer - A boolean indicating whether the customer is a first-time buyer.\r\n * @returns True if the coupon's applicability rule matches the customer's status, false otherwise.\r\n */\r\n isApplicableTo(ftbCustomer: boolean): boolean {\r\n return this.applicableTo === ApplicableTo.ALL || (this.applicableTo === ApplicableTo.FTB && ftbCustomer);\r\n }\r\n}"]}
@@ -1,2 +1,2 @@
1
- import {g,h}from'./chunk-G6EL2Y7V.mjs';var s=class i{price;country;constructor(r,e){if(this.country=e,r<0)throw new Error("InvalidPrice: Price cannot be negative.");this.price=r;}getCountry(){return this.country}getRoundedPrice(){return i.getRoundedPrice(this.price,this.country)}getFormattedString(r){return i.getFormattedString(this.price,this.country,r)}static getFormattedString(r,e,o,t={}){let c=t.displayAsInteger??!1,n=g[e];if(n===void 0)throw new Error("Currency mapping not found for CountryCode");let a=r,d=c?0:i.getDecimalPlaces(n),y={style:t.style??"currency",currency:n,signDisplay:"never",currencyDisplay:t.currencyDisplay,minimumFractionDigits:d,maximumFractionDigits:d};c&&(a=Math.round(a));try{return new Intl.NumberFormat(o,y).format(a)}catch(m){return console.error(`Error formatting price for country "${e}" and currency "${n}":`,m),`${h[n]??n} ${i.addThousandSeparators(a.toFixed(d))}`}}static getDecimalPlaces(r){switch(r){case"INR":default:return 2}}static addThousandSeparators(r){let e=r.split("."),o=e[0],t=e.length>1?"."+e[1]:"";return o.replace(/\B(?=(\d{3})+(?!\d))/g,",")+t}static getRoundedPrice(r,e){if(r<0)throw new Error("Price cannot be negative for rounding.");let o=g[e];if(o===void 0)throw new Error(`Currency mapping not found for CountryCode: ${e}`);let t=i.getDecimalPlaces(o),c=Math.pow(10,t);return Math.round(r*c)/c}static getCurrency(r){return g[r]}};export{s as a};//# sourceMappingURL=chunk-DJHX4EUG.mjs.map
2
- //# sourceMappingURL=chunk-DJHX4EUG.mjs.map
1
+ import {g,h}from'./chunk-6PDP4ETM.mjs';var s=class i{price;country;constructor(r,e){if(this.country=e,r<0)throw new Error("InvalidPrice: Price cannot be negative.");this.price=r;}getCountry(){return this.country}getRoundedPrice(){return i.getRoundedPrice(this.price,this.country)}getFormattedString(r){return i.getFormattedString(this.price,this.country,r)}static getFormattedString(r,e,o,t={}){let c=t.displayAsInteger??!1,n=g[e];if(n===void 0)throw new Error("Currency mapping not found for CountryCode");let a=r,d=c?0:i.getDecimalPlaces(n),y={style:t.style??"currency",currency:n,signDisplay:"never",currencyDisplay:t.currencyDisplay,minimumFractionDigits:d,maximumFractionDigits:d};c&&(a=Math.round(a));try{return new Intl.NumberFormat(o,y).format(a)}catch(m){return console.error(`Error formatting price for country "${e}" and currency "${n}":`,m),`${h[n]??n} ${i.addThousandSeparators(a.toFixed(d))}`}}static getDecimalPlaces(r){switch(r){case"INR":default:return 2}}static addThousandSeparators(r){let e=r.split("."),o=e[0],t=e.length>1?"."+e[1]:"";return o.replace(/\B(?=(\d{3})+(?!\d))/g,",")+t}static getRoundedPrice(r,e){if(r<0)throw new Error("Price cannot be negative for rounding.");let o=g[e];if(o===void 0)throw new Error(`Currency mapping not found for CountryCode: ${e}`);let t=i.getDecimalPlaces(o),c=Math.pow(10,t);return Math.round(r*c)/c}static getCurrency(r){return g[r]}};export{s as a};//# sourceMappingURL=chunk-V4H3X4PI.mjs.map
2
+ //# sourceMappingURL=chunk-V4H3X4PI.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Classes/Price.ts"],"names":["PriceModel","_PriceModel","price","country","locale","options","displayAsInteger","currency","CountryCurrencyMap","valueToFormat","fractionDigits","formattingOptions","error","CurrencySymbolMap","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier"],"mappings":"uCAGA,IAAqBA,CAArB,CAAA,MAAqBC,CAAW,CACpB,KACA,CAAA,OAAA,CAQV,WAAYC,CAAAA,CAAAA,CAAeC,CAAsB,CAAA,CAG/C,GAFA,IAAA,CAAK,OAAUA,CAAAA,CAAAA,CAEZD,CAAQ,CAAA,CAAA,CACT,MAAM,IAAI,KAAM,CAAA,yCAAyC,CAG3D,CAAA,IAAA,CAAK,KAAQA,CAAAA,EACf,CAOO,UAAA,EAA0B,CAC/B,OAAO,IAAK,CAAA,OACd,CAMO,eAAA,EAA0B,CAC/B,OAAOD,CAAW,CAAA,eAAA,CAAgB,IAAK,CAAA,KAAA,CAAO,IAAK,CAAA,OAAO,CAC5D,CASO,kBAAmBG,CAAAA,CAAAA,CAAmB,CAC3C,OAAOH,CAAW,CAAA,kBAAA,CAAmB,IAAK,CAAA,KAAA,CAAO,IAAK,CAAA,OAAA,CAASG,CAAM,CACvE,CAcA,OAAO,kBAAmBF,CAAAA,CAAAA,CAAeC,CAAsBC,CAAAA,CAAAA,CAAqBC,EAAyI,EAAC,CAAW,CACvO,IAAMC,CAAmBD,CAAAA,CAAAA,CAAQ,gBAAoB,EAAA,CAAA,CAAA,CAC/CE,CAAqCC,CAAAA,CAAAA,CAAmBL,CAAO,CAAA,CAErE,GAAII,CAAAA,GAAa,KACf,CAAA,CAAA,MAAM,IAAI,KAAA,CAAM,4CAA4C,CAAA,CAG9D,IAAIE,CAAAA,CAAgBP,CACdQ,CAAAA,CAAAA,CAAiBJ,CAAmB,CAAA,CAAA,CAAIL,CAAW,CAAA,gBAAA,CAAiBM,CAAQ,CAAA,CAE9EI,CAA8C,CAAA,CAC9C,KAAON,CAAAA,CAAAA,CAAQ,KAAS,EAAA,UAAA,CACxB,QAAUE,CAAAA,CAAAA,CACV,WAAa,CAAA,OAAA,CACb,eAAiBF,CAAAA,CA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AmBL,CAAAA,CAAO,CACrE,CAAA,GAAII,CAAa,GAAA,KAAA,CAAA,CACf,MAAM,IAAI,KAAM,CAAA,CAAA,4CAAA,EAA+CJ,CAAO,CAAA,CAAE,CAG1E,CAAA,IAAMe,CAAgBjB,CAAAA,CAAAA,CAAW,gBAAiBM,CAAAA,CAAQ,CACpDY,CAAAA,CAAAA,CAAa,IAAK,CAAA,GAAA,CAAI,EAAID,CAAAA,CAAa,CAG7C,CAAA,OAFqB,IAAK,CAAA,KAAA,CAAMhB,CAAQiB,CAAAA,CAAU,CAAIA,CAAAA,CAGxD,CASA,OAAO,WAAYhB,CAAAA,CAAAA,CAA8B,CAC/C,OAAOK,CAAmBL,CAAAA,CAAO,CACnC,CAEF","file":"chunk-DJHX4EUG.mjs","sourcesContent":["import { CountryCode, CurrencyCode, LocaleCode } from \"./Common\"; // Assuming these are in Common.ts\r\nimport { CountryCurrencyMap, CurrencySymbolMap } from \"./Enum\"; // Ensure these maps exist\r\n\r\nexport default class PriceModel {\r\n protected price: number;\r\n protected country: CountryCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param price - The initial price value.\r\n * @param country - The country code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(price: number, country: CountryCode) {\r\n this.country = country;\r\n\r\n if(price < 0) {\r\n throw new Error(\"InvalidPrice: Price cannot be negative.\");\r\n }\r\n\r\n this.price = price\r\n }\r\n\r\n /**\r\n * Gets the country code associated with this price instance.\r\n * The country code is used for determining currency and formatting rules.\r\n * @returns The CountryCode enum value.\r\n */\r\n public getCountry(): CountryCode {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedPrice(): number {\r\n return PriceModel.getRoundedPrice(this.price, this.country);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price stored in this instance.\r\n * Uses the static `PriceModel.getFormattedString` method for the actual formatting.\r\n * @param locale - The locale code (e.g., 'en-IN') to use for formatting rules.\r\n * @returns The formatted price string according to locale rules.\r\n * @throws {Error} If the currency mapping for the instance's country is not found (via the static method).\r\n */\r\n public getFormattedString(locale: LocaleCode){\r\n return PriceModel.getFormattedString(this.price, this.country, locale);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param price - The initial price value.\r\n * @param country - The country code used for rounding and determining the currency symbol.\r\n * @param locale - The locale code (e.g., 'en-IN') to use for formatting rules.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the price rounded to the nearest integer (no decimals). Defaults to false.\r\n * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.\r\n * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n static getFormattedString(price: number, country: CountryCode, locale?: LocaleCode, options: { displayAsInteger?: boolean, style?: 'currency' | 'decimal', currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name' } = {}): string {\r\n const displayAsInteger = options.displayAsInteger ?? false;\r\n const currency: CurrencyCode | undefined = CountryCurrencyMap[country];\r\n\r\n if (currency === undefined) {\r\n throw new Error('Currency mapping not found for CountryCode');\r\n }\r\n\r\n let valueToFormat = price;\r\n const fractionDigits = displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: options.style ?? 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (displayAsInteger) {\r\n valueToFormat = Math.round(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for country \"${country}\" and currency \"${currency}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case 'INR':\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param country - The country code to determine the currency and rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the country code is not found in the CountryCurrencyMap or price is negative.\r\n */\r\n static getRoundedPrice(price: number, country: CountryCode): number {\r\n if (price < 0) {\r\n throw new Error(\"Price cannot be negative for rounding.\");\r\n }\r\n\r\n const currency: CurrencyCode | undefined = CountryCurrencyMap[country];\r\n if (currency === undefined) {\r\n throw new Error(`Currency mapping not found for CountryCode: ${country}`);\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(price * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n\r\n /**\r\n * Static method to retrieve the currency code associated with a given country code.\r\n * Uses the `CountryCurrencyMap` to find the corresponding currency.\r\n *\r\n * @param country - The country code (e.g., 'IN') for which to find the currency.\r\n * @returns The currency code (e.g., 'INR') as a string, or undefined if the mapping doesn't exist.\r\n */\r\n static getCurrency(country: CountryCode): string {\r\n return CountryCurrencyMap[country];\r\n }\r\n\r\n}"]}
1
+ {"version":3,"sources":["../src/Classes/Price.ts"],"names":["PriceModel","_PriceModel","price","country","locale","options","displayAsInteger","currency","CountryCurrencyMap","valueToFormat","fractionDigits","formattingOptions","error","CurrencySymbolMap","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier"],"mappings":"uCAGA,IAAqBA,CAArB,CAAA,MAAqBC,CAAW,CACpB,KACA,CAAA,OAAA,CAQV,WAAYC,CAAAA,CAAAA,CAAeC,CAAsB,CAAA,CAG/C,GAFA,IAAA,CAAK,OAAUA,CAAAA,CAAAA,CAEZD,CAAQ,CAAA,CAAA,CACT,MAAM,IAAI,KAAM,CAAA,yCAAyC,CAG3D,CAAA,IAAA,CAAK,KAAQA,CAAAA,EACf,CAOO,UAAA,EAA0B,CAC/B,OAAO,IAAK,CAAA,OACd,CAMO,eAAA,EAA0B,CAC/B,OAAOD,CAAW,CAAA,eAAA,CAAgB,IAAK,CAAA,KAAA,CAAO,IAAK,CAAA,OAAO,CAC5D,CASO,kBAAmBG,CAAAA,CAAAA,CAAmB,CAC3C,OAAOH,CAAW,CAAA,kBAAA,CAAmB,IAAK,CAAA,KAAA,CAAO,IAAK,CAAA,OAAA,CAASG,CAAM,CACvE,CAcA,OAAO,kBAAmBF,CAAAA,CAAAA,CAAeC,CAAsBC,CAAAA,CAAAA,CAAqBC,EAAyI,EAAC,CAAW,CACvO,IAAMC,CAAmBD,CAAAA,CAAAA,CAAQ,gBAAoB,EAAA,CAAA,CAAA,CAC/CE,CAAqCC,CAAAA,CAAAA,CAAmBL,CAAO,CAAA,CAErE,GAAII,CAAAA,G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AA,CAAcF,CAAM,CAAA,MAAA,CAAS,CAAI,CAAA,GAAA,CAAMA,CAAM,CAAA,CAAC,EAAI,EAGxD,CAAA,OADyBC,CAAY,CAAA,OAAA,CAAQ,uBAAyB,CAAA,GAAG,CAC/CC,CAAAA,CAC5B,CAWA,OAAO,eAAgBf,CAAAA,CAAAA,CAAeC,CAA8B,CAAA,CAClE,GAAID,CAAAA,CAAQ,CACV,CAAA,MAAM,IAAI,KAAA,CAAM,wCAAwC,CAAA,CAG1D,IAAMK,CAAAA,CAAqCC,CAAmBL,CAAAA,CAAO,CACrE,CAAA,GAAII,CAAa,GAAA,KAAA,CAAA,CACf,MAAM,IAAI,KAAM,CAAA,CAAA,4CAAA,EAA+CJ,CAAO,CAAA,CAAE,CAG1E,CAAA,IAAMe,CAAgBjB,CAAAA,CAAAA,CAAW,gBAAiBM,CAAAA,CAAQ,CACpDY,CAAAA,CAAAA,CAAa,IAAK,CAAA,GAAA,CAAI,EAAID,CAAAA,CAAa,CAG7C,CAAA,OAFqB,IAAK,CAAA,KAAA,CAAMhB,CAAQiB,CAAAA,CAAU,CAAIA,CAAAA,CAGxD,CASA,OAAO,WAAYhB,CAAAA,CAAAA,CAA8B,CAC/C,OAAOK,CAAmBL,CAAAA,CAAO,CACnC,CAEF","file":"chunk-V4H3X4PI.mjs","sourcesContent":["import { CountryCode, CurrencyCode, LocaleCode } from \"./Common\"; // Assuming these are in Common.ts\r\nimport { CountryCurrencyMap, CurrencySymbolMap } from \"./Enum\"; // Ensure these maps exist\r\n\r\nexport default class PriceModel {\r\n protected price: number;\r\n protected country: CountryCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param price - The initial price value.\r\n * @param country - The country code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(price: number, country: CountryCode) {\r\n this.country = country;\r\n\r\n if(price < 0) {\r\n throw new Error(\"InvalidPrice: Price cannot be negative.\");\r\n }\r\n\r\n this.price = price\r\n }\r\n\r\n /**\r\n * Gets the country code associated with this price instance.\r\n * The country code is used for determining currency and formatting rules.\r\n * @returns The CountryCode enum value.\r\n */\r\n public getCountry(): CountryCode {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedPrice(): number {\r\n return PriceModel.getRoundedPrice(this.price, this.country);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price stored in this instance.\r\n * Uses the static `PriceModel.getFormattedString` method for the actual formatting.\r\n * @param locale - The locale code (e.g., 'en-IN') to use for formatting rules.\r\n * @returns The formatted price string according to locale rules.\r\n * @throws {Error} If the currency mapping for the instance's country is not found (via the static method).\r\n */\r\n public getFormattedString(locale: LocaleCode){\r\n return PriceModel.getFormattedString(this.price, this.country, locale);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param price - The initial price value.\r\n * @param country - The country code used for rounding and determining the currency symbol.\r\n * @param locale - The locale code (e.g., 'en-IN') to use for formatting rules.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the price rounded to the nearest integer (no decimals). Defaults to false.\r\n * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.\r\n * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n static getFormattedString(price: number, country: CountryCode, locale?: LocaleCode, options: { displayAsInteger?: boolean, style?: 'currency' | 'decimal', currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name' } = {}): string {\r\n const displayAsInteger = options.displayAsInteger ?? false;\r\n const currency: CurrencyCode | undefined = CountryCurrencyMap[country];\r\n\r\n if (currency === undefined) {\r\n throw new Error('Currency mapping not found for CountryCode');\r\n }\r\n\r\n let valueToFormat = price;\r\n const fractionDigits = displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: options.style ?? 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (displayAsInteger) {\r\n valueToFormat = Math.round(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for country \"${country}\" and currency \"${currency}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case 'INR':\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param country - The country code to determine the currency and rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the country code is not found in the CountryCurrencyMap or price is negative.\r\n */\r\n static getRoundedPrice(price: number, country: CountryCode): number {\r\n if (price < 0) {\r\n throw new Error(\"Price cannot be negative for rounding.\");\r\n }\r\n\r\n const currency: CurrencyCode | undefined = CountryCurrencyMap[country];\r\n if (currency === undefined) {\r\n throw new Error(`Currency mapping not found for CountryCode: ${country}`);\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(price * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n\r\n /**\r\n * Static method to retrieve the currency code associated with a given country code.\r\n * Uses the `CountryCurrencyMap` to find the corresponding currency.\r\n *\r\n * @param country - The country code (e.g., 'IN') for which to find the currency.\r\n * @returns The currency code (e.g., 'INR') as a string, or undefined if the mapping doesn't exist.\r\n */\r\n static getCurrency(country: CountryCode): string {\r\n return CountryCurrencyMap[country];\r\n }\r\n\r\n}"]}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var M=require('crypto'),j=require('util');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var M__default=/*#__PURE__*/_interopDefault(M);var j__default=/*#__PURE__*/_interopDefault(j);var I=(e=>(e.IN="IN",e))(I||{}),T=(e=>(e.INR="INR",e))(T||{}),$=(t=>(t["en-IN"]="en-IN",t["ka-IN"]="ka-IN",t))($||{});var U={$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:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},variantId:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},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(I)},currency:{type:"string",enum:Object.values(T)},locale:{type:"string",enum:Object.values($)},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},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 F={getStandardSchemaDefinition(){return U}},P=F;var m=new Uint8Array(256),x=m.length;function S(){return x>m.length-16&&(M__default.default.randomFillSync(m),x=0),m.slice(x,x+=16)}var L=/^(?:[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 K(t){return typeof t=="string"&&L.test(t)}var h=K;var o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function N(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}function w(t){if(!h(t))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}var D=w;function b(t){t=unescape(encodeURIComponent(t));let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}var C="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Y="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function O(t,e,r){function i(a,d,u,y){var n;if(typeof a=="string"&&(a=b(a)),typeof d=="string"&&(d=D(d)),((n=d)===null||n===void 0?void 0:n.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let p=new Uint8Array(16+a.length);if(p.set(d),p.set(a,d.length),p=r(p),p[6]=p[6]&15|e,p[8]=p[8]&63|128,u){y=y||0;for(let f=0;f<16;++f)u[y+f]=p[f];return u}return N(p)}try{i.name=t;}catch{}return i.DNS=C,i.URL=Y,i}var _={randomUUID:M__default.default.randomUUID};function k(t,e,r){if(_.randomUUID&&!e&&!t)return _.randomUUID();t=t||{};let i=t.random||(t.rng||S)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){r=r||0;for(let a=0;a<16;++a)e[r+a]=i[a];return e}return N(i)}var A=k;function H(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),M__default.default.createHash("sha1").update(t).digest()}var v=H;var q=O("v5",80,v),R=q;var z={isUUID:t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t),isEmail:t=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t),isURL:t=>/^(http|https):\/\/[^ "]+$/.test(t),generateUUID:(t,e)=>e&&t?R(t,e):A(),generateSearchId:(t,e)=>`${t}#${e}`,getKeyfromSearchId:t=>{let[e,r]=t.split("#");return {key:e,variantId:r}}},W=z;var g=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 c={logException:(t,e)=>{console.error(`Exception Occurred in Function: ${t}, Error: ${c.inspect(e)}`);},logError:(t,e)=>{console.error(`Error Occurred in Function: ${t}, Error: ${c.inspect(e)}`);},logWarning:(t,e)=>{console.warn(`Warning in Function: ${t} - ${c.inspect(e)}`);},logMessage:(t,e)=>{console.log(`Message in Function: ${t} - ${c.inspect(e)}`);},logInvalidPayload:(t,e)=>{console.error(`Invalid Payload received for Function: ${t}, Error: ${c.inspect(e)}`);},inspect:t=>typeof t=="string"?t:j__default.default.inspect(t)},l=c;var J={handleException:(t,e,r)=>{e.knownError?(e.logError&&l.logError(t,e),r.status(e.status).json({status:e.status,error:e.error})):e.status&&e.error?(l.logException(t,e),r.status(e.status).json({error:e.errorMessage||JSON.stringify(e.error),status:e.status})):(l.logException(t,e),r.status(500).json({status:500,error:g.INTERNAL_SERVER_ERROR}));},generateResponse:(t,e,r)=>({status:t,data:e,error:r}),generateError:(t,e,r=!0,i=!1)=>({status:t,error:e,knownError:r,logError:i})},G=J;var Z=async(t,e,r="GET",i={},a)=>{let d={method:r,headers:{"Content-Type":"application/json",...i}};r!=="GET"&&a&&(d.body=JSON.stringify(a));let u=`${t}${e?"/"+e:""}`,y=u.includes("api.xetile.com")||u.includes("localhost");try{let n=await fetch(u,d);if(!n.ok){let f,E=await n.text();try{f=JSON.parse(E);}catch{f={status:n.status,error:E||n.statusText},l.logWarning("Fetch",`Failed to parse error response body as JSON for URL-${u}. Raw text: ${E}`);}throw {status:n.status,statusText:n.statusText,error:f}}let p=await n.json();return l.logMessage("Fetch",`API call successful: URL-${u}, Status- ${n.status}`),{status:n.status,statusText:n.statusText,data:y?p.data:p}}catch(n){throw l.logError("Fetch",`API call failed: URL-${u}, Status- ${n.status||500}, Error- ${l.inspect(n.error||n)}`),{status:n.status||500,statusText:n.statusText||g.INTERNAL_SERVER_ERROR,error:n.error||{status:n.status||500,error:n.statusText||g.SOMETHING_WENT_WRONG}}}},X=Z;
1
+ 'use strict';var M=require('crypto'),j=require('util');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var M__default=/*#__PURE__*/_interopDefault(M);var j__default=/*#__PURE__*/_interopDefault(j);var I=(e=>(e.IN="IN",e))(I||{}),T=(e=>(e.INR="INR",e))(T||{}),$=(t=>(t["en-IN"]="en-IN",t["kn-IN"]="kn-IN",t))($||{});var U={$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:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},variantId:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},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(I)},currency:{type:"string",enum:Object.values(T)},locale:{type:"string",enum:Object.values($)},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},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 F={getStandardSchemaDefinition(){return U}},P=F;var m=new Uint8Array(256),x=m.length;function S(){return x>m.length-16&&(M__default.default.randomFillSync(m),x=0),m.slice(x,x+=16)}var L=/^(?:[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 K(t){return typeof t=="string"&&L.test(t)}var h=K;var o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function N(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}function w(t){if(!h(t))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}var D=w;function b(t){t=unescape(encodeURIComponent(t));let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}var C="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Y="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function O(t,e,r){function i(a,d,u,y){var n;if(typeof a=="string"&&(a=b(a)),typeof d=="string"&&(d=D(d)),((n=d)===null||n===void 0?void 0:n.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let p=new Uint8Array(16+a.length);if(p.set(d),p.set(a,d.length),p=r(p),p[6]=p[6]&15|e,p[8]=p[8]&63|128,u){y=y||0;for(let f=0;f<16;++f)u[y+f]=p[f];return u}return N(p)}try{i.name=t;}catch{}return i.DNS=C,i.URL=Y,i}var _={randomUUID:M__default.default.randomUUID};function k(t,e,r){if(_.randomUUID&&!e&&!t)return _.randomUUID();t=t||{};let i=t.random||(t.rng||S)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){r=r||0;for(let a=0;a<16;++a)e[r+a]=i[a];return e}return N(i)}var A=k;function H(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),M__default.default.createHash("sha1").update(t).digest()}var v=H;var q=O("v5",80,v),R=q;var z={isUUID:t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t),isEmail:t=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(t),isURL:t=>/^(http|https):\/\/[^ "]+$/.test(t),generateUUID:(t,e)=>e&&t?R(t,e):A(),generateSearchId:(t,e)=>`${t}#${e}`,getKeyfromSearchId:t=>{let[e,r]=t.split("#");return {key:e,variantId:r}}},W=z;var g=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 c={logException:(t,e)=>{console.error(`Exception Occurred in Function: ${t}, Error: ${c.inspect(e)}`);},logError:(t,e)=>{console.error(`Error Occurred in Function: ${t}, Error: ${c.inspect(e)}`);},logWarning:(t,e)=>{console.warn(`Warning in Function: ${t} - ${c.inspect(e)}`);},logMessage:(t,e)=>{console.log(`Message in Function: ${t} - ${c.inspect(e)}`);},logInvalidPayload:(t,e)=>{console.error(`Invalid Payload received for Function: ${t}, Error: ${c.inspect(e)}`);},inspect:t=>typeof t=="string"?t:j__default.default.inspect(t)},l=c;var J={handleException:(t,e,r)=>{e.knownError?(e.logError&&l.logError(t,e),r.status(e.status).json({status:e.status,error:e.error})):e.status&&e.error?(l.logException(t,e),r.status(e.status).json({error:e.errorMessage||JSON.stringify(e.error),status:e.status})):(l.logException(t,e),r.status(500).json({status:500,error:g.INTERNAL_SERVER_ERROR}));},generateResponse:(t,e,r)=>({status:t,data:e,error:r}),generateError:(t,e,r=!0,i=!1)=>({status:t,error:e,knownError:r,logError:i})},G=J;var Z=async(t,e,r="GET",i={},a)=>{let d={method:r,headers:{"Content-Type":"application/json",...i}};r!=="GET"&&a&&(d.body=JSON.stringify(a));let u=`${t}${e?"/"+e:""}`,y=u.includes("api.xetile.com")||u.includes("localhost");try{let n=await fetch(u,d);if(!n.ok){let f,E=await n.text();try{f=JSON.parse(E);}catch{f={status:n.status,error:E||n.statusText},l.logWarning("Fetch",`Failed to parse error response body as JSON for URL-${u}. Raw text: ${E}`);}throw {status:n.status,statusText:n.statusText,error:f}}let p=await n.json();return l.logMessage("Fetch",`API call successful: URL-${u}, Status- ${n.status}`),{status:n.status,statusText:n.statusText,data:y?p.data:p}}catch(n){throw l.logError("Fetch",`API call failed: URL-${u}, Status- ${n.status||500}, Error- ${l.inspect(n.error||n)}`),{status:n.status||500,statusText:n.statusText||g.INTERNAL_SERVER_ERROR,error:n.error||{status:n.status||500,error:n.statusText||g.SOMETHING_WENT_WRONG}}}},X=Z;
2
2
  exports.Fetch=X;exports.Logger=l;exports.ResponseUtility=G;exports.Schema=P;exports.Utils=W;//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Classes/Enum.ts","../src/Schema/definition.ts","../src/Schema/index.ts","../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Utils/index.ts","../src/enums/ErrorTypes.ts","../src/Logger/index.ts","../src/Utils/response.ts","../src/Utils/fetch.ts"],"names":["OperationalCountry","OperationalCountryCurrency","OperationalLocale","definition_default","Schema","Schema_default","rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","v","parse_default","stringToBytes","str","bytes","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","_namespace","native_default","v4","options","rnds","v4_default","sha1","sha1_default","v5","v5_default","Utils","key","variantId","searchId","Utils_default","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","completeURL","isInternalAPI","response","errorBody","errorText","body","err","fetch_default"],"mappings":"sNAGO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,EAAK,CAAA,IAAA,CADRA,OAAA,EAIAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,GAAM,CAAA,KAAA,CADTA,OAAA,EAIAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,OAAU,CAAA,CAAA,OAAA,CACCA,EAAA,OAAU,CAAA,CAAA,OAAA,CAFxBA,OAAA,ECTZ,CAAA,CAAA,IAA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AAAA,CAAAA,CAAS,UACjC,CACAhB,CAAAA,CAAAA,CAAO,UAAW,CAAA,OAAA,CAAS,CAAuDc,oDAAAA,EAAAA,CAAW,eAAeI,CAAS,CAAA,CAAE,EACzH,CAEA,MAAM,CACJ,MAAQF,CAAAA,CAAAA,CAAS,OACjB,UAAYA,CAAAA,CAAAA,CAAS,WACrB,KAAOC,CAAAA,CACT,CACF,CAEA,IAAME,EAAO,MAAMH,CAAAA,CAAS,MAE5B,CAAA,OAAAhB,EAAO,UAAW,CAAA,OAAA,CAAS,4BAA4Bc,CAAW,CAAA,UAAA,EAAaE,EAAS,MAAM,CAAA,CAAE,EACzF,CACL,MAAA,CAAQA,EAAS,MACjB,CAAA,UAAA,CAAYA,EAAS,UACrB,CAAA,IAAA,CAAMD,EAAgBI,CAAK,CAAA,IAAA,CAAOA,CACpC,CACF,CAASC,MAAAA,CAAAA,CAAU,CAEjB,MAAApB,CAAAA,CAAO,SAAS,OAAS,CAAA,CAAA,qBAAA,EAAwBc,CAAW,CAAaM,UAAAA,EAAAA,CAAAA,CAAI,QAAU,GAAG,CAAA,SAAA,EAAYpB,EAAO,OAAQoB,CAAAA,CAAAA,CAAI,OAASA,CAAG,CAAC,EAAE,CAClI,CAAA,CACJ,OAAQA,CAAI,CAAA,MAAA,EAAU,IACtB,UAAYA,CAAAA,CAAAA,CAAI,YAAc5B,CAAW,CAAA,qBAAA,CACzC,MAAO4B,CAAI,CAAA,KAAA,EAAS,CAClB,MAAQA,CAAAA,CAAAA,CAAI,QAAU,GACtB,CAAA,KAAA,CAAOA,EAAI,UAAc5B,EAAAA,CAAAA,CAAW,oBACtC,CACF,CACF,CACF,CAAA,CAEO6B,CAAQb,CAAAA","file":"index.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) */ 'ka-IN' = 'ka-IN'\r\n}\r\n\r\nexport enum OperationalLanguage {\r\n en = 'en',\r\n ka = 'ka'\r\n}\r\n\r\nexport const LocaleLanguageMap: Record<OperationalLocale, OperationalLanguage> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalLanguage.en,\r\n [OperationalLocale[\"ka-IN\"]]: OperationalLanguage.ka,\r\n}\r\n\r\nexport const LocaleCountryMap: Record<OperationalLocale, OperationalCountry> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalCountry.IN,\r\n [OperationalLocale[\"ka-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\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}","import { OperationalCountry, OperationalCountryCurrency, OperationalLocale } from \"../Classes/Enum\";\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\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"variantId\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\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 \"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 \"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","import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, variantId: string) => {\r\n return `${key}#${variantId}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, variantId] = searchId.split('#');\r\n return {\r\n key,\r\n variantId\r\n }\r\n },\r\n}\r\n\r\nexport default Utils;\r\n","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
+ {"version":3,"sources":["../src/Classes/Enum.ts","../src/Schema/definition.ts","../src/Schema/index.ts","../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Utils/index.ts","../src/enums/ErrorTypes.ts","../src/Logger/index.ts","../src/Utils/response.ts","../src/Utils/fetch.ts"],"names":["OperationalCountry","OperationalCountryCurrency","OperationalLocale","definition_default","Schema","Schema_default","rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","v","parse_default","stringToBytes","str","bytes","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","_namespace","native_default","v4","options","rnds","v4_default","sha1","sha1_default","v5","v5_default","Utils","key","variantId","searchId","Utils_default","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","completeURL","isInternalAPI","response","errorBody","errorText","body","err","fetch_default"],"mappings":"sNAGO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,EAAK,CAAA,IAAA,CADRA,OAAA,EAIAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,GAAM,CAAA,KAAA,CADTA,OAAA,EAIAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,OAAU,CAAA,CAAA,OAAA,CACCA,EAAA,OAAU,CAAA,CAAA,OAAA,CAFxBA,OAAA,ECTZ,CAAA,CAAA,IAAOC,EAAQ,CACb,GAAA,CAAO,YACP,WAAe,CAAA,CACX,cAAiB,CACb,IAAA,CAAQ,SACR,OAAW,CAAA,2BACf,EACA,eAAmB,CAAA,CACf,KAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CACA,CAAA,eAAA,CAAmB,CACf,IAAQ,CAAA,QAAA,CACR,QAAW,gCACf,CAAA,CACA,gBAAmB,CACf,IAAA,CAAQ,SACR,OAAW,CAAA,gCACf,EACA,eAAmB,CAAA,CACf,KAAQ,QACR,CAAA,OAAA,CAAW,gCACf,CACA,CAAA,gBAAA,CAAoB,CAChB,IAAQ,CAAA,QAAA,CACR,QAAW,iCACf,CAAA,CACA,KAAQ,CACJ,IAAA,CAAQ,SACR,OAAW,CAAA,uBACf,EACA,MAAU,CAAA,CACN,KAAQ,QACR,CAAA,OAAA,CAAW,4BACf,CACA,CAAA,MAAA,CAAU,CACN,IAAQ,CAAA,QAAA,CACR,QAAW,4BACf,C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AAS,CAAA,CAAA,qBAAA,EAAwBc,CAAW,CAAaM,UAAAA,EAAAA,CAAAA,CAAI,QAAU,GAAG,CAAA,SAAA,EAAYpB,EAAO,OAAQoB,CAAAA,CAAAA,CAAI,OAASA,CAAG,CAAC,EAAE,CAClI,CAAA,CACJ,OAAQA,CAAI,CAAA,MAAA,EAAU,IACtB,UAAYA,CAAAA,CAAAA,CAAI,YAAc5B,CAAW,CAAA,qBAAA,CACzC,MAAO4B,CAAI,CAAA,KAAA,EAAS,CAClB,MAAQA,CAAAA,CAAAA,CAAI,QAAU,GACtB,CAAA,KAAA,CAAOA,EAAI,UAAc5B,EAAAA,CAAAA,CAAW,oBACtC,CACF,CACF,CACF,CAAA,CAEO6B,CAAQb,CAAAA","file":"index.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\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}","import { OperationalCountry, OperationalCountryCurrency, OperationalLocale } from \"../Classes/Enum\";\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\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"variantId\": {\r\n \"type\": \"string\",\r\n \"pattern\": \"^(?!\\\\s)(?!.*\\\\s$)[A-Z0-9-]{4,16}$\"\r\n },\r\n \"firstName\": { \"$ref\": \"#/definitions/requiredText30\" },\r\n \"lastName\": { \"$ref\": \"#/definitions/text30\" },\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 \"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 \"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","import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, variantId: string) => {\r\n return `${key}#${variantId}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, variantId] = searchId.split('#');\r\n return {\r\n key,\r\n variantId\r\n }\r\n },\r\n}\r\n\r\nexport default Utils;\r\n","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"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export{e as Fetch,c as Logger,d as ResponseUtility,a as Utils}from'./chunk-CKUUUEWT.mjs';import {a,b,c}from'./chunk-G6EL2Y7V.mjs';var n={$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:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},variantId:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},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)},locale:{type:"string",enum:Object.values(c)},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},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 n}},f=$;
1
+ export{e as Fetch,c as Logger,d as ResponseUtility,a as Utils}from'./chunk-CKUUUEWT.mjs';import {a,b,c}from'./chunk-6PDP4ETM.mjs';var n={$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:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},variantId:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$"},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},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)},locale:{type:"string",enum:Object.values(c)},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},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 n}},f=$;
2
2
  export{f as Schema};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b23-lib",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
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 p=(o=>(o.IN="IN",o))(p||{}),t=(o=>(o.INR="INR",o))(t||{}),r=(n=>(n["en-IN"]="en-IN",n["ka-IN"]="ka-IN",n))(r||{}),I=(e=>(e.en="en",e.ka="ka",e))(I||{}),c={"en-IN":"en","ka-IN":"ka"},i={"en-IN":"IN","ka-IN":"IN"},L={IN:"INR"},x={INR:"\u20B9"},l=(a=>(a.MALE="Male",a.FEMALE="Female",a.UNISEX="Unisex",a.KIDS="Kids",a.BOY="Boy",a.GIRL="Girl",a))(l||{});export{p as a,t as b,r as c,I as d,c as e,i as f,L as g,x as h,l as i};//# sourceMappingURL=chunk-G6EL2Y7V.mjs.map
2
- //# sourceMappingURL=chunk-G6EL2Y7V.mjs.map