@repobit/dex-store 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +11 -0
  3. package/dist/src/adaptors/adaptor.base.d.ts +58 -0
  4. package/dist/src/adaptors/adaptor.base.js +89 -0
  5. package/dist/src/adaptors/adaptor.base.js.map +1 -0
  6. package/dist/src/format-price.d.ts +6 -0
  7. package/dist/src/format-price.js +17 -0
  8. package/dist/src/format-price.js.map +1 -0
  9. package/dist/src/index.d.ts +4 -0
  10. package/dist/src/index.js +5 -0
  11. package/dist/src/index.js.map +1 -0
  12. package/dist/src/product-options/option.base.d.ts +52 -0
  13. package/dist/src/product-options/option.base.js +72 -0
  14. package/dist/src/product-options/option.base.js.map +1 -0
  15. package/dist/src/products/product.base.d.ts +114 -0
  16. package/dist/src/products/product.base.js +235 -0
  17. package/dist/src/products/product.base.js.map +1 -0
  18. package/dist/src/products/product.init-selector.d.ts +10 -0
  19. package/dist/src/products/product.init-selector.js +77 -0
  20. package/dist/src/products/product.init-selector.js.map +1 -0
  21. package/dist/src/products/product.vlaicu.d.ts +6 -0
  22. package/dist/src/products/product.vlaicu.js +29 -0
  23. package/dist/src/products/product.vlaicu.js.map +1 -0
  24. package/dist/src/providers/provider.init-selector.d.ts +68 -0
  25. package/dist/src/providers/provider.init-selector.js +131 -0
  26. package/dist/src/providers/provider.init-selector.js.map +1 -0
  27. package/dist/src/providers/provider.interface.d.ts +9 -0
  28. package/dist/src/providers/provider.interface.js +2 -0
  29. package/dist/src/providers/provider.interface.js.map +1 -0
  30. package/dist/src/providers/provider.vlaicu.d.ts +7 -0
  31. package/dist/src/providers/provider.vlaicu.js +10 -0
  32. package/dist/src/providers/provider.vlaicu.js.map +1 -0
  33. package/dist/src/store.d.ts +45 -0
  34. package/dist/src/store.js +103 -0
  35. package/dist/src/store.js.map +1 -0
  36. package/package.json +53 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 0.1.0 (2025-03-25)
