@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.
- package/CHANGELOG.md +19 -0
- package/README.md +11 -0
- package/dist/src/adaptors/adaptor.base.d.ts +58 -0
- package/dist/src/adaptors/adaptor.base.js +89 -0
- package/dist/src/adaptors/adaptor.base.js.map +1 -0
- package/dist/src/format-price.d.ts +6 -0
- package/dist/src/format-price.js +17 -0
- package/dist/src/format-price.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/product-options/option.base.d.ts +52 -0
- package/dist/src/product-options/option.base.js +72 -0
- package/dist/src/product-options/option.base.js.map +1 -0
- package/dist/src/products/product.base.d.ts +114 -0
- package/dist/src/products/product.base.js +235 -0
- package/dist/src/products/product.base.js.map +1 -0
- package/dist/src/products/product.init-selector.d.ts +10 -0
- package/dist/src/products/product.init-selector.js +77 -0
- package/dist/src/products/product.init-selector.js.map +1 -0
- package/dist/src/products/product.vlaicu.d.ts +6 -0
- package/dist/src/products/product.vlaicu.js +29 -0
- package/dist/src/products/product.vlaicu.js.map +1 -0
- package/dist/src/providers/provider.init-selector.d.ts +68 -0
- package/dist/src/providers/provider.init-selector.js +131 -0
- package/dist/src/providers/provider.init-selector.js.map +1 -0
- package/dist/src/providers/provider.interface.d.ts +9 -0
- package/dist/src/providers/provider.interface.js +2 -0
- package/dist/src/providers/provider.interface.js.map +1 -0
- package/dist/src/providers/provider.vlaicu.d.ts +7 -0
- package/dist/src/providers/provider.vlaicu.js +10 -0
- package/dist/src/providers/provider.vlaicu.js.map +1 -0
- package/dist/src/store.d.ts +45 -0
- package/dist/src/store.js +103 -0
- package/dist/src/store.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { formatPrice } from "../format-price.js";
|
|
2
|
+
import { ProductOption } from "../product-options/option.base.js";
|
|
3
|
+
export const setOption = Symbol("setProduct");
|
|
4
|
+
export class Product {
|
|
5
|
+
store;
|
|
6
|
+
name;
|
|
7
|
+
campaign;
|
|
8
|
+
id;
|
|
9
|
+
currency;
|
|
10
|
+
options;
|
|
11
|
+
platformId;
|
|
12
|
+
devices;
|
|
13
|
+
subscriptions;
|
|
14
|
+
discount;
|
|
15
|
+
price;
|
|
16
|
+
discountedPrice;
|
|
17
|
+
constructor(product) {
|
|
18
|
+
this.store = product.store;
|
|
19
|
+
this.name = product.name;
|
|
20
|
+
this.campaign = product.campaign;
|
|
21
|
+
this.id = product.id;
|
|
22
|
+
this.platformId = product.platformId;
|
|
23
|
+
this.currency = product.currency;
|
|
24
|
+
this.devices = {
|
|
25
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
26
|
+
max: Number.MIN_SAFE_INTEGER,
|
|
27
|
+
values: []
|
|
28
|
+
};
|
|
29
|
+
this.subscriptions = {
|
|
30
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
31
|
+
max: Number.MIN_SAFE_INTEGER,
|
|
32
|
+
values: []
|
|
33
|
+
};
|
|
34
|
+
this.discount = {
|
|
35
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
36
|
+
max: Number.MIN_SAFE_INTEGER,
|
|
37
|
+
percentage: {
|
|
38
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
39
|
+
max: Number.MIN_SAFE_INTEGER
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
this.price = {
|
|
43
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
44
|
+
max: Number.MIN_SAFE_INTEGER,
|
|
45
|
+
monthly: {
|
|
46
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
47
|
+
max: Number.MIN_SAFE_INTEGER
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
this.discountedPrice = {
|
|
51
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
52
|
+
max: Number.MIN_SAFE_INTEGER,
|
|
53
|
+
monthly: {
|
|
54
|
+
min: Number.MAX_SAFE_INTEGER,
|
|
55
|
+
max: Number.MIN_SAFE_INTEGER
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
this.options = new Map();
|
|
59
|
+
const devices = new Set();
|
|
60
|
+
const subscriptions = new Set();
|
|
61
|
+
for (const [key, option] of product.options.entries()) {
|
|
62
|
+
const productOption = new ProductOption({ ...option, product: this });
|
|
63
|
+
this.options.set(key, productOption);
|
|
64
|
+
this.price.min = Math.min(productOption.getPrice({ currency: false }), this.price.min);
|
|
65
|
+
this.price.max = Math.max(productOption.getPrice({ currency: false }), this.price.max);
|
|
66
|
+
this.price.monthly.min = Math.min(productOption.getPrice({ monthly: true, currency: false }), this.price.monthly.min);
|
|
67
|
+
this.price.monthly.max = Math.max(productOption.getPrice({ monthly: true, currency: false }), this.price.monthly.max);
|
|
68
|
+
this.discountedPrice.min = Math.min(productOption.getDiscountedPrice({ currency: false }), this.discountedPrice.min);
|
|
69
|
+
this.discountedPrice.max = Math.max(productOption.getDiscountedPrice({ currency: false }), this.discountedPrice.max);
|
|
70
|
+
this.discountedPrice.monthly.min = Math.min(productOption.getDiscountedPrice({ monthly: true, currency: false }), this.discountedPrice.monthly.min);
|
|
71
|
+
this.discountedPrice.monthly.max = Math.max(productOption.getDiscountedPrice({ monthly: true, currency: false }), this.discountedPrice.monthly.max);
|
|
72
|
+
this.devices.min = Math.min(productOption.getDevices(), this.devices.min);
|
|
73
|
+
this.devices.max = Math.max(productOption.getDevices(), this.devices.max);
|
|
74
|
+
devices.add(productOption.getDevices());
|
|
75
|
+
this.subscriptions.min = Math.min(productOption.getSubscription(), this.subscriptions.min);
|
|
76
|
+
this.subscriptions.max = Math.max(productOption.getSubscription(), this.subscriptions.max);
|
|
77
|
+
subscriptions.add(productOption.getSubscription());
|
|
78
|
+
this.discount.min = Math.min(productOption.getDiscount({ symbol: false }), this.discount.min);
|
|
79
|
+
this.discount.max = Math.max(productOption.getDiscount({ symbol: false }), this.discount.max);
|
|
80
|
+
this.discount.percentage.min = Math.min(productOption.getDiscount({ percentage: true, symbol: false }), this.discount.percentage.min);
|
|
81
|
+
this.discount.percentage.max = Math.max(productOption.getDiscount({ percentage: true, symbol: false }), this.discount.percentage.max);
|
|
82
|
+
}
|
|
83
|
+
this.devices.values = [...devices];
|
|
84
|
+
this.subscriptions.values = [...subscriptions];
|
|
85
|
+
}
|
|
86
|
+
getStore() {
|
|
87
|
+
return this.store;
|
|
88
|
+
}
|
|
89
|
+
getId() {
|
|
90
|
+
return this.id;
|
|
91
|
+
}
|
|
92
|
+
getPlatformId() {
|
|
93
|
+
return this.platformId;
|
|
94
|
+
}
|
|
95
|
+
getName() {
|
|
96
|
+
return this.name;
|
|
97
|
+
}
|
|
98
|
+
getCampaign() {
|
|
99
|
+
return this.campaign;
|
|
100
|
+
}
|
|
101
|
+
getCurrency() {
|
|
102
|
+
return this.currency;
|
|
103
|
+
}
|
|
104
|
+
async getOption(param) {
|
|
105
|
+
const adaptor = await this.store?.adaptor;
|
|
106
|
+
const { devices, subscription } = await adaptor.adaptTo({
|
|
107
|
+
id: this.id,
|
|
108
|
+
subscription: Number(param?.subscription),
|
|
109
|
+
devices: Number(param?.devices)
|
|
110
|
+
});
|
|
111
|
+
const bundle = param?.bundle?.filter((option) => Boolean(option));
|
|
112
|
+
const makeBundle = async (option, bundle) => new ProductOption({ ...(await this.bundle(option, bundle)), product: this });
|
|
113
|
+
if (Number(devices) && Number(subscription)) {
|
|
114
|
+
const option = this.options.get(`${devices}-${subscription}`);
|
|
115
|
+
if (!option)
|
|
116
|
+
return undefined;
|
|
117
|
+
//bundle with the option
|
|
118
|
+
if (bundle) {
|
|
119
|
+
return await makeBundle(option, bundle);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return option;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (bundle) {
|
|
126
|
+
const optionsWithBundle = [...this.options.values()].map(option => makeBundle(option, bundle));
|
|
127
|
+
const settled = await Promise.allSettled(optionsWithBundle);
|
|
128
|
+
return settled
|
|
129
|
+
.map((result) => result.status === "fulfilled" ? result.value : undefined);
|
|
130
|
+
}
|
|
131
|
+
//return all options
|
|
132
|
+
return [...this.options.values()];
|
|
133
|
+
}
|
|
134
|
+
[setOption](param) {
|
|
135
|
+
const options = Array.isArray(param.options) ? param.options : [param.options];
|
|
136
|
+
for (const option of options) {
|
|
137
|
+
const devices = option.getDevices();
|
|
138
|
+
const subscription = option.getDevices();
|
|
139
|
+
this.options.set(`${devices}-${subscription}`, option);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
getPrice(param) {
|
|
143
|
+
const { monthly = false, currency = true } = param ?? {};
|
|
144
|
+
const price = monthly
|
|
145
|
+
? this.price.monthly
|
|
146
|
+
: this.price;
|
|
147
|
+
if (currency) {
|
|
148
|
+
return {
|
|
149
|
+
min: formatPrice({ price: price.min, currency: this.currency }),
|
|
150
|
+
max: formatPrice({ price: price.max, currency: this.currency })
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
min: price.min,
|
|
155
|
+
max: price.max
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
getDiscountedPrice(param) {
|
|
159
|
+
const { monthly = false, currency = true } = param ?? {};
|
|
160
|
+
const discountedPrice = monthly
|
|
161
|
+
? this.discountedPrice.monthly
|
|
162
|
+
: this.discountedPrice;
|
|
163
|
+
if (currency) {
|
|
164
|
+
return {
|
|
165
|
+
min: formatPrice({ price: discountedPrice.min, currency: this.currency }),
|
|
166
|
+
max: formatPrice({ price: discountedPrice.max, currency: this.currency })
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
min: discountedPrice.min,
|
|
171
|
+
max: discountedPrice.max
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
getDiscount(param) {
|
|
175
|
+
const { percentage = false, symbol = true } = param ?? {};
|
|
176
|
+
const discountValue = percentage
|
|
177
|
+
? this.discount.percentage
|
|
178
|
+
: this.discount;
|
|
179
|
+
if (percentage) {
|
|
180
|
+
return symbol
|
|
181
|
+
? { min: `${discountValue.min}%`, max: `${discountValue.max}%` }
|
|
182
|
+
: { min: discountValue.min, max: discountValue.max };
|
|
183
|
+
}
|
|
184
|
+
return symbol
|
|
185
|
+
? {
|
|
186
|
+
min: formatPrice({ price: discountValue.min, currency: this.currency }),
|
|
187
|
+
max: formatPrice({ price: discountValue.max, currency: this.currency })
|
|
188
|
+
}
|
|
189
|
+
: {
|
|
190
|
+
min: discountValue.min,
|
|
191
|
+
max: discountValue.max
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
getDevices() {
|
|
195
|
+
return this.devices;
|
|
196
|
+
}
|
|
197
|
+
getSubscriptions() {
|
|
198
|
+
return this.subscriptions;
|
|
199
|
+
}
|
|
200
|
+
async bundle(base, options) {
|
|
201
|
+
const round = (n) => Number(n.toFixed(2));
|
|
202
|
+
// Start with the first option as the base
|
|
203
|
+
const bundledOption = {
|
|
204
|
+
price: base.getPrice({ currency: false }),
|
|
205
|
+
discountedPrice: base.getDiscountedPrice({ currency: false }),
|
|
206
|
+
buyLink: base.getBuyLink(),
|
|
207
|
+
subscription: base.getSubscription(),
|
|
208
|
+
devices: base.getDevices()
|
|
209
|
+
};
|
|
210
|
+
// Process the remaining options
|
|
211
|
+
for (const option of options.slice(1)) {
|
|
212
|
+
const optionPrice = option.getPrice({ currency: false });
|
|
213
|
+
const optionDiscountedPrice = option.getDiscountedPrice({ currency: false });
|
|
214
|
+
// Always add the option's price to the bundled price
|
|
215
|
+
bundledOption.price = round(bundledOption.price + optionPrice);
|
|
216
|
+
if (optionDiscountedPrice) {
|
|
217
|
+
if (bundledOption.discountedPrice) {
|
|
218
|
+
// Both exist: add them together
|
|
219
|
+
bundledOption.discountedPrice = round(bundledOption.discountedPrice + optionDiscountedPrice);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
// If no current discountedPrice, base it on the updated price
|
|
223
|
+
bundledOption.discountedPrice = round(bundledOption.price + optionDiscountedPrice);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if (bundledOption.discountedPrice) {
|
|
227
|
+
// If option lacks a discountedPrice but bundledOption already has one,
|
|
228
|
+
// update the bundled price using the existing discounted value.
|
|
229
|
+
bundledOption.price = round(bundledOption.discountedPrice + optionPrice);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return bundledOption;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=product.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.base.js","sourceRoot":"","sources":["../../../src/products/product.base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAqB,MAAM,+BAA+B,CAAC;AAejF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAuB9C,MAAM,OAAO,OAAO;IACV,KAAK,CAAkB;IACvB,IAAI,CAAoB;IACxB,QAAQ,CAAgB;IACxB,EAAE,CAAsB;IACxB,QAAQ,CAAgB;IACxB,OAAO,CAAqC;IAC5C,UAAU,CAAc;IACxB,OAAO,CAAsB;IAC7B,aAAa,CAAqB;IAClC,QAAQ,CAAsB;IAC9B,KAAK,CAAuB;IAC5B,eAAe,CAAY;IAEnC,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,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,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AAI,CAAC,UAAU,EAAE;YAClC,YAAY,EAAK,IAAI,CAAC,eAAe,EAAE;YACvC,OAAO,EAAU,IAAI,CAAC,UAAU,EAAE;SACnC,CAAC;QAEF,gCAAgC;QAChC,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YACzD,MAAM,qBAAqB,GAAG,MAAM,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YAE7E,qDAAqD;YACrD,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC;YAE/D,IAAI,qBAAqB,EAAE,CAAC;gBAC1B,IAAI,aAAa,CAAC,eAAe,EAAE,CAAC;oBAClC,gCAAgC;oBAChC,aAAa,CAAC,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,eAAe,GAAG,qBAAqB,CAAC,CAAC;gBAC/F,CAAC;qBAAM,CAAC;oBACN,8DAA8D;oBAC9D,aAAa,CAAC,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProductOption } from "../product-options/option.base.js";
|
|
2
|
+
import { Product, ProductData, UnboundProductOptionData } from "../products/product.base.js";
|
|
3
|
+
export declare class InitSelectorProduct extends Product {
|
|
4
|
+
constructor(product: ProductData);
|
|
5
|
+
protected bundle(base: ProductOption, options: ProductOption[]): Promise<UnboundProductOptionData>;
|
|
6
|
+
private hasVpnOption;
|
|
7
|
+
private applyVpnBundle;
|
|
8
|
+
private getSmallBusinessBundleMapping;
|
|
9
|
+
private applySmallBusinessBundle;
|
|
10
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Product } from "../products/product.base.js";
|
|
2
|
+
const bundleIds = {
|
|
3
|
+
"smallbs.bs_nadrm.bs_wadc": {
|
|
4
|
+
id: "b_wa_na",
|
|
5
|
+
coupon: "COUPON.GravityZone-30OFF"
|
|
6
|
+
},
|
|
7
|
+
"smallbs.bs_wadc.bs_nadrm": {
|
|
8
|
+
id: "b_wa_na",
|
|
9
|
+
coupon: "COUPON.GravityZone-30OFF"
|
|
10
|
+
},
|
|
11
|
+
"smallbs.bs_wadc": {
|
|
12
|
+
id: "b_wa",
|
|
13
|
+
coupon: "COUPON.GravityZone-30OFF"
|
|
14
|
+
},
|
|
15
|
+
"smallbs.bs_nadrm": {
|
|
16
|
+
id: "b_na",
|
|
17
|
+
coupon: "COUPON.GravityZone-30OFF"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export class InitSelectorProduct extends Product {
|
|
21
|
+
constructor(product) {
|
|
22
|
+
super(product);
|
|
23
|
+
}
|
|
24
|
+
async bundle(base, options) {
|
|
25
|
+
// Get the base bundle from common logic.
|
|
26
|
+
const bundleOption = await super.bundle(base, options);
|
|
27
|
+
// First, check for a VPN bundle override.
|
|
28
|
+
if (this.hasVpnOption(base, options)) {
|
|
29
|
+
bundleOption.buyLink = this.applyVpnBundle(bundleOption.buyLink);
|
|
30
|
+
return bundleOption;
|
|
31
|
+
}
|
|
32
|
+
// Otherwise, check if there's a small business bundle mapping.
|
|
33
|
+
const mapping = this.getSmallBusinessBundleMapping(base, options);
|
|
34
|
+
if (mapping) {
|
|
35
|
+
bundleOption.buyLink = this.applySmallBusinessBundle(bundleOption.buyLink, mapping);
|
|
36
|
+
}
|
|
37
|
+
return bundleOption;
|
|
38
|
+
}
|
|
39
|
+
// Returns true if any option is for the VPN product.
|
|
40
|
+
hasVpnOption(base, options) {
|
|
41
|
+
const isVpnInOptions = options.some(option => option.getProduct().getId() === "com.bitdefender.vpn");
|
|
42
|
+
const isBaseVpn = base.getProduct().getId() === "com.bitdefender.vpn";
|
|
43
|
+
return isVpnInOptions || isBaseVpn;
|
|
44
|
+
}
|
|
45
|
+
// For VPN bundles, we adjust the buyLink by replacing "buy" with "buybundle".
|
|
46
|
+
applyVpnBundle(buyLink) {
|
|
47
|
+
return buyLink.replace("buy", "buybundle");
|
|
48
|
+
}
|
|
49
|
+
// Build the key and lookup a small business bundle mapping, if any.
|
|
50
|
+
getSmallBusinessBundleMapping(base, options) {
|
|
51
|
+
const baseId = base.getProduct().getId();
|
|
52
|
+
const optionsBundleId = options
|
|
53
|
+
.map(option => option.getProduct().getId())
|
|
54
|
+
.join(".");
|
|
55
|
+
const key = `${baseId}.${optionsBundleId}`;
|
|
56
|
+
return bundleIds[key];
|
|
57
|
+
}
|
|
58
|
+
// Adjust the buyLink using the small business bundle mapping.
|
|
59
|
+
applySmallBusinessBundle(originalBuyLink, mapping) {
|
|
60
|
+
// Create a URL from the original buyLink.
|
|
61
|
+
const url = new URL(originalBuyLink, globalThis?.location?.origin);
|
|
62
|
+
// Split the pathname and filter out empty parts.
|
|
63
|
+
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
64
|
+
// Expecting a pathname structure like: [site, store, method, _, devices, subscription, pid?]
|
|
65
|
+
if (pathParts.length < 6) {
|
|
66
|
+
// If the structure is unexpected, return the original link.
|
|
67
|
+
return originalBuyLink;
|
|
68
|
+
}
|
|
69
|
+
// Destructure expected parts.
|
|
70
|
+
const [site, store, method, , devices, subscription, pid] = pathParts;
|
|
71
|
+
// Build the new path with the bundle mapping's id.
|
|
72
|
+
const newPath = `/${[site, store, method, mapping.id, devices, subscription, pid || mapping.coupon].join("/")}`;
|
|
73
|
+
url.pathname = newPath;
|
|
74
|
+
return url.href;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=product.init-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.init-selector.js","sourceRoot":"","sources":["../../../src/products/product.init-selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAyC,MAAM,yBAAyB,CAAC;AAEzF,MAAM,SAAS,GAAG;IAChB,0BAA0B,EAAE;QAC1B,EAAE,EAAM,SAAS;QACjB,MAAM,EAAE,0BAA0B;KACnC;IACD,0BAA0B,EAAE;QAC1B,EAAE,EAAM,SAAS;QACjB,MAAM,EAAE,0BAA0B;KACnC;IACD,iBAAiB,EAAE;QACjB,EAAE,EAAM,MAAM;QACd,MAAM,EAAE,0BAA0B;KACnC;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAM,MAAM;QACd,MAAM,EAAE,0BAA0B;KACnC;CACO,CAAC;AAEX,MAAM,OAAO,mBAAoB,SAAQ,OAAO;IAC9C,YAAY,OAAoB;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAES,KAAK,CAAC,MAAM,CACpB,IAAmB,EACnB,OAAwB;QAExB,yCAAyC;QACzC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvD,0CAA0C;QAC1C,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YACrC,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACjE,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,+DAA+D;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAClE,IAAI,OAAO,EAAE,CAAC;YACZ,YAAY,CAAC,OAAO,GAAG,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AAC,OAAO,CAAC,CAAC;QAE1D,6FAA6F;QAC7F,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,4DAA4D;YAC5D,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,8BAA8B;QAC9B,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,AAAD,EAAG,OAAO,EAAE,YAAY,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;QACtE,mDAAmD;QACnD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChH,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC;QACvB,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProductOption } from "../product-options/option.base.js";
|
|
2
|
+
import { Product, ProductData, UnboundProductOptionData } from "../products/product.base.js";
|
|
3
|
+
export declare class VlaicuProduct extends Product {
|
|
4
|
+
constructor(product: ProductData);
|
|
5
|
+
protected bundle(base: ProductOption, options: ProductOption[]): Promise<UnboundProductOptionData>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Product } from "../products/product.base.js";
|
|
2
|
+
export class VlaicuProduct extends Product {
|
|
3
|
+
constructor(product) {
|
|
4
|
+
super(product);
|
|
5
|
+
}
|
|
6
|
+
async bundle(base, options) {
|
|
7
|
+
// Get the base bundle from common logic.
|
|
8
|
+
const bundleOption = await super.bundle(base, options);
|
|
9
|
+
const locale = this.getStore().locale;
|
|
10
|
+
const campaign = this.getCampaign();
|
|
11
|
+
const url = new URL(`https://www.bitdefender.com/p-api/v1/buy-links/locale/${locale}`);
|
|
12
|
+
if (campaign) {
|
|
13
|
+
url.searchParams.set("campaign", campaign);
|
|
14
|
+
}
|
|
15
|
+
const bundles = [base, ...options]
|
|
16
|
+
.map(option => `${option.getProduct().getId()}|${option.getDevices()}|${option.getSubscription()}`)
|
|
17
|
+
.join(",");
|
|
18
|
+
if (bundles) {
|
|
19
|
+
url.searchParams.set("bundles", bundles);
|
|
20
|
+
}
|
|
21
|
+
const res = await fetch(url);
|
|
22
|
+
if (res.ok) {
|
|
23
|
+
const data = await res.json();
|
|
24
|
+
bundleOption.buyLink = data.buyLink;
|
|
25
|
+
}
|
|
26
|
+
return bundleOption;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=product.vlaicu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.vlaicu.js","sourceRoot":"","sources":["../../../src/products/product.vlaicu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAyC,MAAM,yBAAyB,CAAC;AAEzF,MAAM,OAAO,aAAc,SAAQ,OAAO;IACxC,YAAY,OAAoB;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAES,KAAK,CAAC,MAAM,CACpB,IAAmB,EACnB,OAAwB;QAExB,yCAAyC;QACzC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,yDAAyD,MAAM,EAAE,CAAC,CAAA;QAEtF,IAAI,QAAQ,EAAE,CAAC;YACb,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC;aAC/B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,IAAI,MAAM,CAAC,eAAe,EAAE,EAAE,CAAC;aAClG,IAAI,CAAC,GAAG,CAAC,CAAA;QAEZ,IAAI,OAAO,EAAE,CAAC;YACZ,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAE7B,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;YACX,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QACtC,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Product } from "../products/product.base.js";
|
|
2
|
+
import { ProductSelector } from "../store.js";
|
|
3
|
+
import { Provider, ProviderData } from "./provider.interface.js";
|
|
4
|
+
export interface FetchResponse {
|
|
5
|
+
code: number;
|
|
6
|
+
data: {
|
|
7
|
+
product: ProductData;
|
|
8
|
+
config: ConfigData;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface ProductData {
|
|
12
|
+
product_id: string;
|
|
13
|
+
product_name: string;
|
|
14
|
+
product_type: string;
|
|
15
|
+
product_alias: string;
|
|
16
|
+
product_active: string;
|
|
17
|
+
base_uri: string;
|
|
18
|
+
variations: VariationsData;
|
|
19
|
+
}
|
|
20
|
+
export type VariationsData = Record<string, Record<string, VariationData>>;
|
|
21
|
+
export interface VariationData {
|
|
22
|
+
product_id: string;
|
|
23
|
+
region_id: string;
|
|
24
|
+
variation_id: string;
|
|
25
|
+
platform_id: string;
|
|
26
|
+
platform_product_id: string;
|
|
27
|
+
price: string;
|
|
28
|
+
currency_id: string;
|
|
29
|
+
in_selector: string;
|
|
30
|
+
active_platform: string;
|
|
31
|
+
variation_active: string;
|
|
32
|
+
avangate_variation_prefix: string;
|
|
33
|
+
variation: VariationDetail;
|
|
34
|
+
currency_label: string;
|
|
35
|
+
currency_iso: string;
|
|
36
|
+
discount?: DiscountData;
|
|
37
|
+
promotion?: string;
|
|
38
|
+
promotion_functions?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface VariationDetail {
|
|
41
|
+
variation_id: string;
|
|
42
|
+
variation_name: string;
|
|
43
|
+
dimension_id: string;
|
|
44
|
+
dimension_value: string;
|
|
45
|
+
years: string;
|
|
46
|
+
}
|
|
47
|
+
export interface DiscountData {
|
|
48
|
+
discounted_price: string;
|
|
49
|
+
discount_value: string;
|
|
50
|
+
discount_type: number;
|
|
51
|
+
}
|
|
52
|
+
export interface ConfigData {
|
|
53
|
+
country_code: string;
|
|
54
|
+
extra_params: {
|
|
55
|
+
pid: string | null;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export declare class InitSelectorProvider implements Provider {
|
|
59
|
+
private country;
|
|
60
|
+
private language;
|
|
61
|
+
private store;
|
|
62
|
+
constructor({ store }: ProviderData);
|
|
63
|
+
getProduct({ id, campaign }: ProductSelector): Promise<Product | undefined>;
|
|
64
|
+
private buildPayload;
|
|
65
|
+
private buildApiURL;
|
|
66
|
+
private processVariations;
|
|
67
|
+
private buildBuyLink;
|
|
68
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Product } from "../products/product.base.js";
|
|
2
|
+
import { INGNORE_CAMPAIGN } from "./provider.interface.js";
|
|
3
|
+
const countriesMapping = new Map([
|
|
4
|
+
["gb", "uk"],
|
|
5
|
+
["ch", "de"],
|
|
6
|
+
["at", "de"],
|
|
7
|
+
["us", "us"],
|
|
8
|
+
["mx", "en"],
|
|
9
|
+
["nz", "au"]
|
|
10
|
+
]);
|
|
11
|
+
const getCountry = (country) => countriesMapping.get(country) ?? country;
|
|
12
|
+
export class InitSelectorProvider {
|
|
13
|
+
country;
|
|
14
|
+
language;
|
|
15
|
+
store;
|
|
16
|
+
constructor({ store }) {
|
|
17
|
+
this.store = store;
|
|
18
|
+
const [language, country] = store.locale.split("-");
|
|
19
|
+
this.language = language;
|
|
20
|
+
this.country = getCountry(country);
|
|
21
|
+
}
|
|
22
|
+
async getProduct({ id, campaign }) {
|
|
23
|
+
const adaptor = await this.store.adaptor;
|
|
24
|
+
const computedCampaign = await this.store.getCampaign({ id, campaign });
|
|
25
|
+
const payload = this.buildPayload(id, computedCampaign);
|
|
26
|
+
const apiURL = this.buildApiURL();
|
|
27
|
+
let fetchResponse;
|
|
28
|
+
try {
|
|
29
|
+
const formData = new FormData();
|
|
30
|
+
formData.append("data", payload);
|
|
31
|
+
const response = await fetch(apiURL.href, {
|
|
32
|
+
method: "post",
|
|
33
|
+
body: formData
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok)
|
|
36
|
+
return undefined;
|
|
37
|
+
fetchResponse = await response.json();
|
|
38
|
+
// Ensure variations exist.
|
|
39
|
+
if (!fetchResponse.data.product.variations ||
|
|
40
|
+
Object.keys(fetchResponse.data.product.variations).length === 0) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error("Failed to fetch product:", error);
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
// Process variations into option data.
|
|
49
|
+
const { options, platformId, currency } = await this.processVariations(id, fetchResponse.data.product.variations, adaptor, computedCampaign);
|
|
50
|
+
// Return a new Product.
|
|
51
|
+
return new Product({
|
|
52
|
+
id: (await adaptor.adaptTo({ id })).id,
|
|
53
|
+
name: fetchResponse.data.product.product_name,
|
|
54
|
+
store: this.store,
|
|
55
|
+
campaign: computedCampaign,
|
|
56
|
+
currency,
|
|
57
|
+
platformId,
|
|
58
|
+
options
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
buildPayload(id, campaign) {
|
|
62
|
+
const config = { country_code: this.country };
|
|
63
|
+
if (INGNORE_CAMPAIGN.includes(String(campaign))) {
|
|
64
|
+
config.ignore_promotions = true;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
config.extra_params = { pid: campaign || null };
|
|
68
|
+
}
|
|
69
|
+
return JSON.stringify({
|
|
70
|
+
ev: 1,
|
|
71
|
+
product_id: id,
|
|
72
|
+
config
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
buildApiURL() {
|
|
76
|
+
const url = new URL("https://www.bitdefender.com/site/Store/ajax");
|
|
77
|
+
url.searchParams.set("force_country", this.country);
|
|
78
|
+
return url;
|
|
79
|
+
}
|
|
80
|
+
async processVariations(id, variations, adaptor, campaign) {
|
|
81
|
+
const options = new Map();
|
|
82
|
+
let platformId = "";
|
|
83
|
+
let currency = "";
|
|
84
|
+
// Loop through devices and subscriptions.
|
|
85
|
+
for (const [devices, devicesValue] of Object.entries(variations)) {
|
|
86
|
+
for (const [subscription, subscriptionsValue] of Object.entries(devicesValue)) {
|
|
87
|
+
const adaptedVariation = await adaptor.adaptTo({
|
|
88
|
+
id,
|
|
89
|
+
subscription: Number(subscription),
|
|
90
|
+
devices: Number(devices)
|
|
91
|
+
});
|
|
92
|
+
const variationData = {
|
|
93
|
+
devices: adaptedVariation.devices,
|
|
94
|
+
subscription: adaptedVariation.subscription,
|
|
95
|
+
price: Number(subscriptionsValue.price),
|
|
96
|
+
discountedPrice: Number(subscriptionsValue.discount?.discounted_price || 0),
|
|
97
|
+
buyLink: "" // To be computed below.
|
|
98
|
+
};
|
|
99
|
+
// Capture common info.
|
|
100
|
+
platformId = subscriptionsValue.platform_product_id;
|
|
101
|
+
currency = subscriptionsValue.currency_iso;
|
|
102
|
+
//compute buy link
|
|
103
|
+
variationData.buyLink = this.buildBuyLink(id, variationData, subscriptionsValue, campaign);
|
|
104
|
+
//apply transforms
|
|
105
|
+
// if (this.store.transformers?.product) {
|
|
106
|
+
// variationData = await this.store.transformers?.product?.getOption?.(variationData);
|
|
107
|
+
// }
|
|
108
|
+
// if (this.store.transformers?.product?.getOption) {
|
|
109
|
+
// variationData = await this.store.transformers?.product?.getOption(variationData);
|
|
110
|
+
// }
|
|
111
|
+
options.set(`${adaptedVariation.devices}-${adaptedVariation.subscription}`, variationData);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { options, platformId, currency };
|
|
115
|
+
}
|
|
116
|
+
buildBuyLink(id, variation, subscriptionsValue, campaign) {
|
|
117
|
+
const buyLinkRouteParams = ["buy", id, variation.devices, variation.subscription].join("/");
|
|
118
|
+
// Build base URL; include campaign pid if available.
|
|
119
|
+
const pathSuffix = campaign ? `pid.${campaign}` : "";
|
|
120
|
+
const url = new URL(`https://www.bitdefender.com/site/Store/${buyLinkRouteParams}/${pathSuffix}`);
|
|
121
|
+
url.searchParams.set("CURRENCY", subscriptionsValue.currency_iso);
|
|
122
|
+
url.searchParams.set("DCURRENCY", subscriptionsValue.currency_iso);
|
|
123
|
+
url.searchParams.set("CART", "1");
|
|
124
|
+
url.searchParams.set("CARD", "2");
|
|
125
|
+
url.searchParams.set("SHORT_FORM", "1");
|
|
126
|
+
url.searchParams.set("LANG", this.language);
|
|
127
|
+
url.searchParams.set("force_country", this.country);
|
|
128
|
+
return url.href;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=provider.init-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.init-selector.js","sourceRoot":"","sources":["../../../src/providers/provider.init-selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA4B,MAAM,4BAA4B,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAA0B,MAAM,yBAAyB,CAAC;AA+DnF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAA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CAAC,CAAC;QAClE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACnE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QACxC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Product } from "../products/product.base.js";
|
|
2
|
+
import { ProductSelector, Store } from "../store.js";
|
|
3
|
+
export type ProviderData = {
|
|
4
|
+
store: Store;
|
|
5
|
+
};
|
|
6
|
+
export declare const INGNORE_CAMPAIGN: string[];
|
|
7
|
+
export interface Provider {
|
|
8
|
+
getProduct(param: ProductSelector): Promise<Product | undefined>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.interface.js","sourceRoot":"","sources":["../../../src/providers/provider.interface.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Product } from "../products/product.base.js";
|
|
2
|
+
import { Provider, ProviderData } from "./provider.interface.js";
|
|
3
|
+
export declare class VlaicuProvider implements Provider {
|
|
4
|
+
private store;
|
|
5
|
+
constructor(param: ProviderData);
|
|
6
|
+
getProduct(): Promise<Product | undefined>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.vlaicu.js","sourceRoot":"","sources":["../../../src/providers/provider.vlaicu.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,cAAc;IACjB,KAAK,CAAQ;IAErB,YAAY,KAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAa,CAAC;IACvB,CAAC;CACF"}
|