@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
@@ -2,7 +2,7 @@ import {
2
2
  IPaymentActions,
3
3
  IPaymentAdapter,
4
4
  PaymentChargeActionResult,
5
- } from '@unchainedshop/types/payments';
5
+ } from '@unchainedshop/types/payments.js';
6
6
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
7
7
  import { createLogger } from '@unchainedshop/logger';
8
8
 
@@ -17,11 +17,11 @@ import {
17
17
  getTransaction,
18
18
  refundTransaction,
19
19
  voidTransaction,
20
- } from './api';
21
- import { orderIsPaid } from './utils';
22
- import { CompletionModes, IntegrationModes, SignResponse } from './types';
20
+ } from './api.js';
21
+ import { orderIsPaid } from './utils.js';
22
+ import { CompletionModes, IntegrationModes, SignResponse } from './types.js';
23
23
 
24
- export * from './middleware';
24
+ export * from './middleware.js';
25
25
 
26
26
  const { PostFinanceCheckout } = pf;
27
27
 
@@ -1,7 +1,7 @@
1
- import { Context } from '@unchainedshop/types/api';
1
+ import { Context } from '@unchainedshop/types/api.js';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
- import { WebhookData } from './types';
4
- import { getTransaction, getTransactionCompletion } from './api';
3
+ import { WebhookData } from './types.js';
4
+ import { getTransaction, getTransactionCompletion } from './api.js';
5
5
 
6
6
  const logger = createLogger('unchained:core-payment:postfinance-checkout');
7
7
 
@@ -1,4 +1,4 @@
1
- import { Order, OrdersModule } from '@unchainedshop/types/orders';
1
+ import { Order, OrdersModule } from '@unchainedshop/types/orders.js';
2
2
  import * as pf from 'postfinancecheckout';
3
3
 
4
4
  const { PostFinanceCheckout } = pf;
@@ -1,5 +1,5 @@
1
- import { Context } from '@unchainedshop/types/api';
2
- import { IPaymentAdapter } from '@unchainedshop/types/payments';
1
+ import { Context } from '@unchainedshop/types/api.js';
2
+ import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
3
3
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
4
4
  import { createLogger } from '@unchainedshop/logger';
5
5
 
@@ -1,6 +1,6 @@
1
- import { IPaymentAdapter, PaymentChargeActionResult } from '@unchainedshop/types/payments';
1
+ import { IPaymentAdapter, PaymentChargeActionResult } from '@unchainedshop/types/payments.js';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
- import { PaymentPageInitializeInput, SaferpayClient } from './worldline-saferpay-client';
3
+ import { PaymentPageInitializeInput, SaferpayClient } from './worldline-saferpay-client/index.js';
4
4
 
5
5
  const {
6
6
  WORLDLINE_BASE_URL = 'https://test.saferpay.com/api',
@@ -1,11 +1,11 @@
1
- import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel';
2
- import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert';
1
+ import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel.js';
2
+ import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert.js';
3
3
  import {
4
4
  PaymentPageInitializeInput,
5
5
  PaymentPageInitializeResponse,
6
- } from '../models/PaymentPageInitialize';
7
- import { RequestHeader } from '../models/Request';
8
- import { SaferpayConnection } from './SaferpayConnection';
6
+ } from '../models/PaymentPageInitialize.js';
7
+ import { RequestHeader } from '../models/Request.js';
8
+ import { SaferpayConnection } from './SaferpayConnection.js';
9
9
 
10
10
  export class SaferpayClient {
11
11
  private conn: SaferpayConnection;
@@ -1,8 +1,8 @@
1
- export { SaferpayClient } from './api/SaferpayClient';
1
+ export { SaferpayClient } from './api/SaferpayClient.js';
2
2
 
3
3
  export type {
4
4
  PaymentPageInitializeInput,
5
5
  PaymentPageInitializeResponse,
6
- } from './models/PaymentPageInitialize';
7
- export type { PaymentPageAssertInput, PaymentPageAssertResponse } from './models/PaymentPageAssert';
8
- export type { TransactionCancelInput, TransactionCancelResponse } from './models/TransactionCancel';
6
+ } from './models/PaymentPageInitialize.js';
7
+ export type { PaymentPageAssertInput, PaymentPageAssertResponse } from './models/PaymentPageAssert.js';
8
+ export type { TransactionCancelInput, TransactionCancelResponse } from './models/TransactionCancel.js';
@@ -1,7 +1,7 @@
1
- import { Response } from './Response';
2
- import { Request } from './Request';
3
- import { TransactionAmount, TransactionStatus } from './Transaction';
4
- import { PaymentMethods } from './PaymentMethods';
1
+ import { Response } from './Response.js';
2
+ import { Request } from './Request.js';
3
+ import { TransactionAmount, TransactionStatus } from './Transaction.js';
4
+ import { PaymentMethods } from './PaymentMethods.js';
5
5
 
