@unchainedshop/plugins 2.0.0-rc.3 → 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.
Files changed (236) hide show
  1. package/jest.config.js +12 -0
  2. package/lib/delivery/pick-mup.js +1 -1
  3. package/lib/delivery/pick-mup.js.map +1 -1
  4. package/lib/enrollments/licensed.d.ts +4 -1
  5. package/lib/enrollments/licensed.js +1 -1
  6. package/lib/enrollments/licensed.js.map +1 -1
  7. package/lib/files/gridfs/gridfs-adapter.d.ts +1 -1
  8. package/lib/files/gridfs/gridfs-adapter.js +1 -1
  9. package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
  10. package/lib/files/gridfs/gridfs-webhook.js +1 -1
  11. package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
  12. package/lib/files/gridfs/index.js +12 -3
  13. package/lib/files/gridfs/index.js.map +1 -1
  14. package/lib/files/minio/minio-adapter.d.ts +1 -1
  15. package/lib/files/minio/minio-adapter.js +1 -1
  16. package/lib/files/minio/minio-adapter.js.map +1 -1
  17. package/lib/filters/local-search.d.ts +1 -1
  18. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
  19. package/lib/payment/apple-iap/index.d.ts +2 -2
  20. package/lib/payment/apple-iap/index.js +2 -2
  21. package/lib/payment/apple-iap/index.js.map +1 -1
  22. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +2 -2
  23. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +1 -1
  24. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -1
  25. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
  26. package/lib/payment/cryptopay/index.d.ts +3 -3
  27. package/lib/payment/cryptopay/index.js +3 -3
  28. package/lib/payment/cryptopay/index.js.map +1 -1
  29. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +2 -2
  30. package/lib/payment/cryptopay/module/configureCryptopayModule.js +1 -1
  31. package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +1 -1
  32. package/lib/payment/cryptopay/plugin.d.ts +1 -1
  33. package/lib/payment/cryptopay/plugin.js +1 -1
  34. package/lib/payment/cryptopay/plugin.js.map +1 -1
  35. package/lib/payment/datatrans-v2/api/authorize.d.ts +1 -1
  36. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +1 -1
  37. package/lib/payment/datatrans-v2/api/cancel.d.ts +1 -1
  38. package/lib/payment/datatrans-v2/api/index.d.ts +8 -8
  39. package/lib/payment/datatrans-v2/api/index.js +9 -9
  40. package/lib/payment/datatrans-v2/api/index.js.map +1 -1
  41. package/lib/payment/datatrans-v2/api/init.d.ts +1 -1
  42. package/lib/payment/datatrans-v2/api/init.js +1 -1
  43. package/lib/payment/datatrans-v2/api/init.js.map +1 -1
  44. package/lib/payment/datatrans-v2/api/secureFields.d.ts +1 -1
  45. package/lib/payment/datatrans-v2/api/secureFields.js +1 -1
  46. package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -1
  47. package/lib/payment/datatrans-v2/api/settle.d.ts +1 -1
  48. package/lib/payment/datatrans-v2/api/status.d.ts +1 -1
  49. package/lib/payment/datatrans-v2/api/validate.d.ts +1 -1
  50. package/lib/payment/datatrans-v2/index.d.ts +1 -1
  51. package/lib/payment/datatrans-v2/index.js +4 -4
  52. package/lib/payment/datatrans-v2/index.js.map +1 -1
  53. package/lib/payment/datatrans-v2/middleware.js +1 -1
  54. package/lib/payment/datatrans-v2/middleware.js.map +1 -1
  55. package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +4 -4
  56. package/lib/payment/datatrans-v2/parseRegistrationData.js +1 -1
  57. package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -1
  58. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
  59. package/lib/payment/postfinance-checkout/index.d.ts +1 -1
  60. package/lib/payment/postfinance-checkout/index.js +4 -4
  61. package/lib/payment/postfinance-checkout/index.js.map +1 -1
  62. package/lib/payment/postfinance-checkout/middleware.js +1 -1
  63. package/lib/payment/postfinance-checkout/middleware.js.map +1 -1
  64. package/lib/payment/postfinance-checkout/types.js +2 -2
  65. package/lib/payment/postfinance-checkout/types.js.map +1 -1
  66. package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
  67. package/lib/payment/worldline-saferpay/index.js +1 -1
  68. package/lib/payment/worldline-saferpay/index.js.map +1 -1
  69. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +4 -4
  70. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +1 -1
  71. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -1
  72. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -4
  73. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +1 -1
  74. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -1
  75. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +4 -4
  76. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +4 -4
  77. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +2 -2
  78. package/lib/plugins-index.d.ts +43 -42
  79. package/lib/plugins-index.js +51 -50
  80. package/lib/plugins-index.js.map +1 -1
  81. package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
  82. package/lib/pricing/discount-100-off.d.ts +2 -1
  83. package/lib/pricing/discount-100-off.js +1 -1
  84. package/lib/pricing/discount-100-off.js.map +1 -1
  85. package/lib/pricing/discount-half-price-manual.d.ts +2 -1
  86. package/lib/pricing/discount-half-price-manual.js +1 -1
  87. package/lib/pricing/discount-half-price-manual.js.map +1 -1
  88. package/lib/pricing/discount-half-price.d.ts +2 -1
  89. package/lib/pricing/discount-half-price.js +1 -1
  90. package/lib/pricing/discount-half-price.js.map +1 -1
  91. package/lib/pricing/free-delivery.d.ts +1 -1
  92. package/lib/pricing/free-payment.d.ts +1 -1
  93. package/lib/pricing/order-delivery.d.ts +2 -1
  94. package/lib/pricing/order-delivery.js +1 -1
  95. package/lib/pricing/order-delivery.js.map +1 -1
  96. package/lib/pricing/order-discount.d.ts +10 -1
  97. package/lib/pricing/order-discount.js +6 -5
  98. package/lib/pricing/order-discount.js.map +1 -1
  99. package/lib/pricing/order-items-discount.js +5 -1
  100. package/lib/pricing/order-items-discount.js.map +1 -1
  101. package/lib/pricing/product-catalog-price.d.ts +2 -1
  102. package/lib/pricing/product-catalog-price.js +1 -1
  103. package/lib/pricing/product-catalog-price.js.map +1 -1
  104. package/lib/pricing/product-discount.d.ts +2 -1
  105. package/lib/pricing/product-discount.js +3 -3
  106. package/lib/pricing/product-discount.js.map +1 -1
  107. package/lib/pricing/product-price-rateconversion.d.ts +2 -1
  108. package/lib/pricing/product-price-rateconversion.js +1 -1
  109. package/lib/pricing/product-price-rateconversion.js.map +1 -1
  110. package/lib/pricing/product-price-round.d.ts +3 -1
  111. package/lib/pricing/product-price-round.js +3 -3
  112. package/lib/pricing/product-price-round.js.map +1 -1
  113. package/lib/pricing/product-swiss-tax.d.ts +8 -0
  114. package/lib/pricing/product-swiss-tax.js +3 -3
  115. package/lib/pricing/product-swiss-tax.js.map +1 -1
  116. package/lib/warehousing/eth-minter.js +1 -1
  117. package/lib/warehousing/eth-minter.js.map +1 -1
  118. package/lib/warehousing/google-sheets.d.ts +1 -1
  119. package/lib/warehousing/google-sheets.js +1 -1
  120. package/lib/warehousing/google-sheets.js.map +1 -1
  121. package/lib/worker/bulk-import.d.ts +1 -1
  122. package/lib/worker/email.d.ts +1 -1
  123. package/lib/worker/email.js +1 -1
  124. package/lib/worker/email.js.map +1 -1
  125. package/lib/worker/export-token.d.ts +2 -2
  126. package/lib/worker/external.d.ts +1 -1
  127. package/lib/worker/http-request.d.ts +1 -1
  128. package/lib/worker/message.d.ts +1 -1
  129. package/lib/worker/push-notification.d.ts +1 -0
  130. package/lib/worker/push-notification.js +73 -0
  131. package/lib/worker/push-notification.js.map +1 -0
  132. package/lib/worker/update-token-ownership.d.ts +2 -2
  133. package/lib/worker/zombie-killer.d.ts +1 -1
  134. package/package.json +22 -22
  135. package/src/delivery/pick-mup.ts +1 -1
  136. package/src/delivery/post.ts +1 -1
  137. package/src/delivery/send-message.ts +1 -1
  138. package/src/delivery/stores.ts +1 -1
  139. package/src/enrollments/licensed.ts +2 -2
  140. package/src/events/node-event-emitter.ts +1 -1
  141. package/src/events/redis.ts +1 -1
  142. package/src/files/gridfs/gridfs-adapter.ts +2 -2
  143. package/src/files/gridfs/gridfs-webhook.ts +1 -1
  144. package/src/files/gridfs/index.ts +14 -3
  145. package/src/files/minio/minio-adapter.ts +2 -2
  146. package/src/filters/local-search.ts +2 -2
  147. package/src/filters/strict-equal.ts +1 -1
  148. package/src/payment/apple-iap/adapter.ts +4 -4
  149. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
  150. package/src/payment/apple-iap/index.ts +2 -2
  151. package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +2 -2
  152. package/src/payment/braintree.ts +1 -1
  153. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
  154. package/src/payment/cryptopay/index.ts +3 -3
  155. package/src/payment/cryptopay/middleware.ts +4 -4
  156. package/src/payment/cryptopay/module/configureCryptopayModule.ts +2 -2
  157. package/src/payment/cryptopay/plugin.ts +4 -4
  158. package/src/payment/datatrans-v2/api/authorize.ts +1 -1
  159. package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +1 -1
  160. package/src/payment/datatrans-v2/api/cancel.ts +1 -1
  161. package/src/payment/datatrans-v2/api/index.ts +9 -9
  162. package/src/payment/datatrans-v2/api/init.ts +2 -2
  163. package/src/payment/datatrans-v2/api/secureFields.ts +2 -2
  164. package/src/payment/datatrans-v2/api/settle.ts +1 -1
  165. package/src/payment/datatrans-v2/api/status.ts +1 -1
  166. package/src/payment/datatrans-v2/api/validate.ts +1 -1
  167. package/src/payment/datatrans-v2/index.ts +6 -6
  168. package/src/payment/datatrans-v2/middleware.ts +3 -3
  169. package/src/payment/datatrans-v2/parseRegistrationData.ts +2 -2
  170. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
  171. package/src/payment/invoice-prepaid.ts +1 -1
  172. package/src/payment/invoice.ts +1 -1
  173. package/src/payment/paypal-checkout.ts +1 -1
  174. package/src/payment/postfinance-checkout/index.ts +5 -5
  175. package/src/payment/postfinance-checkout/middleware.ts +3 -3
  176. package/src/payment/postfinance-checkout/utils.ts +1 -1
  177. package/src/payment/stripe.ts +2 -2
  178. package/src/payment/worldline-saferpay/index.ts +2 -2
  179. package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +5 -5
  180. package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +4 -4
  181. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +4 -4
  182. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +4 -4
  183. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +2 -2
  184. package/src/plugins-index.ts +52 -51
  185. package/src/pricing/apply-rate.test.ts +92 -0
  186. package/src/pricing/configureProductPriceRounding.test.ts +44 -0
  187. package/src/pricing/delivery-swiss-tax.ts +1 -1
  188. package/src/pricing/discount-100-off.test.ts +31 -0
  189. package/src/pricing/discount-100-off.ts +2 -2
  190. package/src/pricing/discount-half-price-manual.test.ts +42 -0
  191. package/src/pricing/discount-half-price-manual.ts +2 -2
  192. package/src/pricing/discount-half-price.test.ts +40 -0
  193. package/src/pricing/discount-half-price.ts +2 -2
  194. package/src/pricing/free-delivery.test.ts +12 -0
  195. package/src/pricing/free-delivery.ts +1 -1
  196. package/src/pricing/free-payment.ts +1 -1
  197. package/src/pricing/getTaxRate.test.ts +69 -0
  198. package/src/pricing/licenced-enrollment.test.ts +37 -0
  199. package/src/pricing/order-delivery.test.ts +9 -0
  200. package/src/pricing/order-delivery.ts +2 -2
  201. package/src/pricing/order-discount.test.ts +206 -0
  202. package/src/pricing/order-discount.ts +7 -5
  203. package/src/pricing/order-items-discount.ts +5 -2
  204. package/src/pricing/order-items.ts +1 -1
  205. package/src/pricing/order-payment.ts +1 -1
  206. package/{tests/plugins-index.test.js → src/pricing/plugins-index.test.ts} +0 -0
  207. package/src/pricing/product-catalog-price.ts +2 -2
  208. package/src/pricing/product-discount.ts +4 -4
  209. package/src/pricing/product-price-rateconversion.ts +2 -2
  210. package/src/pricing/product-price-round.ts +5 -5
  211. package/src/pricing/product-swiss-tax.test.ts +141 -0
  212. package/src/pricing/product-swiss-tax.ts +4 -4
  213. package/src/pricing/roundToNext.test.ts +24 -0
  214. package/src/quotations/manual.ts +1 -1
  215. package/src/warehousing/eth-minter.ts +2 -2
  216. package/src/warehousing/google-sheets.ts +2 -2
  217. package/src/warehousing/store.ts +1 -1
  218. package/src/worker/bulk-import.ts +2 -2
  219. package/src/worker/email.ts +2 -2
  220. package/src/worker/enrollment-order-generator.ts +5 -5
  221. package/src/worker/export-token.ts +2 -2
  222. package/src/worker/external.ts +1 -1
  223. package/src/worker/heartbeat.ts +1 -1
  224. package/src/worker/http-request.ts +1 -1
  225. package/src/worker/message.ts +1 -1
  226. package/src/worker/push-notification.ts +106 -0
  227. package/src/worker/sms.ts +1 -1
  228. package/src/worker/update-coinbase-rates.ts +2 -2
  229. package/src/worker/update-ecb-rates.ts +2 -2
  230. package/src/worker/update-token-ownership.ts +2 -2
  231. package/src/worker/zombie-killer.ts +1 -1
  232. package/tsconfig.json +3 -25
  233. package/lib/pricing/utils/cache.d.ts +0 -8
  234. package/lib/pricing/utils/cache.js +0 -28
  235. package/lib/pricing/utils/cache.js.map +0 -1
  236. package/src/pricing/utils/cache.js +0 -32
