@unchainedshop/plugins 2.0.0-rc.4 → 2.0.1

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 (82) hide show
  1. package/jest.config.js +12 -0
  2. package/lib/enrollments/licensed.d.ts +4 -1
  3. package/lib/enrollments/licensed.js +1 -1
  4. package/lib/enrollments/licensed.js.map +1 -1
  5. package/lib/files/gridfs/index.js +12 -3
  6. package/lib/files/gridfs/index.js.map +1 -1
  7. package/lib/plugins-index.d.ts +1 -0
  8. package/lib/plugins-index.js +1 -0
  9. package/lib/plugins-index.js.map +1 -1
  10. package/lib/pricing/discount-100-off.d.ts +2 -1
  11. package/lib/pricing/discount-100-off.js +1 -1
  12. package/lib/pricing/discount-100-off.js.map +1 -1
  13. package/lib/pricing/discount-half-price-manual.d.ts +2 -1
  14. package/lib/pricing/discount-half-price-manual.js +1 -1
  15. package/lib/pricing/discount-half-price-manual.js.map +1 -1
  16. package/lib/pricing/discount-half-price.d.ts +2 -1
  17. package/lib/pricing/discount-half-price.js +1 -1
  18. package/lib/pricing/discount-half-price.js.map +1 -1
  19. package/lib/pricing/order-delivery.d.ts +2 -1
  20. package/lib/pricing/order-delivery.js +1 -1
  21. package/lib/pricing/order-delivery.js.map +1 -1
  22. package/lib/pricing/order-discount.d.ts +10 -1
  23. package/lib/pricing/order-discount.js +5 -4
  24. package/lib/pricing/order-discount.js.map +1 -1
  25. package/lib/pricing/order-items-discount.js +4 -0
  26. package/lib/pricing/order-items-discount.js.map +1 -1
  27. package/lib/pricing/product-catalog-price.d.ts +2 -1
  28. package/lib/pricing/product-catalog-price.js +1 -1
  29. package/lib/pricing/product-catalog-price.js.map +1 -1
  30. package/lib/pricing/product-discount.d.ts +2 -1
  31. package/lib/pricing/product-discount.js +2 -2
  32. package/lib/pricing/product-discount.js.map +1 -1
  33. package/lib/pricing/product-price-rateconversion.d.ts +2 -1
  34. package/lib/pricing/product-price-rateconversion.js +1 -1
  35. package/lib/pricing/product-price-rateconversion.js.map +1 -1
  36. package/lib/pricing/product-price-round.d.ts +2 -0
  37. package/lib/pricing/product-price-round.js +3 -3
  38. package/lib/pricing/product-price-round.js.map +1 -1
  39. package/lib/pricing/product-swiss-tax.d.ts +8 -0
  40. package/lib/pricing/product-swiss-tax.js +3 -3
  41. package/lib/pricing/product-swiss-tax.js.map +1 -1
  42. package/lib/worker/email.d.ts +1 -1
  43. package/lib/worker/email.js +1 -1
  44. package/lib/worker/email.js.map +1 -1
  45. package/lib/worker/push-notification.d.ts +1 -0
  46. package/lib/worker/push-notification.js +73 -0
  47. package/lib/worker/push-notification.js.map +1 -0
  48. package/package.json +23 -23
  49. package/src/enrollments/licensed.ts +1 -1
  50. package/src/files/gridfs/index.ts +14 -3
  51. package/src/plugins-index.ts +1 -0
  52. package/src/pricing/apply-rate.test.ts +92 -0
  53. package/src/pricing/configureProductPriceRounding.test.ts +44 -0
  54. package/src/pricing/discount-100-off.test.ts +31 -0
  55. package/src/pricing/discount-100-off.ts +1 -1
  56. package/src/pricing/discount-half-price-manual.test.ts +42 -0
  57. package/src/pricing/discount-half-price-manual.ts +1 -1
  58. package/src/pricing/discount-half-price.test.ts +40 -0
  59. package/src/pricing/discount-half-price.ts +1 -1
  60. package/src/pricing/free-delivery.test.ts +12 -0
  61. package/src/pricing/getTaxRate.test.ts +69 -0
  62. package/src/pricing/licenced-enrollment.test.ts +37 -0
  63. package/src/pricing/order-delivery.test.ts +9 -0
  64. package/src/pricing/order-delivery.ts +1 -1
  65. package/src/pricing/order-discount.test.ts +206 -0
  66. package/src/pricing/order-discount.ts +6 -4
  67. package/src/pricing/order-items-discount.ts +4 -1
  68. package/{tests/plugins-index.test.js → src/pricing/plugins-index.test.ts} +0 -0
  69. package/src/pricing/product-catalog-price.ts +1 -1
  70. package/src/pricing/product-discount.ts +2 -2
  71. package/src/pricing/product-price-rateconversion.ts +1 -1
  72. package/src/pricing/product-price-round.ts +4 -4
  73. package/src/pricing/product-swiss-tax.test.ts +141 -0
  74. package/src/pricing/product-swiss-tax.ts +3 -3
  75. package/src/pricing/roundToNext.test.ts +24 -0
  76. package/src/worker/email.ts +1 -1
  77. package/src/worker/push-notification.ts +106 -0
  78. package/tsconfig.json +3 -22
  79. package/lib/pricing/utils/cache.d.ts +0 -9
  80. package/lib/pricing/utils/cache.js +0 -29
  81. package/lib/pricing/utils/cache.js.map +0 -1
  82. 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;