@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.
- package/jest.config.js +12 -0
- package/lib/delivery/pick-mup.js +1 -1
- package/lib/delivery/pick-mup.js.map +1 -1
- 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/gridfs-adapter.d.ts +1 -1
- package/lib/files/gridfs/gridfs-adapter.js +1 -1
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.js +1 -1
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
- package/lib/files/gridfs/index.js +12 -3
- package/lib/files/gridfs/index.js.map +1 -1
- package/lib/files/minio/minio-adapter.d.ts +1 -1
- package/lib/files/minio/minio-adapter.js +1 -1
- package/lib/files/minio/minio-adapter.js.map +1 -1
- package/lib/filters/local-search.d.ts +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
- package/lib/payment/apple-iap/index.d.ts +2 -2
- package/lib/payment/apple-iap/index.js +2 -2
- package/lib/payment/apple-iap/index.js.map +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +2 -2
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
- package/lib/payment/cryptopay/index.d.ts +3 -3
- package/lib/payment/cryptopay/index.js +3 -3
- package/lib/payment/cryptopay/index.js.map +1 -1
- package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +2 -2
- package/lib/payment/cryptopay/module/configureCryptopayModule.js +1 -1
- package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts +1 -1
- package/lib/payment/cryptopay/plugin.js +1 -1
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/index.d.ts +8 -8
- package/lib/payment/datatrans-v2/api/index.js +9 -9
- package/lib/payment/datatrans-v2/api/index.js.map +1 -1
- package/lib/payment/datatrans-v2/api/init.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/init.js +1 -1
- package/lib/payment/datatrans-v2/api/init.js.map +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.js +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/status.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/validate.d.ts +1 -1
- package/lib/payment/datatrans-v2/index.d.ts +1 -1
- package/lib/payment/datatrans-v2/index.js +4 -4
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/middleware.js +1 -1
- package/lib/payment/datatrans-v2/middleware.js.map +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +4 -4
- package/lib/payment/datatrans-v2/parseRegistrationData.js +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
- package/lib/payment/postfinance-checkout/index.d.ts +1 -1
- package/lib/payment/postfinance-checkout/index.js +4 -4
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.js +1 -1
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -1
- package/lib/payment/postfinance-checkout/types.js +2 -2
- package/lib/payment/postfinance-checkout/types.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
- package/lib/payment/worldline-saferpay/index.js +1 -1
- package/lib/payment/worldline-saferpay/index.js.map +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +4 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +2 -2
- package/lib/plugins-index.d.ts +43 -42
- package/lib/plugins-index.js +51 -50
- package/lib/plugins-index.js.map +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts +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/free-delivery.d.ts +1 -1
- package/lib/pricing/free-payment.d.ts +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 +6 -5
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +5 -1
- 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 +3 -3
- 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 +3 -1
- 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/warehousing/eth-minter.js +1 -1
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/warehousing/google-sheets.d.ts +1 -1
- package/lib/warehousing/google-sheets.js +1 -1
- package/lib/warehousing/google-sheets.js.map +1 -1
- package/lib/worker/bulk-import.d.ts +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/export-token.d.ts +2 -2
- package/lib/worker/external.d.ts +1 -1
- package/lib/worker/http-request.d.ts +1 -1
- package/lib/worker/message.d.ts +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/lib/worker/update-token-ownership.d.ts +2 -2
- package/lib/worker/zombie-killer.d.ts +1 -1
- package/package.json +22 -22
- package/src/delivery/pick-mup.ts +1 -1
- package/src/delivery/post.ts +1 -1
- package/src/delivery/send-message.ts +1 -1
- package/src/delivery/stores.ts +1 -1
- package/src/enrollments/licensed.ts +2 -2
- package/src/events/node-event-emitter.ts +1 -1
- package/src/events/redis.ts +1 -1
- package/src/files/gridfs/gridfs-adapter.ts +2 -2
- package/src/files/gridfs/gridfs-webhook.ts +1 -1
- package/src/files/gridfs/index.ts +14 -3
- package/src/files/minio/minio-adapter.ts +2 -2
- package/src/filters/local-search.ts +2 -2
- package/src/filters/strict-equal.ts +1 -1
- package/src/payment/apple-iap/adapter.ts +4 -4
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/apple-iap/index.ts +2 -2
- package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +2 -2
- package/src/payment/braintree.ts +1 -1
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/index.ts +3 -3
- package/src/payment/cryptopay/middleware.ts +4 -4
- package/src/payment/cryptopay/module/configureCryptopayModule.ts +2 -2
- package/src/payment/cryptopay/plugin.ts +4 -4
- package/src/payment/datatrans-v2/api/authorize.ts +1 -1
- package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +1 -1
- package/src/payment/datatrans-v2/api/cancel.ts +1 -1
- package/src/payment/datatrans-v2/api/index.ts +9 -9
- package/src/payment/datatrans-v2/api/init.ts +2 -2
- package/src/payment/datatrans-v2/api/secureFields.ts +2 -2
- package/src/payment/datatrans-v2/api/settle.ts +1 -1
- package/src/payment/datatrans-v2/api/status.ts +1 -1
- package/src/payment/datatrans-v2/api/validate.ts +1 -1
- package/src/payment/datatrans-v2/index.ts +6 -6
- package/src/payment/datatrans-v2/middleware.ts +3 -3
- package/src/payment/datatrans-v2/parseRegistrationData.ts +2 -2
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
- package/src/payment/invoice-prepaid.ts +1 -1
- package/src/payment/invoice.ts +1 -1
- package/src/payment/paypal-checkout.ts +1 -1
- package/src/payment/postfinance-checkout/index.ts +5 -5
- package/src/payment/postfinance-checkout/middleware.ts +3 -3
- package/src/payment/postfinance-checkout/utils.ts +1 -1
- package/src/payment/stripe.ts +2 -2
- package/src/payment/worldline-saferpay/index.ts +2 -2
- package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +5 -5
- package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +4 -4
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +4 -4
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +4 -4
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +2 -2
- package/src/plugins-index.ts +52 -51
- package/src/pricing/apply-rate.test.ts +92 -0
- package/src/pricing/configureProductPriceRounding.test.ts +44 -0
- package/src/pricing/delivery-swiss-tax.ts +1 -1
- package/src/pricing/discount-100-off.test.ts +31 -0
- package/src/pricing/discount-100-off.ts +2 -2
- package/src/pricing/discount-half-price-manual.test.ts +42 -0
- package/src/pricing/discount-half-price-manual.ts +2 -2
- package/src/pricing/discount-half-price.test.ts +40 -0
- package/src/pricing/discount-half-price.ts +2 -2
- package/src/pricing/free-delivery.test.ts +12 -0
- package/src/pricing/free-delivery.ts +1 -1
- package/src/pricing/free-payment.ts +1 -1
- 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 +2 -2
- package/src/pricing/order-discount.test.ts +206 -0
- package/src/pricing/order-discount.ts +7 -5
- package/src/pricing/order-items-discount.ts +5 -2
- package/src/pricing/order-items.ts +1 -1
- package/src/pricing/order-payment.ts +1 -1
- package/{tests/plugins-index.test.js → src/pricing/plugins-index.test.ts} +0 -0
- package/src/pricing/product-catalog-price.ts +2 -2
- package/src/pricing/product-discount.ts +4 -4
- package/src/pricing/product-price-rateconversion.ts +2 -2
- package/src/pricing/product-price-round.ts +5 -5
- package/src/pricing/product-swiss-tax.test.ts +141 -0
- package/src/pricing/product-swiss-tax.ts +4 -4
- package/src/pricing/roundToNext.test.ts +24 -0
- package/src/quotations/manual.ts +1 -1
- package/src/warehousing/eth-minter.ts +2 -2
- package/src/warehousing/google-sheets.ts +2 -2
- package/src/warehousing/store.ts +1 -1
- package/src/worker/bulk-import.ts +2 -2
- package/src/worker/email.ts +2 -2
- package/src/worker/enrollment-order-generator.ts +5 -5
- package/src/worker/export-token.ts +2 -2
- package/src/worker/external.ts +1 -1
- package/src/worker/heartbeat.ts +1 -1
- package/src/worker/http-request.ts +1 -1
- package/src/worker/message.ts +1 -1
- package/src/worker/push-notification.ts +106 -0
- package/src/worker/sms.ts +1 -1
- package/src/worker/update-coinbase-rates.ts +2 -2
- package/src/worker/update-ecb-rates.ts +2 -2
- package/src/worker/update-token-ownership.ts +2 -2
- package/src/worker/zombie-killer.ts +1 -1
- package/tsconfig.json +3 -25
- package/lib/pricing/utils/cache.d.ts +0 -8
- package/lib/pricing/utils/cache.js +0 -28
- package/lib/pricing/utils/cache.js.map +0 -1
- package/src/pricing/utils/cache.js +0 -32
package/src/worker/email.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 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,
|
package/src/worker/external.ts
CHANGED
|
@@ -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> = {
|
package/src/worker/heartbeat.ts
CHANGED
|
@@ -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
|
|
package/src/worker/message.ts
CHANGED
|
@@ -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('* * * * *');
|
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
|
-
|
|
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,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;
|