7
+
8
+
9
+ ### Features
10
+
11
+ * **DEX-21811:** add initial files ([048b21f](https://github.com/bitdefender/dex-core/commit/048b21f4f3693e62646a17839cf100efc77caaf7))
12
+ * **DEX-21811:** add provider init selector ([366d36a](https://github.com/bitdefender/dex-core/commit/366d36afd2eb9ef989460b664eac3e1e24cd7317))
13
+ * **DEX-21811:** add test for provider ([884a136](https://github.com/bitdefender/dex-core/commit/884a136a45dd29c24ab4d95c7b7e3f50877cfe39))
14
+ * **DEX-21811:** add vlaicu bundle test ([d6df092](https://github.com/bitdefender/dex-core/commit/d6df0929981c839515d1fec5ad96348ef0b745c7))
15
+ * **DEX-21811:** added bundle logic for init selector ([00a7bca](https://github.com/bitdefender/dex-core/commit/00a7bca94ed04e4ebfc8925932e9ddcc3d834d00))
16
+ * **DEX-21811:** change campaign to a function ([aa578e6](https://github.com/bitdefender/dex-core/commit/aa578e66198f0d29b41dd42b7b0908a0082422cc))
17
+ * **DEX-21811:** changed getOption to be async for vlaicu bundle ([40988d8](https://github.com/bitdefender/dex-core/commit/40988d843c6545bd65eda01fb476032603b8d905))
18
+ * **DEX-21811:** fix export ([26ff9d1](https://github.com/bitdefender/dex-core/commit/26ff9d1d5eb08c87753d581efb322bb88b416e87))
19
+ * **DEX-21811:** fix types ([531c1bd](https://github.com/bitdefender/dex-core/commit/531c1bd8a0fec02de12c70341a9d29fea77e09e5))
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `@bitdefender/dex-store`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ import dexStore from '@bitdefender/dex-store';
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,58 @@
1
+ export type OptionsMapping = Record<number, Record<number, {
2
+ devices: number;
3
+ subscription: number;
4
+ }>>;
5
+ export type ProductsMapping = Map<string, {
6
+ id: string;
7
+ options?: Promise<OptionsMapping | null>;
8
+ }>;
9
+ export type Product = {
10
+ id: string;
11
+ devices: number;
12
+ subscription: number;
13
+ };
14
+ export type OptionsSheet = {
15
+ total: number;
16
+ offset: number;
17
+ limit: number;
18
+ data: Array<{
19
+ fromDevices: number;
20
+ fromSubscription: number;
21
+ toDevices: number;
22
+ toSubscription: number;
23
+ }>;
24
+ columns: Array<"fromDevices" | "fromSubscription" | "toDevices" | "toSubscription">;
25
+ ":type": "sheet";
26
+ };
27
+ export type ProductIdSheet = {
28
+ total: number;
29
+ offset: number;
30
+ limit: number;
31
+ data: Array<{
32
+ from: string;
33
+ to: string;
34
+ }>;
35
+ columns: Array<"from" | "to">;
36
+ ":type": "sheet";
37
+ };
38
+ export declare class Adaptor {
39
+ private mapper;
40
+ constructor(mapper: ProductsMapping | null);
41
+ static create(): Promise<Adaptor>;
42
+ adaptTo(param: {
43
+ id: string;
44
+ }): Promise<{
45
+ id: string;
46
+ }>;
47
+ adaptTo(param: {
48
+ id: string;
49
+ devices: number;
50
+ subscription: number;
51
+ }): Promise<{
52
+ id: string;
53
+ devices: number;
54
+ subscription: number;
55
+ }>;
56
+ static getMappings(): Promise<ProductsMapping | null>;
57
+ private getMappingForId;
58
+ }
@@ -0,0 +1,89 @@
1
+ export class Adaptor {
2
+ mapper;
3
+ constructor(mapper) {
4
+ this.mapper = mapper;
5
+ }
6
+ static async create() {
7
+ const productsMapping = await this.getMappings();
8
+ return new Adaptor(productsMapping);
9
+ }
10
+ async adaptTo(param) {
11
+ const { id, devices, subscription } = param;
12
+ const product = { id };
13
+ if (!this.mapper) {
14
+ product.devices = devices;
15
+ product.subscription = subscription;
16
+ return product;
17
+ }
18
+ const mappedProduct = this.mapper.get(id);
19
+ if (mappedProduct) {
20
+ product.id = mappedProduct.id;
21
+ }
22
+ else {
23
+ product.devices = devices;
24
+ product.subscription = subscription;
25
+ return product;
26
+ }
27
+ if (mappedProduct && !mappedProduct?.options) {
28
+ mappedProduct.options = this.getMappingForId(id);
29
+ }
30
+ if (devices && subscription) {
31
+ const options = await mappedProduct.options;
32
+ if (options) {
33
+ const option = options[devices]?.[subscription];
34
+ if (option) {
35
+ product.devices = option.devices;
36
+ product.subscription = option.subscription;
37
+ }
38
+ }
39
+ }
40
+ return product;
41
+ }
42
+ static async getMappings() {
43
+ try {
44
+ const response = await fetch("https://www.bitdefender.com/common/store-config/init-to-vlaicu-mappings.json?sheet=id-mappings");
45
+ if (!response.ok) {
46
+ console.error(`${response.status}: ${response.statusText}`);
47
+ return null;
48
+ }
49
+ const sheet = await response.json();
50
+ const products = new Map();
51
+ for (const product of sheet.data) {
52
+ const { from, to } = product;
53
+ products.set(from, { id: to });
54
+ }
55
+ return products;
56
+ }
57
+ catch (error) {
58
+ console.error(error);
59
+ return null;
60
+ }
61
+ }
62
+ async getMappingForId(id) {
63
+ try {
64
+ const response = await fetch(`https://www.bitdefender.com/common/store-config/init-to-vlaicu-mappings.json?sheet=${id}`);
65
+ if (!response.ok) {
66
+ console.error(`${response.status}: ${response.statusText}`);
67
+ return null;
68
+ }
69
+ const sheet = await response.json();
70
+ const options = {};
71
+ for (const option of sheet.data) {
72
+ const fromDevices = Number(option.fromDevices), fromSubscription = Number(option.fromSubscription), toDevices = Number(option.toDevices), toSubscription = Number(option.toSubscription);
73
+ if (!options[fromDevices]) {
74
+ options[fromDevices] = {};
75
+ }
76
+ options[fromDevices][fromSubscription] = {
77
+ devices: toDevices,
78
+ subscription: toSubscription
79
+ };
80
+ }
81
+ return options;
82
+ }
83
+ catch (error) {
84
+ console.error(error);
85
+ return null;
86
+ }
87
+ }
88
+ }
89
+ //# sourceMappingURL=adaptor.base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptor.base.js","sourceRoot":"","sources":["../../../src/adaptors/adaptor.base.ts"],"names":[],"mappings":"AAmCA,MAAM,OAAO,OAAO;IACV,MAAM,CAAyB;IAE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,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBAC5D,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,KAAK,GAAgB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEjD,MAAM,OAAO,GAAmB,EAAE,CAAC;YAEnC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBAChC,MACE,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EACxC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAClD,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EACpC,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;gBAEhD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC1B,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;gBAC5B,CAAC;gBAED,OAAO,CAAC,WAAW,CAAC,CAAC,gBAAgB,CAAC,GAAG;oBACvC,OAAO,EAAO,SAAS;oBACvB,YAAY,EAAE,cAAc;iBAC7B,CAAA;YACH,CAAC;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export type PriceFormat = {
2
+ price: number;
3
+ currency?: string;
4
+ locale?: Intl.UnicodeBCP47LocaleIdentifier;
5
+ };
6
+ export declare const formatPrice: ({ price, currency, locale }: PriceFormat) => string | number;
@@ -0,0 +1,17 @@
1
+ export const formatPrice = ({ price, currency, locale = "en-us" }) => {
2
+ if (!price) {
3
+ return "";
4
+ }
5
+ if (!currency) {
6
+ return price;
7
+ }
8
+ return new Intl
9
+ .NumberFormat(locale, {
10
+ style: "currency",
11
+ currency,
12
+ minimumFractionDigits: 0,
13
+ maximumFractionDigits: 2
14
+ })
15
+ .format(price);
16
+ };
17
+ //# sourceMappingURL=format-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-price.js","sourceRoot":"","sources":["../../src/format-price.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAe,EAAE,EAAE;IAChF,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,IAAI;SACZ,YAAY,CAAC,MAAM,EAAE;QACpB,KAAK,EAAkB,UAAU;QACjC,QAAQ;QACR,qBAAqB,EAAE,CAAC;QACxB,qBAAqB,EAAE,CAAC;KAAE,CAAC;SAC5B,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ProductOption } from "./product-options/option.base.js";
2
+ import { Product } from "./products/product.base.js";
3
+ import { Store } from "./store.js";
4
+ export { Product, ProductOption, Store };
@@ -0,0 +1,5 @@
1
+ import { ProductOption } from "./product-options/option.base.js";
2
+ import { Product } from "./products/product.base.js";
3
+ import { Store } from "./store.js";
4
+ export { Product, ProductOption, Store };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EACL,OAAO,EACP,aAAa,EACb,KAAK,EACN,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { Product } from "../products/product.base.js";
2
+ export type ProductOptionData = {
3
+ product: Product;
4
+ price: number;
5
+ discountedPrice: number;
6
+ devices: number;
7
+ subscription: number;
8
+ buyLink: string;
9
+ };
10
+ export declare class ProductOption {
11
+ private product;
12
+ private price;
13
+ private discountedPrice;
14
+ private devices;
15
+ private subscription;
16
+ private currency?;
17
+ private buyLink;
18
+ private discount;
19
+ constructor(option: ProductOptionData);
20
+ getProduct(): Product;
21
+ getVariation(): string;
22
+ getPrice(): string;
23
+ getPrice(param: {
24
+ monthly?: boolean;
25
+ currency: true;
26
+ }): string;
27
+ getPrice(param: {
28
+ monthly?: boolean;
29
+ currency?: false;
30
+ }): number;
31
+ getDiscountedPrice(): string;
32
+ getDiscountedPrice(param: {
33
+ monthly?: boolean;
34
+ currency: true;
35
+ }): string;
36
+ getDiscountedPrice(param: {
37
+ monthly?: boolean;
38
+ currency?: false;
39
+ }): number;
40
+ getDiscount(): number;
41
+ getDiscount(param: {
42
+ percentage?: boolean;
43
+ symbol: true;
44
+ }): string;
45
+ getDiscount(param: {
46
+ percentage?: boolean;
47
+ symbol?: false;
48
+ }): number;
49
+ getBuyLink(): string;
50
+ getDevices(): number;
51
+ getSubscription(): number;
52
+ }
@@ -0,0 +1,72 @@
1
+ import { formatPrice } from "../format-price.js";
2
+ export class ProductOption {
3
+ product;
4
+ price;
5
+ discountedPrice;
6
+ devices;
7
+ subscription;
8
+ currency;
9
+ buyLink;
10
+ discount;
11
+ constructor(option) {
12
+ this.product = option.product;
13
+ this.price = {
14
+ value: option.price,
15
+ monthly: Number(Number(option.price / option.subscription).toFixed(2))
16
+ };
17
+ this.discountedPrice = {
18
+ value: option.discountedPrice,
19
+ monthly: Number(Number(option.discountedPrice / option.subscription).toFixed(2))
20
+ };
21
+ this.devices = option.devices;
22
+ this.subscription = option.subscription;
23
+ this.currency = option.product.getCurrency();
24
+ this.buyLink = option.buyLink;
25
+ this.discount = {
26
+ value: Math.round((option.price - option.discountedPrice + Number.EPSILON) * 100) / 100,
27
+ percentage: Math.round(((option.price - option.discountedPrice) / option.price * 100))
28
+ };
29
+ }
30
+ getProduct() {
31
+ return this.product;
32
+ }
33
+ getVariation() {
34
+ return `${this.devices}-${this.subscription}`;
35
+ }
36
+ getPrice(param) {
37
+ const { monthly = false, currency = true } = param ?? {};
38
+ const rawPrice = monthly ? this.price.monthly : this.price.value;
39
+ if (currency) {
40
+ return formatPrice({ price: rawPrice, currency: this.currency });
41
+ }
42
+ return rawPrice;
43
+ }
44
+ getDiscountedPrice(param) {
45
+ const { monthly = false, currency = true } = param ?? {};
46
+ const rawPrice = monthly ? this.discountedPrice.monthly : this.discountedPrice.value;
47
+ if (currency) {
48
+ return formatPrice({ price: rawPrice, currency: this.currency });
49
+ }
50
+ return rawPrice;
51
+ }
52
+ getDiscount(param) {
53
+ const { percentage = false, symbol = true } = param ?? {};
54
+ const rawValue = percentage ? this.discount.percentage : this.discount.value;
55
+ if (symbol) {
56
+ return percentage
57
+ ? `${rawValue}%`
58
+ : formatPrice({ price: rawValue, currency: this.currency });
59
+ }
60
+ return rawValue;
61
+ }
62
+ getBuyLink() {
63
+ return this.buyLink;
64
+ }
65
+ getDevices() {
66
+ return this.devices;
67
+ }
68
+ getSubscription() {
69
+ return this.subscription;
70
+ }
71
+ }
72
+ //# sourceMappingURL=option.base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option.base.js","sourceRoot":"","sources":["../../../src/product-options/option.base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAsB7C,MAAM,OAAO,aAAa;IAChB,OAAO,CAAkB;IACzB,KAAK,CAAsB;IAC3B,eAAe,CAAY;IAC3B,OAAO,CAAiB;IACxB,YAAY,CAAY;IACxB,QAAQ,CAAgB;IACxB,OAAO,CAAiB;IACxB,QAAQ,CAAsB;IAEtC,YAAY,MAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG;YACX,K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QAChE,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,114 @@
1
+ import { ProductOption, ProductOptionData } from "../product-options/option.base.js";
2
+ import { Store } from "../store.js";
3
+ export type UnboundProductOptionData = Omit<ProductOptionData, "product">;
4
+ export type ProductData = {
5
+ store: Store;
6
+ name: string;
7
+ campaign?: string;
8
+ id: string;
9
+ currency: string;
10
+ options: Map<string, UnboundProductOptionData>;
11
+ platformId: string;
12
+ };
13
+ export declare const setOption: unique symbol;
14
+ type MinMaxType = {
15
+ min: number;
16
+ max: number;
17
+ };
18
+ type DevicesType = MinMaxType & {
19
+ values: number[];
20
+ };
21
+ type SubscriptionType = MinMaxType & {
22
+ values: number[];
23
+ };
24
+ export declare class Product {
25
+ private store;
26
+ private name;
27
+ private campaign?;
28
+ private id;
29
+ private currency;
30
+ private options;
31
+ private platformId;
32
+ private devices;
33
+ private subscriptions;
34
+ private discount;
35
+ private price;
36
+ private discountedPrice;
37
+ constructor(product: ProductData);
38
+ getStore(): Store;
39
+ getId(): string;
40
+ getPlatformId(): string;
41
+ getName(): string;
42
+ getCampaign(): string | undefined;
43
+ getCurrency(): string;
44
+ getOption(): Promise<ProductOption[]>;
45
+ getOption(param: {
46
+ bundle: ProductOption[];
47
+ }): Promise<(ProductOption | undefined)[]>;
48
+ getOption(param: {
49
+ devices: number;
50
+ subscription: number;
51
+ bundle?: (ProductOption | undefined)[];
52
+ }): Promise<ProductOption | undefined>;
53
+ [setOption](param: {
54
+ options: ProductOption | ProductOption[];
55
+ }): void;
56
+ getPrice(): {
57
+ min: string;
58
+ max: string;
59
+ };
60
+ getPrice(param: {
61
+ monthly?: boolean;
62
+ currency: true;
63
+ }): {
64
+ min: string;
65
+ max: string;
66
+ };
67
+ getPrice(param: {
68
+ monthly?: boolean;
69
+ currency?: false;
70
+ }): {
71
+ min: number;
72
+ max: number;
73
+ };
74
+ getDiscountedPrice(): {
75
+ min: string;
76
+ max: string;
77
+ };
78
+ getDiscountedPrice(param: {
79
+ monthly?: boolean;
80
+ currency: true;
81
+ }): {
82
+ min: string;
83
+ max: string;
84
+ };
85
+ getDiscountedPrice(param: {
86
+ monthly?: boolean;
87
+ currency?: false;
88
+ }): {
89
+ min: number;
90
+ max: number;
91
+ };
92
+ getDiscount(): {
93
+ min: number;
94
+ max: number;
95
+ };
96
+ getDiscount(param: {
97
+ percentage?: boolean;
98
+ symbol: true;
99
+ }): {
100
+ min: string;
101
+ max: string;
102
+ };
103
+ getDiscount(param: {
104
+ percentage?: boolean;
105
+ symbol?: false;
106
+ }): {
107
+ min: number;
108
+ max: number;
109
+ };
110
+ getDevices(): DevicesType;
111
+ getSubscriptions(): SubscriptionType;
112
+ protected bundle(base: ProductOption, options: ProductOption[]): Promise<UnboundProductOptionData>;
113
+ }
114
+ export {};