@@ -1,6 +1,6 @@
1
1
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
3
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
6
  import os from 'os';
@@ -9,7 +9,7 @@ import nodemailer from 'nodemailer';
9
9
 
10
10
  const logger = createLogger('unchained:plugins:worker:email');
11
11
 
12
- const checkEmailInterceptionEnabled = () => {
12
+ export const checkEmailInterceptionEnabled = () => {
13
13
  return process.env.NODE_ENV !== 'production' && !process.env.UNCHAINED_DISABLE_EMAIL_INTERCEPTION;
14
14
  };
15
15
 
@@ -1,14 +1,14 @@
1
- import { Enrollment } from '@unchainedshop/types/enrollments';
2
- import { OrderPosition } from '@unchainedshop/types/orders.positions';
3
- import { Product } from '@unchainedshop/types/products';
4
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
1
+ import { Enrollment } from '@unchainedshop/types/enrollments.js';
2
+ import { OrderPosition } from '@unchainedshop/types/orders.positions.js';
3
+ import { Product } from '@unchainedshop/types/products.js';
4
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
5
5
  import {
6
6
  EnrollmentDirector,
7
7
  enrollmentsSettings,
8
8
  EnrollmentStatus,
9
9
  } from '@unchainedshop/core-enrollments';
10
10
  import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core-worker';
11
- import { UnchainedCore } from '@unchainedshop/types/core';
11
+ import { UnchainedCore } from '@unchainedshop/types/core.js';
12
12
 
13
13
  const generateOrder = async (
14
14
  enrollment: Enrollment,
@@ -1,6 +1,6 @@
1
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
1
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
2
2
  import { WorkerDirector, WorkerAdapter, WorkerEventTypes } from '@unchainedshop/core-worker';
3
- import { UnchainedCore } from '@unchainedshop/types/core';
3
+ import { UnchainedCore } from '@unchainedshop/types/core.js';
4
4
 
5
5
  export const ExportTokenWorker: IWorkerAdapter<void, void> = {
6
6
  ...WorkerAdapter,
@@ -1,4 +1,4 @@
1
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
1
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
2
2
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
3
3
 
4
4
  export const ExternalWorkerPlugin: IWorkerAdapter<void, void> = {
@@ -1,4 +1,4 @@
1
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
1
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
2
2
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
3
3
 
4
4
  const wait = async (time: number) => {
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="dom" />
2
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
2
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
3
3
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
4
4
  import { log, LogLevel } from '@unchainedshop/logger';
5
5
 
@@ -1,4 +1,4 @@
1
- import { IWorkerAdapter, Work } from '@unchainedshop/types/worker';
1
+ import { IWorkerAdapter, Work } from '@unchainedshop/types/worker.js';
2
2
  import { MessagingDirector } from '@unchainedshop/core-messaging';
3
3
  import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core-worker';
4
4
  import { createLogger } from '@unchainedshop/logger';
@@ -0,0 +1,106 @@
1
+ import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
2
+ import { createLogger } from '@unchainedshop/logger';
3
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
4
+ import webPush from 'web-push';
5
+
6
+ const { PUSH_NOTIFICATION_PUBLIC_KEY, PUSH_NOTIFICATION_PRIVATE_KEY } = process.env;
7
+
8
+ const logger = createLogger('unchained:plugins:worker:push-notification');
9
+
10
+ type NotificationOptions = {
11
+ vapidDetails: {
12
+ subject: string;
13
+ publicKey: string;
14
+ privateKey: string;
15
+ };
16
+ TTL: number;
17
+ urgency?: 'very-low' | 'low' | 'normal' | 'high';
18
+ topic?: string;
19
+ };
20
+
21
+ const PushNotificationWorkerPlugin: IWorkerAdapter<
22
+ {
23
+ subscription: any;
24
+ payload: string;
25
+ subject: string;
26
+ urgency?: 'very-low' | 'low' | 'normal' | 'high';
27
+ topic?: string;
28
+ },
29
+ any
30
+ > = {
31
+ ...WorkerAdapter,
32
+
33
+ key: 'shop.unchained.worker-plugin.push-notification',
34
+ label: 'Push Notification',
35
+
36
+ version: '1.0',
37
+
38
+ type: 'PUSH',
39
+
40
+ doWork: async ({ subscription, subject, payload, urgency = null, topic = null }) => {
41
+ logger.debug(`${PushNotificationWorkerPlugin.key} -> doWork: Push -> ${subject}`);
42
+ if (!PUSH_NOTIFICATION_PUBLIC_KEY)
43
+ return {
44
+ success: false,
45
+ error: {
46
+ name: 'VAPID_PUBLIC_KEY_REQUIRED',
47
+ message: 'vapidPublicKey key required to send push notifications',
48
+ },
49
+ };
50
+ if (!PUSH_NOTIFICATION_PRIVATE_KEY)
51
+ return {
52
+ success: false,
53
+ error: {
54
+ name: 'VAPID_PRIVATE_KEY_REQUIRED',
55
+ message: 'vapidPrivateKey key are required to send push notifications',
56
+ },
57
+ };
58
+
59
+ if (!subscription) {
60
+ return {
61
+ success: false,
62
+ error: {
63
+ name: 'USER_SUBSCRIPTION_OBJECT_REQUIRED',
64
+ message: 'PUSH service subscription required',
65
+ },
66
+ };
67
+ }
68
+
69
+ const options: NotificationOptions = {
70
+ vapidDetails: {
71
+ subject,
72
+ publicKey: PUSH_NOTIFICATION_PUBLIC_KEY,
73
+ privateKey: PUSH_NOTIFICATION_PRIVATE_KEY,
74
+ },
75
+ TTL: 60,
76
+ };
77
+
78
+ if (urgency) {
79
+ options.urgency = urgency;
80
+ }
81
+
82
+ if (topic) {
83
+ options.topic = topic;
84
+ }
85
+
86
+ try {
87
+ await webPush.sendNotification(subscription, payload, options);
88
+
89
+ return {
90
+ success: true,
91
+ error: null,
92
+ };
93
+ } catch (err) {
94
+ return {
95
+ success: false,
96
+ error: {
97
+ name: err.name,
98
+ message: err.message,
99
+ stack: err.stack,
100
+ },
101
+ };
102
+ }
103
+ },
104
+ };
105
+
106
+ WorkerDirector.registerAdapter(PushNotificationWorkerPlugin);
package/src/worker/sms.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
3
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
4
4
  import Twilio from 'twilio';
5
5
 
6
6
  const { TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_SMS_FROM } = process.env;
@@ -1,8 +1,8 @@
1
1
  /// <reference lib="dom" />
2
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
2
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
3
3
  import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core-worker';
4
4
  import later from '@breejs/later';
5
- import { ProductPriceRate } from '@unchainedshop/types/products.pricing';
5
+ import { ProductPriceRate } from '@unchainedshop/types/products.pricing.js';
6
6
  import { systemLocale } from '@unchainedshop/utils';
7
7
 
8
8
  const getExchangeRates = async (base) => {
@@ -1,9 +1,9 @@
1
1
  /// <reference lib="dom" />
2
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
2
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
3
3
  import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core-worker';
4
4
  import later from '@breejs/later';
5
5
  import xmlJs from 'xml-js';
6
- import { ProductPriceRate } from '@unchainedshop/types/products.pricing';
6
+ import { ProductPriceRate } from '@unchainedshop/types/products.pricing.js';
7
7
 
8
8
  const getExchangeRates = async () => {
9
9
  return fetch(`https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml`, {
@@ -1,6 +1,6 @@
1
- import { IWorkerAdapter, Work } from '@unchainedshop/types/worker';
1
+ import { IWorkerAdapter, Work } from '@unchainedshop/types/worker.js';
2
2
  import { WorkerDirector, WorkerAdapter, WorkerEventTypes } from '@unchainedshop/core-worker';
3
- import { UnchainedCore } from '@unchainedshop/types/core';
3
+ import { UnchainedCore } from '@unchainedshop/types/core.js';
4
4
  import later from '@breejs/later';
5
5
 
6
6
  const everyMinute = later.parse.cron('* * * * *');
@@ -1,4 +1,4 @@
1
- import { IWorkerAdapter } from '@unchainedshop/types/worker';
1
+ import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
2
2
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
 
package/tsconfig.json CHANGED
@@ -1,38 +1,16 @@
1
1
  {
2
+ "extends": "../shared/base.tsconfig.json",
2
3
  "compilerOptions": {
3
- "allowJs": true,
4
- "allowSyntheticDefaultImports": true,
5
- "declaration": true,
6
- "esModuleInterop": true,
7
- "experimentalDecorators": true,
8
- "forceConsistentCasingInFileNames": true,
9
4
  "rootDir": "src",
10
- "lib": [
11
- "esnext"
12
- ],
13
- "module": "esnext",
14
- "moduleResolution": "node",
15
- "noImplicitReturns": true,
16
- "noUnusedLocals": false,
17
5
  "outDir": "lib",
18
- "preserveWatchOutput": true,
19
- "skipLibCheck": true,
20
- "sourceMap": true,
21
- "target": "esnext",
22
- "types": [
23
- "node",
24
- "jest"
25
- ],
26
6
  "paths": {
27
7
  "postfinancecheckout": [
28
8
  "./src/payment/postfinance-checkout/silence-postfinancecheckout.d.ts"
29
9
  ],
30
10
  }
31
11
  },
32
- // "exclude": [
33
- // "./src/payment/postfinance-checkout/*"
34
- // ],
12
+ "exclude": ["**/*.test.ts", "**/*.test.js", "tests"],
35
13
  "include": [
36
- "src"
14
+ "./src"
37
15
  ]
38
16
  }
@@ -1,8 +0,0 @@
1
- export default Cache;
2
- declare class Cache {
3
- constructor(ttlSeconds?: number);
4
- cache: any;
5
- get(key: any, currentFuntion: any): any;
6
- del(keys: any): void;
7
- flushAll(): void;
8
- }
@@ -1,28 +0,0 @@
1
- import 'abort-controller/polyfill';
2
- import LRUCache from 'lru-cache';
3
- class Cache {
4
- constructor(ttlSeconds = 60) {
5
- this.cache = new LRUCache({
6
- max: 500,
7
- ttl: ttlSeconds * 1000,
8
- });
9
- }
10
- get(key, currentFuntion) {
11
- const value = this.cache.get(key);
12
- if (value) {
13
- return Promise.resolve(value);
14
- }
15
- return currentFuntion().then((result) => {
16
- this.cache.set(key, result);
17
- return result;
18
- });
19
- }
20
- del(keys) {
21
- this.cache.del(keys);
22
- }
23
- flushAll() {
24
- this.cache.reset();
25
- }
26
- }
27
- export default Cache;
28
- //# sourceMappingURL=cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/pricing/utils/cache.js"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,MAAM,KAAK;IACT,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,32 +0,0 @@
1
- import 'abort-controller/polyfill';
2
- import LRUCache from 'lru-cache';
3
-
4
- class Cache {
5
- constructor(ttlSeconds = 60) {
6
- this.cache = new LRUCache({
7
- max: 500,
8
- ttl: ttlSeconds * 1000,
9
- });
10
- }
11
-
12
- get(key, currentFuntion) {
13
- const value = this.cache.get(key);
14
- if (value) {
15
- return Promise.resolve(value);
16
- }
17
- return currentFuntion().then((result) => {
18
- this.cache.set(key, result);
19
- return result;
20
- });
21
- }
22
-
23
- del(keys) {
24
- this.cache.del(keys);
25
- }
26
-
27
- flushAll() {
28
- this.cache.reset();
29
- }
30
- }
31
-
32
- export default Cache;