6
6
  export interface PaymentPageAssertInput extends Request {
7
7
  Token: string;
@@ -1,7 +1,7 @@
1
- import { PaymentMethods } from './PaymentMethods';
2
- import { Request } from './Request';
3
- import { Response } from './Response';
4
- import { TransactionAmount } from './Transaction';
1
+ import { PaymentMethods } from './PaymentMethods.js';
2
+ import { Request } from './Request.js';
3
+ import { Response } from './Response.js';
4
+ import { TransactionAmount } from './Transaction.js';
5
5
 
6
6
  export interface PaymentPageInitializeInput extends Request {
7
7
  ConfigSet?: string;
@@ -1,5 +1,5 @@
1
- import { Response } from './Response';
2
- import { Request } from './Request';
1
+ import { Response } from './Response.js';
2
+ import { Request } from './Request.js';
3
3
 
4
4
  export interface TransactionCancelInput extends Request {
5
5
  TransactionReference: {
@@ -1,75 +1,76 @@
1
- import { useMiddlewareWithCurrentContext } from '@unchainedshop/api/express';
2
- import { UnchainedCore } from '@unchainedshop/types/core';
1
+ import { useMiddlewareWithCurrentContext } from '@unchainedshop/api/express/index.js';
2
+ import { UnchainedCore } from '@unchainedshop/types/core.js';
3
3
  import express from 'express';
4
4
 
5
5
  // Delivery
6
- import './delivery/post';
7
- import './delivery/pick-mup';
8
- import './delivery/send-message';
9
- import './delivery/stores';
6
+ import './delivery/post.js';
7
+ import './delivery/pick-mup.js';
8
+ import './delivery/send-message.js';
9
+ import './delivery/stores.js';
10
10
 
11
11
  // Payment
12
- import './payment/invoice';
13
- import './payment/invoice-prepaid';
14
- import './payment/paypal-checkout';
15
- import './payment/worldline-saferpay';
16
- import { datatransHandler } from './payment/datatrans-v2';
17
- import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay';
18
- import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap';
19
- import { stripeHandler } from './payment/stripe';
20
- import { postfinanceCheckoutHandler } from './payment/postfinance-checkout';
12
+ import './payment/invoice.js';
13
+ import './payment/invoice-prepaid.js';
14
+ import './payment/paypal-checkout.js';
15
+ import './payment/worldline-saferpay/index.js';
16
+ import { datatransHandler } from './payment/datatrans-v2/index.js';
17
+ import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay/index.js';
18
+ import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap/index.js';
19
+ import { stripeHandler } from './payment/stripe.js';
20
+ import { postfinanceCheckoutHandler } from './payment/postfinance-checkout/index.js';
21
21
 
22
22
  // Warehousing
23
- import './warehousing/store';
24
- import './warehousing/eth-minter';
23
+ import './warehousing/store.js';
24
+ import './warehousing/eth-minter.js';
25
25
 
26
26
  // Pricing
27
- import './pricing/discount-half-price-manual';
28
- import './pricing/discount-100-off';
29
- import './pricing/free-payment';
30
- import './pricing/free-delivery';
31
- import './pricing/order-items';
32
- import './pricing/order-discount';
33
- import './pricing/order-delivery';
34
- import './pricing/order-payment';
35
- import './pricing/product-catalog-price';
36
- import './pricing/product-price-rateconversion';
37
- import './pricing/product-discount';
38
- import './pricing/product-swiss-tax';
39
- import './pricing/delivery-swiss-tax';
27
+ import './pricing/discount-half-price-manual.js';
28
+ import './pricing/discount-100-off.js';
29
+ import './pricing/free-payment.js';
30
+ import './pricing/free-delivery.js';
31
+ import './pricing/order-items.js';
32
+ import './pricing/order-discount.js';
33
+ import './pricing/order-delivery.js';
34
+ import './pricing/order-payment.js';
35
+ import './pricing/product-catalog-price.js';
36
+ import './pricing/product-price-rateconversion.js';
37
+ import './pricing/product-discount.js';
38
+ import './pricing/product-swiss-tax.js';
39
+ import './pricing/delivery-swiss-tax.js';
40
40
 
41
41
  // Filter & Search
42
- import './filters/strict-equal';
43
- import './filters/local-search';
42
+ import './filters/strict-equal.js';
43
+ import './filters/local-search.js';
44
44
 
45
45
  // Quotations
46
- import './quotations/manual';
46
+ import './quotations/manual.js';
47
47
 
48
48
  // Enrollments
49
- import './enrollments/licensed';
49
+ import './enrollments/licensed.js';
50
50
 
51
51
  // Event Queue
52
- import './events/node-event-emitter';
52
+ import './events/node-event-emitter.js';
53
53
 
54
54
  // Workers
55
- import './worker/bulk-import';
56
- import './worker/zombie-killer';
57
- import './worker/message';
58
- import './worker/external';
59
- import './worker/http-request';
60
- import './worker/heartbeat';
61
- import './worker/email';
62
- import './worker/sms';
63
- import './worker/update-ecb-rates';
64
- import './worker/update-coinbase-rates';
65
- import { configureExportToken } from './worker/export-token';
66
- import { configureGenerateOrderAutoscheduling } from './worker/enrollment-order-generator';
67
- import { configureUpdateTokenOwnership } from './worker/update-token-ownership';
55
+ import './worker/bulk-import.js';
56
+ import './worker/zombie-killer.js';
57
+ import './worker/message.js';
58
+ import './worker/external.js';
59
+ import './worker/http-request.js';
60
+ import './worker/heartbeat.js';
61
+ import './worker/email.js';
62
+ import './worker/sms.js';
63
+ import './worker/push-notification.js';
64
+ import './worker/update-ecb-rates.js';
65
+ import './worker/update-coinbase-rates.js';
66
+ import { configureExportToken } from './worker/export-token.js';
67
+ import { configureGenerateOrderAutoscheduling } from './worker/enrollment-order-generator.js';
68
+ import { configureUpdateTokenOwnership } from './worker/update-token-ownership.js';
68
69
 
69
70
  // Asset Management
70
- import './files/gridfs/gridfs-adapter';
71
- import { gridfsHandler } from './files/gridfs/gridfs-webhook';
72
- import { configureGridFSFileUploadModule } from './files/gridfs';
71
+ import './files/gridfs/gridfs-adapter.js';
72
+ import { gridfsHandler } from './files/gridfs/gridfs-webhook.js';
73
+ import { configureGridFSFileUploadModule } from './files/gridfs/index.js';
73
74
 
74
75
  const {
75
76
  CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay',
@@ -0,0 +1,92 @@
1
+ import {applyRate} from './product-discount.js'
2
+ describe('applyRate', () => {
3
+ it('applies the rate correctly when a rate is provided', () => {
4
+ const configuration = {
5
+ rate: 0.1
6
+ };
7
+ const amount = 100;
8
+ expect(applyRate(configuration, amount)).toBe(10);
9
+ });
10
+
11
+ it('applies the fixed rate correctly when a fixed rate is provided', () => {
12
+ const configuration = {
13
+ fixedRate: 50
14
+ };
15
+ const amount = 100;
16
+ expect(applyRate(configuration, amount)).toBe(50);
17
+ });
18
+
19
+ it('applies the fixed rate correctly when a fixed rate is provided and the amount is less than fixed rate', () => {
20
+ const configuration = {
21
+ fixedRate: 150
22
+ };
23
+ const amount = 100;
24
+ expect(applyRate(configuration, amount)).toBe(100);
25
+ });
26
+
27
+ it('applies the rate correctly when rate is less than or equal to 0', () => {
28
+ const configuration = {
29
+ rate: -0.1
30
+ };
31
+ const amount = 100;
32
+ expect(applyRate(configuration, amount)).toBe(-10);
33
+ });
34
+ it('applies the rate correctly when only rate is provided and amount is negative', () => {
35
+ const configuration = {
36
+ rate: 0.1
37
+ };
38
+ const amount = -100;
39
+ expect(applyRate(configuration, amount)).toBe(-10);
40
+ });
41
+
42
+
43
+ it('applies the rate correctly when only rate is provided and amount is negative', () => {
44
+ const configuration = {
45
+ rate: 0.1
46
+ };
47
+ const amount = -100;
48
+ expect(applyRate(configuration, amount)).toBe(-10);
49
+ });
50
+
51
+
52
+ it('applies the rate correctly when only rate is provided and amount is negative', () => {
53
+ const configuration = {
54
+ rate: 0.1
55
+ };
56
+ const amount = -100;
57
+ expect(applyRate(configuration, amount)).toBe(-10);
58
+ });
59
+
60
+
61
+
62
+ it('applies the rate correctly when only rate is provided and amount is negative', () => {
63
+ const configuration = {
64
+ rate: 0.1
65
+ };
66
+ const amount = -100;
67
+ expect(applyRate(configuration, amount)).toBe(-10);
68
+ });
69
+
70
+
71
+ it('returns 0 when rate and fixed rate are not provided', () => {
72
+ const configuration = {};
73
+ const amount = 100;
74
+ expect(applyRate(configuration, amount)).toBe(0);
75
+ });
76
+
77
+ it('applies the rate correctly when only rate is provided and amount is negative', () => {
78
+ const configuration = {
79
+ rate: 0.1
80
+ };
81
+ const amount = -100;
82
+ expect(applyRate(configuration, amount)).toBe(-10);
83
+ });
84
+
85
+ it('returns 0 when rate and fixed rate are not provided', () => {
86
+ const configuration = {};
87
+ const amount = 100;
88
+ expect(applyRate(configuration, amount)).toBe(0);
89
+ });
90
+
91
+
92
+ });
@@ -0,0 +1,44 @@
1
+ import {configureProductPriceRounding, ProductPriceRoundSettings } from './product-price-round.js'
2
+
3
+
4
+
5
+ describe('configureProductPriceRounding', () => {
6
+ beforeEach(() => {
7
+ ProductPriceRoundSettings.configurations = {};
8
+ ProductPriceRoundSettings.defaultPrecision = 50;
9
+ ProductPriceRoundSettings.skip = [];
10
+ });
11
+
12
+ it('updates the default precision correctly', () => {
13
+ configureProductPriceRounding({ defaultPrecision: 100 } as any);
14
+ expect(ProductPriceRoundSettings.defaultPrecision).toBe(100);
15
+ });
16
+
17
+ it('updates the configurations correctly', () => {
18
+ configureProductPriceRounding({ configurations: { 'product1': 25 } } as any);
19
+ expect(ProductPriceRoundSettings.configurations).toEqual({ 'product1': 25 });
20
+ });
21
+
22
+ it('updates the skip list correctly', () => {
23
+ configureProductPriceRounding({ skip: ['product1'] } as any);
24
+ expect(ProductPriceRoundSettings.skip).toEqual(['product1']);
25
+ });
26
+
27
+ it('updates multiple properties correctly', () => {
28
+ configureProductPriceRounding({
29
+ configurations: { 'product1': 25 },
30
+ defaultPrecision: 100,
31
+ skip: ['product1']
32
+ });
33
+ expect(ProductPriceRoundSettings.configurations).toEqual({ 'product1': 25 });
34
+ expect(ProductPriceRoundSettings.defaultPrecision).toBe(100);
35
+ expect(ProductPriceRoundSettings.skip).toEqual(['product1']);
36
+ });
37
+
38
+ it('does not update any properties when no arguments are passed', () => {
39
+ configureProductPriceRounding({} as any);
40
+ expect(ProductPriceRoundSettings.configurations).toEqual({});
41
+ expect(ProductPriceRoundSettings.defaultPrecision).toBe(50);
42
+ expect(ProductPriceRoundSettings.skip).toEqual([]);
43
+ });
44
+ });
@@ -2,7 +2,7 @@ import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/
2
2
  import {
3
3
  DeliveryPricingAdapterContext,
4
4
  IDeliveryPricingAdapter,
5
- } from '@unchainedshop/types/delivery.pricing';
5
+ } from '@unchainedshop/types/delivery.pricing.js';
6
6
 
7
7
  // https://www.ch.ch/de/mehrwertsteuersatz-schweiz/
8
8
  export const SwissTaxCategories = {
@@ -0,0 +1,31 @@
1
+ import { HundredOff } from './discount-100-off.js';
2
+
3
+ describe('HundredOff', () => {
4
+ it('isManualAdditionAllowed', async () => {
5
+ let x
6
+ expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
7
+ });
8
+ it('isManualRemovalAllowed', async () => {
9
+ expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
10
+ });
11
+ it('isValidForSystemTriggering', async () => {
12
+ const context = {};
13
+ const actions = await HundredOff.actions({ context } as any);
14
+ expect(await actions.isValidForSystemTriggering()).toBeFalsy();
15
+ });
16
+ it('isValidForCodeTriggering', async () => {
17
+ const context = {};
18
+ const actions = await HundredOff.actions({ context } as any);
19
+ expect(await actions.isValidForCodeTriggering({ code: '100OFF' })).toBeTruthy();
20
+ expect(await actions.isValidForCodeTriggering({ code: 'wrongcode' })).toBeFalsy();
21
+ });
22
+
23
+ it('discountForPricingAdapterKey', async () => {
24
+ const context = {};
25
+ const actions = await HundredOff.actions({ context } as any);
26
+ expect(
27
+ actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.order-discount' } as any)
28
+ ).toEqual({ fixedRate: 10000 });
29
+ expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
30
+ });
31
+ });
@@ -1,7 +1,7 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount';
1
+ import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
2
2
  import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
3
3
 
4
- const HundredOff: IDiscountAdapter = {
4
+ export const HundredOff: IDiscountAdapter = {
5
5
  ...OrderDiscountAdapter,
6
6
 
7
7
  key: 'shop.unchained.discount.100-off',
@@ -0,0 +1,42 @@
1
+ import { HalfPriceManual } from './discount-half-price-manual.js';
2
+
3
+ describe('HalfPriceManual', () => {
4
+ it('isManualAdditionAllowed', async () => {
5
+ let x;
6
+ expect(await HalfPriceManual.isManualAdditionAllowed(x)).toBeTruthy();
7
+ });
8
+
9
+ it('isManualRemovalAllowed', async () => {
10
+ expect(await HalfPriceManual.isManualRemovalAllowed()).toBeTruthy();
11
+ });
12
+
13
+ it('isValidForSystemTriggering', async () => {
14
+ const context = {};
15
+ const actions = await HalfPriceManual.actions({ context } as any);
16
+ expect(await actions.isValidForSystemTriggering()).toBeFalsy();
17
+ });
18
+
19
+ it('isValidForCodeTriggering', async () => {
20
+ const context = {};
21
+ const actions = await HalfPriceManual.actions({ context } as any);
22
+ expect(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' })).toBeTruthy();
23
+ expect(await actions.isValidForCodeTriggering({ code: 'othercode' })).toBeFalsy();
24
+ });
25
+
26
+ it('discountForPricingAdapterKey', async () => {
27
+ const context = {};
28
+ const actions = await HalfPriceManual.actions({ context } as any);
29
+ expect(
30
+ actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.product-discount' } as any)
31
+ ).toEqual({ rate: 0.5 });
32
+ expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
33
+ });
34
+
35
+ it('Actions', async () => {
36
+ const context = {};
37
+ const actions = await HalfPriceManual.actions({ context } as any);
38
+ expect(typeof actions.isValidForSystemTriggering).toBe('function');
39
+ expect(typeof actions.isValidForCodeTriggering).toBe('function');
40
+ expect(typeof actions.discountForPricingAdapterKey).toBe('function');
41
+ });
42
+ });
@@ -1,7 +1,7 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount';
1
+ import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
2
2
  import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
3
3
 
4
- const HalfPriceManual: IDiscountAdapter = {
4
+ export const HalfPriceManual: IDiscountAdapter = {
5
5
  ...OrderDiscountAdapter,
6
6
 
7
7
  key: 'shop.unchained.discount.half-price-manual',
@@ -0,0 +1,40 @@
1
+ import { HalfPrice } from './discount-half-price.js';
2
+
3
+ describe('HalfPrice', () => {
4
+ it('isManualAdditionAllowed', async () => {
5
+ expect(await HalfPrice.isManualAdditionAllowed('')).toBeFalsy();
6
+ });
7
+
8
+ it('isManualRemovalAllowed', async () => {
9
+ expect(await HalfPrice.isManualRemovalAllowed()).toBeFalsy();
10
+ });
11
+
12
+ it('isValidForSystemTriggering', async () => {
13
+ const context = {
14
+ modules: {
15
+ users: {
16
+ findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] }))
17
+ }
18
+ },
19
+ order: { userId: 'user-id' }
20
+ };
21
+ const actions = await HalfPrice.actions({ context } as any);
22
+ expect(await actions.isValidForSystemTriggering()).toBeTruthy();
23
+
24
+ context.modules.users.findUserById.mockImplementationOnce(() => Promise.resolve({ tags: [] }));
25
+ expect(await actions.isValidForSystemTriggering()).toBeFalsy();
26
+ });
27
+ it('discountForPricingAdapterKey', async () => {
28
+ const context = {};
29
+ const actions = await HalfPrice.actions({ context } as any);
30
+ expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.product-discount' } as any)).toEqual({ rate: 0.5 });
31
+ expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
32
+ });
33
+
34
+ it('isValidForCodeTriggering', async () => {
35
+ const context = {};
36
+ const actions = await HalfPrice.actions({ context } as any);
37
+
38
+ expect(await actions.isValidForCodeTriggering({code: ''})).toBeFalsy();
39
+ });
40
+ });
@@ -1,7 +1,7 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount';
1
+ import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
2
2
  import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
3
3
 
4
- const HalfPrice: IDiscountAdapter = {
4
+ export const HalfPrice: IDiscountAdapter = {
5
5
  ...OrderDiscountAdapter,
6
6
 
7
7
  key: 'shop.unchained.discount.half-price',
@@ -0,0 +1,12 @@
1
+ import { DeliveryFreePrice } from "./free-delivery.js";
2
+
3
+
4
+
5
+ describe("DeliveryFreePrice", () => {
6
+
7
+ it('should return true', () => {
8
+ expect(DeliveryFreePrice.isActivatedFor(undefined)).toBeTruthy();
9
+
10
+ });
11
+
12
+ })
@@ -1,5 +1,5 @@
1
1
  import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
2
- import { IDeliveryPricingAdapter } from '@unchainedshop/types/delivery.pricing';
2
+ import { IDeliveryPricingAdapter } from '@unchainedshop/types/delivery.pricing.js';
3
3
 
4
4
  export const DeliveryFreePrice: IDeliveryPricingAdapter = {
5
5
  ...DeliveryPricingAdapter,
@@ -1,5 +1,5 @@
1
1
  import { PaymentPricingAdapter, PaymentPricingDirector } from '@unchainedshop/core-payment';
2
- import { IPaymentPricingAdapter } from '@unchainedshop/types/payments.pricing';
2
+ import { IPaymentPricingAdapter } from '@unchainedshop/types/payments.pricing.js';
3
3
 
4
4
  export const PaymentFreePrice: IPaymentPricingAdapter = {
5
5
  ...PaymentPricingAdapter,
@@ -0,0 +1,69 @@
1
+ import { SwissTaxCategories, getTaxRate } from './product-swiss-tax.js';
2
+
3
+
4
+
5
+ describe('getTaxRate', () => {
6
+ it('default rate', () => {
7
+ const context: any = {
8
+ product: {
9
+ tags: []
10
+ },
11
+ provider: {
12
+ configuration: [],
13
+ },
14
+ };
15
+ expect(getTaxRate(context)).toBe(0.077);
16
+ });
17
+
18
+ it('reduced rate', () => {
19
+ const context: any = {
20
+ product: {
21
+ tags: ['swiss-tax-category:reduced']
22
+ },
23
+ provider: {
24
+ configuration: [
25
+ {
26
+ key: 'swiss-tax-category',
27
+ value: SwissTaxCategories.REDUCED.rate(),
28
+ },
29
+ ],
30
+ },
31
+ };
32
+ expect(getTaxRate(context)).toBe(0.025);
33
+ });
34
+
35
+ it('special rate', () => {
36
+ const context: any = {
37
+ product: {
38
+ tags: ['swiss-tax-category:special']
39
+ },
40
+ provider: {
41
+ configuration: [
42
+ {
43
+ key: 'swiss-tax-category',
44
+ value: SwissTaxCategories.SPECIAL.rate(),
45
+ },
46
+ ],
47
+ },
48
+ };
49
+ expect(getTaxRate(context)).toBe(0.037);
50
+ });
51
+
52
+ it('default rate', () => {
53
+ const context: any = {
54
+ product: {
55
+ tags: ['swiss-tax-category:default']
56
+ },
57
+ provider: {
58
+ configuration: [
59
+ {
60
+ key: 'swiss-tax-category',
61
+ value: SwissTaxCategories.DEFAULT.rate(),
62
+ },
63
+ ],
64
+ },
65
+ };
66
+ expect(getTaxRate(context)).toBe(0.077);
67
+ });
68
+
69
+ })