@repobit/dex-store 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.11](https://github.com/bitdefender/dex-core/compare/@repobit/dex-store@1.3.10...@repobit/dex-store@1.3.11) (2026-03-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **DEX-26778:** fix bundle pricing issue ([94410c2](https://github.com/bitdefender/dex-core/commit/94410c27db55e3c644d96b12e9bcf1595b6a735e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.3.10](https://github.com/bitdefender/dex-core/compare/@repobit/dex-store@1.3.9...@repobit/dex-store@1.3.10) (2026-02-17)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @repobit/dex-store
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [1.3.9](https://github.com/bitdefender/dex-core/compare/@repobit/dex-store@1.3.8...@repobit/dex-store@1.3.9) (2026-02-16)
|
|
7
24
|
|
|
8
25
|
**Note:** Version bump only for package @repobit/dex-store
|
|
@@ -249,21 +249,20 @@ export class Product {
|
|
|
249
249
|
const optionPrice = option.getPrice({ currency: false });
|
|
250
250
|
const optionDiscountedPrice = option.getDiscountedPrice({ currency: false });
|
|
251
251
|
// Always add the option's price to the bundled price
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
// Both exist: add them together
|
|
256
|
-
bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionDiscountedPrice);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
// If no current discountedPrice, base it on the updated price
|
|
260
|
-
bundledOption.discountedPrice = round(bundledOption.price + optionDiscountedPrice);
|
|
261
|
-
}
|
|
252
|
+
if (bundledOption.discountedPrice && optionDiscountedPrice) {
|
|
253
|
+
bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionDiscountedPrice);
|
|
254
|
+
bundledOption.price = round(bundledOption.price + optionPrice);
|
|
262
255
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
256
|
+
if (bundledOption.discountedPrice && !optionDiscountedPrice) {
|
|
257
|
+
bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionPrice);
|
|
258
|
+
bundledOption.price = round(bundledOption.price + optionPrice);
|
|
259
|
+
}
|
|
260
|
+
if (!bundledOption.discountedPrice && optionDiscountedPrice) {
|
|
261
|
+
bundledOption.discountedPrice = round(bundledOption.price + optionDiscountedPrice);
|
|
262
|
+
bundledOption.price = round(bundledOption.price + optionPrice);
|
|
263
|
+
}
|
|
264
|
+
if (!bundledOption.discountedPrice && !optionDiscountedPrice) {
|
|
265
|
+
bundledOption.price = round(bundledOption.price + optionPrice);
|
|
267
266
|
}
|
|
268
267
|
}
|
|
269
268
|
return bundledOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product.base.js","sourceRoot":"","sources":["../../../src/products/product.base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAmBtE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAuB9C,MAAM,OAAgB,OAAO;IACnB,KAAK,CAAmB;IACxB,IAAI,CAAqB;IACzB,QAAQ,CAAiB;IACzB,YAAY,CAAa;IACzB,EAAE,CAAuB;IACzB,KAAK,CAAoB;IACzB,QAAQ,CAAiB;IACzB,OAAO,CAAsC;IAC7C,UAAU,CAAe;IACzB,OAAO,CAAuB;IAC9B,aAAa,CAAsB;IACnC,QAAQ,CAAuB;IA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AC,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,GAAG,qBAAqB,CAAC,CAAC;gBACrF,CAAC;YACH,CAAC;iBAAM,IAAI,aAAa,CAAC,eAAe,EAAE,CAAC;gBACzC,uEAAuE;gBACvE,gEAAgE;gBAChE,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,eAAe,GAAG,WAAW,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { ProductBundleOption, ProductOption, ProductOptionData } from \"@/product-options/option.base\";\nimport type { Store } from \"@/store\";\nimport { STORE_ADAPTER, STORE_TRANSFORMERS } from \"@/store.constants\";\n\nexport type UnboundProductOptionData = Omit<ProductOptionData, \"product\">\n\nexport type ProductData = {\n store : Store;\n name : string;\n campaign? : string;\n campaignType? : string;\n id : string;\n alias : string;\n currency : string;\n options : Map<string, UnboundProductOptionData>;\n buyLinkBaseUrl?: string;\n platformId : string;\n}\n\nexport type UnboundProductData = Omit<ProductData, \"store\">\n\nexport const SET_OPTION = Symbol(\"setOption\");\n\ntype MinMaxType = {\n min: number,\n max: number\n}\n\ntype PriceType = MinMaxType & {\n monthly: MinMaxType\n}\n\ntype DiscountType = MinMaxType & {\n percentage: MinMaxType\n}\n\ntype DevicesType = MinMaxType & {\n values: number[]\n}\n\ntype SubscriptionType = MinMaxType & {\n values: number[]\n}\n\nexport abstract class Product {\n private store : Store;\n private name : string;\n private campaign? : string;\n private campaignType? : string;\n private id : string;\n private alias : string;\n private currency : string;\n private options : Map<string, ProductOption>;\n private platformId : string;\n private devices : DevicesType;\n private subscriptions : SubscriptionType;\n private discount : DiscountType;\n private price : PriceType;\n private discountedPrice : PriceType;\n private buyLinkBaseUrl ?: string;\n\n constructor(product: ProductData) {\n this.store = product.store;\n this.name = product.name;\n this.campaign = product.campaign;\n this.campaignType = product.campaignType;\n this.id = product.id;\n this.alias = product.alias;\n this.platformId = product.platformId;\n this.currency = product.currency;\n this.devices = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n values: []\n };\n this.subscriptions = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n values: []\n };\n this.discount = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n percentage: {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n }\n };\n this.price = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n monthly: {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n }\n };\n this.discountedPrice = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n monthly: {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n }\n };\n this.options = new Map();\n this.buyLinkBaseUrl = product.buyLinkBaseUrl;\n\n const devices = new Set<number>();\n const subscriptions = new Set<number>();\n\n for (const [key, option] of product.options.entries()) {\n const productOption = this._createOption({ ...option, product: this })\n this.options.set(key, productOption)\n\n this.price.min = Math.min(\n productOption.getPrice({ currency: false }),\n this.price.min\n );\n this.price.max = Math.max(\n productOption.getPrice({ currency: false }),\n this.price.max\n );\n\n this.price.monthly.min = Math.min(\n productOption.getPrice({ monthly: true, currency: false }),\n this.price.monthly.min\n );\n this.price.monthly.max = Math.max(\n productOption.getPrice({ monthly: true, currency: false }),\n this.price.monthly.max\n );\n\n this.discountedPrice.min = Math.min(\n productOption.getDiscountedPrice({ currency: false }),\n this.discountedPrice.min\n );\n this.discountedPrice.max = Math.max(\n productOption.getDiscountedPrice({ currency: false }),\n this.discountedPrice.max\n );\n\n this.discountedPrice.monthly.min = Math.min(\n productOption.getDiscountedPrice({ monthly: true, currency: false }),\n this.discountedPrice.monthly.min\n );\n this.discountedPrice.monthly.max = Math.max(\n productOption.getDiscountedPrice({ monthly: true, currency: false }),\n this.discountedPrice.monthly.max\n );\n\n this.devices.min = Math.min(productOption.getDevices(), this.devices.min);\n this.devices.max = Math.max(productOption.getDevices(), this.devices.max);\n devices.add(productOption.getDevices());\n\n this.subscriptions.min = Math.min(productOption.getSubscription(), this.subscriptions.min);\n this.subscriptions.max = Math.max(productOption.getSubscription(), this.subscriptions.max);\n subscriptions.add(productOption.getSubscription());\n\n this.discount.min = Math.min(productOption.getDiscount({ symbol: false }), this.discount.min);\n this.discount.max = Math.max(productOption.getDiscount({ symbol: false }), this.discount.max);\n\n this.discount.percentage.min = Math.min(productOption.getDiscount({ percentage: true, symbol: false }), this.discount.percentage.min);\n this.discount.percentage.max = Math.max(productOption.getDiscount({ percentage: true, symbol: false }), this.discount.percentage.max);\n }\n\n this.devices.values = [...devices];\n this.subscriptions.values = [...subscriptions];\n }\n\n protected abstract _createOption(product: ProductOptionData): ProductOption;\n\n getStore() {\n return this.store;\n }\n\n getId() {\n return this.id;\n }\n\n getAlias() {\n return this.alias;\n }\n\n getPlatformId() {\n return this.platformId;\n }\n\n getName() {\n return this.name;\n }\n\n getCampaign() {\n return this.campaign;\n }\n\n getCampaignType() {\n return this.campaignType;\n }\n\n getCurrency() {\n return this.currency;\n }\n\n getBuyLinkBaseUrl() {\n return this.buyLinkBaseUrl;\n }\n\n async getOption(): Promise<ProductOption[]>\n async getOption(param: { devices: undefined, subscription: undefined, bundle: ProductBundleOption[] }): Promise<(ProductOption | undefined)[]>\n async getOption(param: { devices: number, subscription: number, bundle?: (ProductBundleOption | undefined)[] }): Promise<ProductOption | undefined>\n async getOption(param?: { devices?: number, subscription?: number, bundle?: (ProductBundleOption | undefined)[] }): Promise<ProductOption | (ProductOption | undefined)[] | undefined> {\n const adaptor = await this.store[STORE_ADAPTER];\n const { devices, subscription } = await adaptor.adaptTo({\n id : this.alias,\n subscription: Number(param?.subscription),\n devices : Number(param?.devices)\n });\n const bundle = param?.bundle?.filter((option): option is ProductBundleOption => Boolean(option));\n\n const makeBundle = async (option: ProductOption, bundle: ProductBundleOption[]) => {\n const bundledOption = await this.bundle(option, bundle);\n\n const transformer = this.store[STORE_TRANSFORMERS]?.buyLink;\n if (transformer) {\n const productData: UnboundProductData = {\n name : this.name,\n campaign : this.campaign,\n campaignType : this.campaignType,\n id : this.id,\n alias : this.alias,\n currency : this.currency,\n options : new Map(),\n buyLinkBaseUrl: this.buyLinkBaseUrl,\n platformId : this.platformId\n };\n\n bundledOption.buyLink = await transformer({\n buyLink: bundledOption.buyLink,\n product: productData,\n option : bundledOption\n });\n }\n\n return this._createOption({ ...bundledOption, product: this });\n }\n\n if (Number(devices) && Number(subscription)) {\n const option = this.options.get(`${devices}-${subscription}`);\n if (!option) return undefined;\n\n //bundle with the option\n if (bundle && bundle.length > 0) {\n return await makeBundle(option, bundle);\n } else {\n return option;\n }\n }\n\n if (bundle && bundle.length > 0) {\n const optionsWithBundle = [...this.options.values()].map(option => makeBundle(option, bundle));\n const settled = await Promise.allSettled(optionsWithBundle);\n return settled\n .map((result) => result.status === \"fulfilled\" ? result.value : undefined)\n }\n\n //return all options\n return [...this.options.values()];\n }\n\n [SET_OPTION](param: { options: ProductOption | ProductOption[] }) {\n const options = Array.isArray(param.options) ? param.options : [param.options];\n for (const option of options) {\n const devices = option.getDevices();\n const subscription = option.getSubscription();\n\n this.options.set(`${devices}-${subscription}`, option)\n }\n }\n\n getPrice(): { min: string, max: string };\n getPrice(param: { monthly?: boolean, currency: true }): { min: string, max: string };\n getPrice(param: { monthly?: boolean, currency?: false }): { min: number, max: number };\n getPrice(param?: { monthly?: boolean, currency?: boolean }) {\n const { monthly = false, currency = true } = param ?? {};\n\n const price = monthly\n ? this.price.monthly\n : this.price;\n\n if (currency) {\n return {\n min: this.store.formatPrice({ price: price.min, currency: this.currency }),\n max: this.store.formatPrice({ price: price.max, currency: this.currency })\n };\n }\n\n return {\n min: price.min,\n max: price.max\n };\n }\n\n getDiscountedPrice(): { min: string, max: string };\n getDiscountedPrice(param: { monthly?: boolean, currency: true }): { min: string, max: string };\n getDiscountedPrice(param: { monthly?: boolean, currency?: false }): { min: number, max: number };\n getDiscountedPrice(param?: { monthly?: boolean, currency?: boolean }) {\n const { monthly = false, currency = true } = param ?? {};\n\n const discountedPrice = monthly\n ? this.discountedPrice.monthly\n : this.discountedPrice;\n\n if (currency) {\n return {\n min: this.store.formatPrice({ price: discountedPrice.min, currency: this.currency }),\n max: this.store.formatPrice({ price: discountedPrice.max, currency: this.currency })\n };\n }\n\n return {\n min: discountedPrice.min,\n max: discountedPrice.max\n };\n }\n\n getDiscount(): { min: number, max: number };\n getDiscount(param: { percentage?: boolean; symbol: true }): { min: string, max: string };\n getDiscount(param: { percentage?: boolean; symbol?: false }): { min: number, max: number };\n getDiscount(param?: { percentage?: boolean, symbol?: boolean }) {\n const { percentage = false, symbol = true } = param ?? {};\n\n const discountValue = percentage\n ? this.discount.percentage\n : this.discount;\n\n if (percentage) {\n return symbol\n ? { min: `${discountValue.min}%`, max: `${discountValue.max}%` }\n : { min: discountValue.min, max: discountValue.max }\n }\n\n return symbol\n ? {\n min: this.store.formatPrice({ price: discountValue.min, currency: this.currency }),\n max: this.store.formatPrice({ price: discountValue.max, currency: this.currency })\n }\n : {\n min: discountValue.min,\n max: discountValue.max\n };\n }\n\n getDevices() {\n return this.devices;\n }\n\n getSubscriptions() {\n return this.subscriptions;\n }\n\n protected async bundle(base: ProductOption, options: ProductBundleOption[]): Promise<UnboundProductOptionData> {\n const round = (n: number): number => Number(n.toFixed(2));\n\n // Start with the first option as the base\n const bundledOption: UnboundProductOptionData = {\n price : base.getPrice({ currency: false }),\n discountedPrice: base.getDiscountedPrice({ currency: false }),\n buyLink : base.getBuyLink(),\n subscription : base.getSubscription(),\n devices : base.getDevices(),\n bundle : options\n };\n\n // Process the remaining options\n for (const { option } of options) {\n const optionPrice = option.getPrice({ currency: false });\n const optionDiscountedPrice = option.getDiscountedPrice({ currency: false });\n\n // Always add the option's price to the bundled price\n bundledOption.price = round(bundledOption.price + optionPrice);\n\n if (optionDiscountedPrice) {\n if (bundledOption.discountedPrice) {\n // Both exist: add them together\n bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionDiscountedPrice);\n } else {\n // If no current discountedPrice, base it on the updated price\n bundledOption.discountedPrice = round(bundledOption.price + optionDiscountedPrice);\n }\n } else if (bundledOption.discountedPrice) {\n // If option lacks a discountedPrice but bundledOption already has one,\n // update the bundled price using the existing discounted value.\n bundledOption.price = round(bundledOption.discountedPrice + optionPrice);\n }\n }\n\n return bundledOption;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"product.base.js","sourceRoot":"","sources":["../../../src/products/product.base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAmBtE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAuB9C,MAAM,OAAgB,OAAO;IACnB,KAAK,CAAmB;IACxB,IAAI,CAAqB;IACzB,QAAQ,CAAiB;IACzB,YAAY,CAAa;IACzB,EAAE,CAAuB;IACzB,KAAK,CAAoB;IACzB,QAAQ,CAAiB;IACzB,OAAO,CAAsC;IAC7C,UAAU,CAAe;IACzB,OAAO,CAAuB;IAC9B,aAAa,CAAsB;IACnC,QAAQ,CAAuB;IAC/B,KAAK,CAAuB;IAC5B,eAAe,CAAa;IAC5B,cAAc,CAAW;IAEjC,YAAY,OAAoB;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,UAAU,G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a,CAAC,eAAe,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC7D,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { ProductBundleOption, ProductOption, ProductOptionData } from \"@/product-options/option.base\";\nimport type { Store } from \"@/store\";\nimport { STORE_ADAPTER, STORE_TRANSFORMERS } from \"@/store.constants\";\n\nexport type UnboundProductOptionData = Omit<ProductOptionData, \"product\">\n\nexport type ProductData = {\n store : Store;\n name : string;\n campaign? : string;\n campaignType? : string;\n id : string;\n alias : string;\n currency : string;\n options : Map<string, UnboundProductOptionData>;\n buyLinkBaseUrl?: string;\n platformId : string;\n}\n\nexport type UnboundProductData = Omit<ProductData, \"store\">\n\nexport const SET_OPTION = Symbol(\"setOption\");\n\ntype MinMaxType = {\n min: number,\n max: number\n}\n\ntype PriceType = MinMaxType & {\n monthly: MinMaxType\n}\n\ntype DiscountType = MinMaxType & {\n percentage: MinMaxType\n}\n\ntype DevicesType = MinMaxType & {\n values: number[]\n}\n\ntype SubscriptionType = MinMaxType & {\n values: number[]\n}\n\nexport abstract class Product {\n private store : Store;\n private name : string;\n private campaign? : string;\n private campaignType? : string;\n private id : string;\n private alias : string;\n private currency : string;\n private options : Map<string, ProductOption>;\n private platformId : string;\n private devices : DevicesType;\n private subscriptions : SubscriptionType;\n private discount : DiscountType;\n private price : PriceType;\n private discountedPrice : PriceType;\n private buyLinkBaseUrl ?: string;\n\n constructor(product: ProductData) {\n this.store = product.store;\n this.name = product.name;\n this.campaign = product.campaign;\n this.campaignType = product.campaignType;\n this.id = product.id;\n this.alias = product.alias;\n this.platformId = product.platformId;\n this.currency = product.currency;\n this.devices = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n values: []\n };\n this.subscriptions = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n values: []\n };\n this.discount = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n percentage: {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n }\n };\n this.price = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n monthly: {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n }\n };\n this.discountedPrice = {\n min : Number.MAX_SAFE_INTEGER,\n max : Number.MIN_SAFE_INTEGER,\n monthly: {\n min: Number.MAX_SAFE_INTEGER,\n max: Number.MIN_SAFE_INTEGER\n }\n };\n this.options = new Map();\n this.buyLinkBaseUrl = product.buyLinkBaseUrl;\n\n const devices = new Set<number>();\n const subscriptions = new Set<number>();\n\n for (const [key, option] of product.options.entries()) {\n const productOption = this._createOption({ ...option, product: this })\n this.options.set(key, productOption)\n\n this.price.min = Math.min(\n productOption.getPrice({ currency: false }),\n this.price.min\n );\n this.price.max = Math.max(\n productOption.getPrice({ currency: false }),\n this.price.max\n );\n\n this.price.monthly.min = Math.min(\n productOption.getPrice({ monthly: true, currency: false }),\n this.price.monthly.min\n );\n this.price.monthly.max = Math.max(\n productOption.getPrice({ monthly: true, currency: false }),\n this.price.monthly.max\n );\n\n this.discountedPrice.min = Math.min(\n productOption.getDiscountedPrice({ currency: false }),\n this.discountedPrice.min\n );\n this.discountedPrice.max = Math.max(\n productOption.getDiscountedPrice({ currency: false }),\n this.discountedPrice.max\n );\n\n this.discountedPrice.monthly.min = Math.min(\n productOption.getDiscountedPrice({ monthly: true, currency: false }),\n this.discountedPrice.monthly.min\n );\n this.discountedPrice.monthly.max = Math.max(\n productOption.getDiscountedPrice({ monthly: true, currency: false }),\n this.discountedPrice.monthly.max\n );\n\n this.devices.min = Math.min(productOption.getDevices(), this.devices.min);\n this.devices.max = Math.max(productOption.getDevices(), this.devices.max);\n devices.add(productOption.getDevices());\n\n this.subscriptions.min = Math.min(productOption.getSubscription(), this.subscriptions.min);\n this.subscriptions.max = Math.max(productOption.getSubscription(), this.subscriptions.max);\n subscriptions.add(productOption.getSubscription());\n\n this.discount.min = Math.min(productOption.getDiscount({ symbol: false }), this.discount.min);\n this.discount.max = Math.max(productOption.getDiscount({ symbol: false }), this.discount.max);\n\n this.discount.percentage.min = Math.min(productOption.getDiscount({ percentage: true, symbol: false }), this.discount.percentage.min);\n this.discount.percentage.max = Math.max(productOption.getDiscount({ percentage: true, symbol: false }), this.discount.percentage.max);\n }\n\n this.devices.values = [...devices];\n this.subscriptions.values = [...subscriptions];\n }\n\n protected abstract _createOption(product: ProductOptionData): ProductOption;\n\n getStore() {\n return this.store;\n }\n\n getId() {\n return this.id;\n }\n\n getAlias() {\n return this.alias;\n }\n\n getPlatformId() {\n return this.platformId;\n }\n\n getName() {\n return this.name;\n }\n\n getCampaign() {\n return this.campaign;\n }\n\n getCampaignType() {\n return this.campaignType;\n }\n\n getCurrency() {\n return this.currency;\n }\n\n getBuyLinkBaseUrl() {\n return this.buyLinkBaseUrl;\n }\n\n async getOption(): Promise<ProductOption[]>\n async getOption(param: { devices: undefined, subscription: undefined, bundle: ProductBundleOption[] }): Promise<(ProductOption | undefined)[]>\n async getOption(param: { devices: number, subscription: number, bundle?: (ProductBundleOption | undefined)[] }): Promise<ProductOption | undefined>\n async getOption(param?: { devices?: number, subscription?: number, bundle?: (ProductBundleOption | undefined)[] }): Promise<ProductOption | (ProductOption | undefined)[] | undefined> {\n const adaptor = await this.store[STORE_ADAPTER];\n const { devices, subscription } = await adaptor.adaptTo({\n id : this.alias,\n subscription: Number(param?.subscription),\n devices : Number(param?.devices)\n });\n const bundle = param?.bundle?.filter((option): option is ProductBundleOption => Boolean(option));\n\n const makeBundle = async (option: ProductOption, bundle: ProductBundleOption[]) => {\n const bundledOption = await this.bundle(option, bundle);\n\n const transformer = this.store[STORE_TRANSFORMERS]?.buyLink;\n if (transformer) {\n const productData: UnboundProductData = {\n name : this.name,\n campaign : this.campaign,\n campaignType : this.campaignType,\n id : this.id,\n alias : this.alias,\n currency : this.currency,\n options : new Map(),\n buyLinkBaseUrl: this.buyLinkBaseUrl,\n platformId : this.platformId\n };\n\n bundledOption.buyLink = await transformer({\n buyLink: bundledOption.buyLink,\n product: productData,\n option : bundledOption\n });\n }\n\n return this._createOption({ ...bundledOption, product: this });\n }\n\n if (Number(devices) && Number(subscription)) {\n const option = this.options.get(`${devices}-${subscription}`);\n if (!option) return undefined;\n\n //bundle with the option\n if (bundle && bundle.length > 0) {\n return await makeBundle(option, bundle);\n } else {\n return option;\n }\n }\n\n if (bundle && bundle.length > 0) {\n const optionsWithBundle = [...this.options.values()].map(option => makeBundle(option, bundle));\n const settled = await Promise.allSettled(optionsWithBundle);\n return settled\n .map((result) => result.status === \"fulfilled\" ? result.value : undefined)\n }\n\n //return all options\n return [...this.options.values()];\n }\n\n [SET_OPTION](param: { options: ProductOption | ProductOption[] }) {\n const options = Array.isArray(param.options) ? param.options : [param.options];\n for (const option of options) {\n const devices = option.getDevices();\n const subscription = option.getSubscription();\n\n this.options.set(`${devices}-${subscription}`, option)\n }\n }\n\n getPrice(): { min: string, max: string };\n getPrice(param: { monthly?: boolean, currency: true }): { min: string, max: string };\n getPrice(param: { monthly?: boolean, currency?: false }): { min: number, max: number };\n getPrice(param?: { monthly?: boolean, currency?: boolean }) {\n const { monthly = false, currency = true } = param ?? {};\n\n const price = monthly\n ? this.price.monthly\n : this.price;\n\n if (currency) {\n return {\n min: this.store.formatPrice({ price: price.min, currency: this.currency }),\n max: this.store.formatPrice({ price: price.max, currency: this.currency })\n };\n }\n\n return {\n min: price.min,\n max: price.max\n };\n }\n\n getDiscountedPrice(): { min: string, max: string };\n getDiscountedPrice(param: { monthly?: boolean, currency: true }): { min: string, max: string };\n getDiscountedPrice(param: { monthly?: boolean, currency?: false }): { min: number, max: number };\n getDiscountedPrice(param?: { monthly?: boolean, currency?: boolean }) {\n const { monthly = false, currency = true } = param ?? {};\n\n const discountedPrice = monthly\n ? this.discountedPrice.monthly\n : this.discountedPrice;\n\n if (currency) {\n return {\n min: this.store.formatPrice({ price: discountedPrice.min, currency: this.currency }),\n max: this.store.formatPrice({ price: discountedPrice.max, currency: this.currency })\n };\n }\n\n return {\n min: discountedPrice.min,\n max: discountedPrice.max\n };\n }\n\n getDiscount(): { min: number, max: number };\n getDiscount(param: { percentage?: boolean; symbol: true }): { min: string, max: string };\n getDiscount(param: { percentage?: boolean; symbol?: false }): { min: number, max: number };\n getDiscount(param?: { percentage?: boolean, symbol?: boolean }) {\n const { percentage = false, symbol = true } = param ?? {};\n\n const discountValue = percentage\n ? this.discount.percentage\n : this.discount;\n\n if (percentage) {\n return symbol\n ? { min: `${discountValue.min}%`, max: `${discountValue.max}%` }\n : { min: discountValue.min, max: discountValue.max }\n }\n\n return symbol\n ? {\n min: this.store.formatPrice({ price: discountValue.min, currency: this.currency }),\n max: this.store.formatPrice({ price: discountValue.max, currency: this.currency })\n }\n : {\n min: discountValue.min,\n max: discountValue.max\n };\n }\n\n getDevices() {\n return this.devices;\n }\n\n getSubscriptions() {\n return this.subscriptions;\n }\n\n protected async bundle(base: ProductOption, options: ProductBundleOption[]): Promise<UnboundProductOptionData> {\n const round = (n: number): number => Number(n.toFixed(2));\n\n // Start with the first option as the base\n const bundledOption: UnboundProductOptionData = {\n price : base.getPrice({ currency: false }),\n discountedPrice: base.getDiscountedPrice({ currency: false }),\n buyLink : base.getBuyLink(),\n subscription : base.getSubscription(),\n devices : base.getDevices(),\n bundle : options\n };\n\n // Process the remaining options\n for (const { option } of options) {\n const optionPrice = option.getPrice({ currency: false });\n const optionDiscountedPrice = option.getDiscountedPrice({ currency: false });\n\n // Always add the option's price to the bundled price\n if (bundledOption.discountedPrice && optionDiscountedPrice) {\n bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionDiscountedPrice);\n bundledOption.price = round(bundledOption.price + optionPrice);\n }\n\n if (bundledOption.discountedPrice && !optionDiscountedPrice) {\n bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionPrice);\n bundledOption.price = round(bundledOption.price + optionPrice);\n }\n\n if (!bundledOption.discountedPrice && optionDiscountedPrice) {\n bundledOption.discountedPrice = round(bundledOption.price + optionDiscountedPrice);\n bundledOption.price = round(bundledOption.price + optionPrice);\n }\n\n if (!bundledOption.discountedPrice && !optionDiscountedPrice) {\n bundledOption.price = round(bundledOption.price + optionPrice);\n }\n }\n\n return bundledOption;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobit/dex-store",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11",
|
|
4
4
|
"description": "Client for pricing API",
|
|
5
5
|
"author": "Buga Adrian Alexandru <abuga@bitdefender.com>",
|
|
6
6
|
"homepage": "https://github.com/bitdefender/dex-core#readme",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": "22.14.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@repobit/dex-constants": "^
|
|
42
|
+
"@repobit/dex-constants": "^2.0.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "18a527dd1735f0f70236bd68d435ab672b50edb8"
|
|
45
45
|
}
|