@unchainedshop/plugins 2.0.0-rc.4 → 2.0.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/jest.config.js +12 -0
- package/lib/enrollments/licensed.d.ts +4 -1
- package/lib/enrollments/licensed.js +1 -1
- package/lib/enrollments/licensed.js.map +1 -1
- package/lib/files/gridfs/index.js +12 -3
- package/lib/files/gridfs/index.js.map +1 -1
- package/lib/plugins-index.d.ts +1 -0
- package/lib/plugins-index.js +1 -0
- package/lib/plugins-index.js.map +1 -1
- package/lib/pricing/discount-100-off.d.ts +2 -1
- package/lib/pricing/discount-100-off.js +1 -1
- package/lib/pricing/discount-100-off.js.map +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts +2 -1
- package/lib/pricing/discount-half-price-manual.js +1 -1
- package/lib/pricing/discount-half-price-manual.js.map +1 -1
- package/lib/pricing/discount-half-price.d.ts +2 -1
- package/lib/pricing/discount-half-price.js +1 -1
- package/lib/pricing/discount-half-price.js.map +1 -1
- package/lib/pricing/order-delivery.d.ts +2 -1
- package/lib/pricing/order-delivery.js +1 -1
- package/lib/pricing/order-delivery.js.map +1 -1
- package/lib/pricing/order-discount.d.ts +10 -1
- package/lib/pricing/order-discount.js +5 -4
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +4 -0
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +2 -1
- package/lib/pricing/product-catalog-price.js +1 -1
- package/lib/pricing/product-catalog-price.js.map +1 -1
- package/lib/pricing/product-discount.d.ts +2 -1
- package/lib/pricing/product-discount.js +2 -2
- package/lib/pricing/product-discount.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts +2 -1
- package/lib/pricing/product-price-rateconversion.js +1 -1
- package/lib/pricing/product-price-rateconversion.js.map +1 -1
- package/lib/pricing/product-price-round.d.ts +2 -0
- package/lib/pricing/product-price-round.js +3 -3
- package/lib/pricing/product-price-round.js.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +8 -0
- package/lib/pricing/product-swiss-tax.js +3 -3
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/worker/email.d.ts +1 -1
- package/lib/worker/email.js +1 -1
- package/lib/worker/email.js.map +1 -1
- package/lib/worker/push-notification.d.ts +1 -0
- package/lib/worker/push-notification.js +73 -0
- package/lib/worker/push-notification.js.map +1 -0
- package/package.json +22 -22
- package/src/enrollments/licensed.ts +1 -1
- package/src/files/gridfs/index.ts +14 -3
- package/src/plugins-index.ts +1 -0
- package/src/pricing/apply-rate.test.ts +92 -0
- package/src/pricing/configureProductPriceRounding.test.ts +44 -0
- package/src/pricing/discount-100-off.test.ts +31 -0
- package/src/pricing/discount-100-off.ts +1 -1
- package/src/pricing/discount-half-price-manual.test.ts +42 -0
- package/src/pricing/discount-half-price-manual.ts +1 -1
- package/src/pricing/discount-half-price.test.ts +40 -0
- package/src/pricing/discount-half-price.ts +1 -1
- package/src/pricing/free-delivery.test.ts +12 -0
- package/src/pricing/getTaxRate.test.ts +69 -0
- package/src/pricing/licenced-enrollment.test.ts +37 -0
- package/src/pricing/order-delivery.test.ts +9 -0
- package/src/pricing/order-delivery.ts +1 -1
- package/src/pricing/order-discount.test.ts +206 -0
- package/src/pricing/order-discount.ts +6 -4
- package/src/pricing/order-items-discount.ts +4 -1
- package/{tests/plugins-index.test.js → src/pricing/plugins-index.test.ts} +0 -0
- package/src/pricing/product-catalog-price.ts +1 -1
- package/src/pricing/product-discount.ts +2 -2
- package/src/pricing/product-price-rateconversion.ts +1 -1
- package/src/pricing/product-price-round.ts +4 -4
- package/src/pricing/product-swiss-tax.test.ts +141 -0
- package/src/pricing/product-swiss-tax.ts +3 -3
- package/src/pricing/roundToNext.test.ts +24 -0
- package/src/worker/email.ts +1 -1
- package/src/worker/push-notification.ts +106 -0
- package/tsconfig.json +3 -22
- package/lib/pricing/utils/cache.d.ts +0 -9
- package/lib/pricing/utils/cache.js +0 -29
- package/lib/pricing/utils/cache.js.map +0 -1
- package/src/pricing/utils/cache.ts +0 -34
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import 'abort-controller/polyfill.js';
|
|
2
|
-
import LRUCache from 'lru-cache';
|
|
3
|
-
class Cache {
|
|
4
|
-
cache;
|
|
5
|
-
constructor(ttlSeconds = 60) {
|
|
6
|
-
this.cache = new LRUCache({
|
|
7
|
-
max: 500,
|
|
8
|
-
ttl: ttlSeconds * 1000,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
get(key, currentFuntion) {
|
|
12
|
-
const value = this.cache.get(key);
|
|
13
|
-
if (value) {
|
|
14
|
-
return Promise.resolve(value);
|
|
15
|
-
}
|
|
16
|
-
return currentFuntion().then((result) => {
|
|
17
|
-
this.cache.set(key, result);
|
|
18
|
-
return result;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
del(keys) {
|
|
22
|
-
this.cache.del(keys);
|
|
23
|
-
}
|
|
24
|
-
flushAll() {
|
|
25
|
-
this.cache.reset();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export default Cache;
|
|
29
|
-
//# sourceMappingURL=cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/pricing/utils/cache.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AACtC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,KAAK;IACT,KAAK,CAAC;IAEN,YAAY,UAAU,GAAG,EAAE;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC;YACxB,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,UAAU,GAAG,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,GAAG,EAAE,cAAc;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,EAAE;YACT,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC/B;QACD,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACtC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC5B,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,IAAI;QACN,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import 'abort-controller/polyfill.js';
|
|
2
|
-
import LRUCache from 'lru-cache';
|
|
3
|
-
|
|
4
|
-
class Cache {
|
|
5
|
-
cache;
|
|
6
|
-
|
|
7
|
-
constructor(ttlSeconds = 60) {
|
|
8
|
-
this.cache = new LRUCache({
|
|
9
|
-
max: 500,
|
|
10
|
-
ttl: ttlSeconds * 1000,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get(key, currentFuntion) {
|
|
15
|
-
const value = this.cache.get(key);
|
|
16
|
-
if (value) {
|
|
17
|
-
return Promise.resolve(value);
|
|
18
|
-
}
|
|
19
|
-
return currentFuntion().then((result) => {
|
|
20
|
-
this.cache.set(key, result);
|
|
21
|
-
return result;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
del(keys) {
|
|
26
|
-
this.cache.del(keys);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
flushAll() {
|
|
30
|
-
this.cache.reset();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default Cache;
|