@unchainedshop/plugins 3.0.0-alpha2 → 3.0.0-alpha4

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 (217) hide show
  1. package/lib/delivery/pick-mup.js +1 -1
  2. package/lib/delivery/pick-mup.js.map +1 -1
  3. package/lib/files/gridfs/gridfs-webhook.d.ts +1 -1
  4. package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -1
  5. package/lib/filters/local-search.d.ts +1 -1
  6. package/lib/filters/local-search.d.ts.map +1 -1
  7. package/lib/filters/local-search.js.map +1 -1
  8. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
  9. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
  10. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
  11. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
  12. package/lib/payment/cryptopay/plugin.d.ts +1 -1
  13. package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
  14. package/lib/payment/datatrans-v2/index.js +2 -2
  15. package/lib/payment/datatrans-v2/index.js.map +1 -1
  16. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
  17. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
  18. package/lib/payment/paypal-checkout.js +7 -1
  19. package/lib/payment/paypal-checkout.js.map +1 -1
  20. package/lib/payment/postfinance-checkout/api.js +3 -3
  21. package/lib/payment/postfinance-checkout/api.js.map +1 -1
  22. package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
  23. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  24. package/lib/payment/saferpay/adapter.d.ts +1 -1
  25. package/lib/payment/saferpay/adapter.d.ts.map +1 -1
  26. package/lib/payment/saferpay/api/api/SaferpayClient.d.ts +1 -1
  27. package/lib/payment/saferpay/api/api/SaferpayClient.d.ts.map +1 -1
  28. package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
  29. package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
  30. package/lib/payment/stripe/middleware.d.ts.map +1 -1
  31. package/lib/payment/stripe/middleware.js +0 -3
  32. package/lib/payment/stripe/middleware.js.map +1 -1
  33. package/lib/payment/stripe/stripe.d.ts +3 -3
  34. package/lib/payment/stripe/stripe.d.ts.map +1 -1
  35. package/lib/payment/stripe/stripe.js +4 -4
  36. package/lib/payment/stripe/stripe.js.map +1 -1
  37. package/lib/plugins-index.d.ts +3 -31
  38. package/lib/plugins-index.d.ts.map +1 -1
  39. package/lib/plugins-index.js +10 -61
  40. package/lib/plugins-index.js.map +1 -1
  41. package/lib/presets/base-express.d.ts +3 -0
  42. package/lib/presets/base-express.d.ts.map +1 -0
  43. package/lib/presets/base-express.js +6 -0
  44. package/lib/presets/base-express.js.map +1 -0
  45. package/lib/presets/base-modules.d.ts +29 -0
  46. package/lib/presets/base-modules.d.ts.map +1 -0
  47. package/lib/presets/base-modules.js +40 -0
  48. package/lib/presets/base-modules.js.map +1 -0
  49. package/lib/presets/countries/ch.d.ts +4 -0
  50. package/lib/presets/countries/ch.d.ts.map +1 -0
  51. package/lib/presets/countries/ch.js +4 -0
  52. package/lib/presets/countries/ch.js.map +1 -0
  53. package/lib/presets/crypto-express.d.ts +4 -0
  54. package/lib/presets/crypto-express.d.ts.map +1 -0
  55. package/lib/presets/crypto-express.js +9 -0
  56. package/lib/presets/crypto-express.js.map +1 -0
  57. package/lib/presets/crypto-modules.d.ts +11 -0
  58. package/lib/presets/crypto-modules.d.ts.map +1 -0
  59. package/lib/presets/crypto-modules.js +14 -0
  60. package/lib/presets/crypto-modules.js.map +1 -0
  61. package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
  62. package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
  63. package/lib/pricing/delivery-swiss-tax.js +1 -1
  64. package/lib/pricing/delivery-swiss-tax.js.map +1 -1
  65. package/lib/pricing/discount-100-off.d.ts +1 -1
  66. package/lib/pricing/discount-100-off.d.ts.map +1 -1
  67. package/lib/pricing/discount-half-price-manual.d.ts +1 -1
  68. package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
  69. package/lib/pricing/discount-half-price.d.ts +1 -1
  70. package/lib/pricing/discount-half-price.d.ts.map +1 -1
  71. package/lib/pricing/free-delivery.d.ts +1 -1
  72. package/lib/pricing/free-delivery.d.ts.map +1 -1
  73. package/lib/pricing/free-delivery.js +1 -1
  74. package/lib/pricing/free-delivery.js.map +1 -1
  75. package/lib/pricing/free-payment.d.ts +1 -1
  76. package/lib/pricing/free-payment.d.ts.map +1 -1
  77. package/lib/pricing/free-payment.js +1 -1
  78. package/lib/pricing/free-payment.js.map +1 -1
  79. package/lib/pricing/order-delivery.d.ts +1 -1
  80. package/lib/pricing/order-delivery.d.ts.map +1 -1
  81. package/lib/pricing/order-discount.d.ts +1 -1
  82. package/lib/pricing/order-discount.d.ts.map +1 -1
  83. package/lib/pricing/order-discount.js +1 -1
  84. package/lib/pricing/order-discount.js.map +1 -1
  85. package/lib/pricing/order-items-discount.js +1 -1
  86. package/lib/pricing/order-items-discount.js.map +1 -1
  87. package/lib/pricing/order-round.d.ts +1 -1
  88. package/lib/pricing/order-round.d.ts.map +1 -1
  89. package/lib/pricing/order-round.js +1 -1
  90. package/lib/pricing/order-round.js.map +1 -1
  91. package/lib/pricing/product-catalog-price.d.ts +1 -1
  92. package/lib/pricing/product-catalog-price.d.ts.map +1 -1
  93. package/lib/pricing/product-discount.js +1 -1
  94. package/lib/pricing/product-discount.js.map +1 -1
  95. package/lib/pricing/product-price-rateconversion.d.ts +1 -1
  96. package/lib/pricing/product-price-rateconversion.d.ts.map +1 -1
  97. package/lib/pricing/product-round.d.ts +1 -1
  98. package/lib/pricing/product-round.d.ts.map +1 -1
  99. package/lib/pricing/product-swiss-tax.d.ts +4 -12
  100. package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
  101. package/lib/pricing/product-swiss-tax.js +3 -3
  102. package/lib/pricing/product-swiss-tax.js.map +1 -1
  103. package/lib/warehousing/eth-minter.js +4 -3
  104. package/lib/warehousing/eth-minter.js.map +1 -1
  105. package/lib/worker/bulk-import.d.ts +1 -1
  106. package/lib/worker/bulk-import.d.ts.map +1 -1
  107. package/lib/worker/bulk-import.js.map +1 -1
  108. package/lib/worker/error-notifications.d.ts +1 -1
  109. package/lib/worker/error-notifications.d.ts.map +1 -1
  110. package/lib/worker/error-notifications.js +1 -1
  111. package/lib/worker/error-notifications.js.map +1 -1
  112. package/lib/worker/export-token.d.ts +2 -2
  113. package/lib/worker/export-token.d.ts.map +1 -1
  114. package/lib/worker/export-token.js +1 -1
  115. package/lib/worker/export-token.js.map +1 -1
  116. package/lib/worker/external.d.ts +1 -1
  117. package/lib/worker/external.d.ts.map +1 -1
  118. package/lib/worker/http-request.d.ts +1 -1
  119. package/lib/worker/http-request.d.ts.map +1 -1
  120. package/lib/worker/message.d.ts +1 -1
  121. package/lib/worker/message.d.ts.map +1 -1
  122. package/lib/worker/message.js.map +1 -1
  123. package/lib/worker/update-coinbase-rates.js +1 -1
  124. package/lib/worker/update-coinbase-rates.js.map +1 -1
  125. package/lib/worker/update-ecb-rates.js +1 -1
  126. package/lib/worker/update-ecb-rates.js.map +1 -1
  127. package/lib/worker/update-token-ownership.d.ts +1 -1
  128. package/lib/worker/update-token-ownership.d.ts.map +1 -1
  129. package/lib/worker/zombie-killer.d.ts +1 -1
  130. package/lib/worker/zombie-killer.d.ts.map +1 -1
  131. package/package.json +28 -26
  132. package/src/delivery/pick-mup.ts +1 -1
  133. package/src/delivery/post.ts +1 -1
  134. package/src/delivery/send-message.ts +1 -1
  135. package/src/delivery/stores.ts +1 -1
  136. package/src/enrollments/licensed.ts +1 -1
  137. package/src/files/gridfs/gridfs-adapter.ts +1 -1
  138. package/src/files/gridfs/gridfs-webhook.ts +1 -1
  139. package/src/files/minio/minio-adapter.ts +1 -1
  140. package/src/filters/local-search.ts +4 -4
  141. package/src/filters/strict-equal.ts +1 -1
  142. package/src/payment/apple-iap/adapter.ts +3 -3
  143. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
  144. package/src/payment/braintree.ts +1 -1
  145. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
  146. package/src/payment/cryptopay/middleware.ts +3 -3
  147. package/src/payment/cryptopay/plugin.ts +2 -2
  148. package/src/payment/datatrans-v2/index.ts +3 -3
  149. package/src/payment/datatrans-v2/middleware.ts +1 -1
  150. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
  151. package/src/payment/invoice-prepaid.ts +1 -1
  152. package/src/payment/invoice.ts +1 -1
  153. package/src/payment/paypal-checkout.ts +8 -2
  154. package/src/payment/payrexx/index.ts +1 -1
  155. package/src/payment/payrexx/middleware.ts +1 -1
  156. package/src/payment/postfinance-checkout/api.ts +3 -3
  157. package/src/payment/postfinance-checkout/index.ts +1 -1
  158. package/src/payment/postfinance-checkout/middleware.ts +1 -1
  159. package/src/payment/postfinance-checkout/utils.ts +1 -1
  160. package/src/payment/saferpay/adapter.ts +2 -2
  161. package/src/payment/saferpay/api/api/SaferpayClient.ts +1 -1
  162. package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
  163. package/src/payment/saferpay/middleware.ts +1 -1
  164. package/src/payment/stripe/index.ts +1 -1
  165. package/src/payment/stripe/middleware.ts +1 -4
  166. package/src/payment/stripe/stripe.ts +7 -7
  167. package/src/plugins-index.ts +14 -70
  168. package/src/presets/base-express.ts +7 -0
  169. package/src/presets/base-modules.ts +56 -0
  170. package/src/presets/countries/ch.ts +3 -0
  171. package/src/presets/crypto-express.ts +12 -0
  172. package/src/presets/crypto-modules.ts +23 -0
  173. package/src/pricing/delivery-swiss-tax.ts +3 -6
  174. package/src/pricing/discount-100-off.test.ts +13 -7
  175. package/src/pricing/discount-100-off.ts +1 -1
  176. package/src/pricing/discount-half-price-manual.test.ts +13 -7
  177. package/src/pricing/discount-half-price-manual.ts +1 -1
  178. package/src/pricing/discount-half-price.test.ts +15 -7
  179. package/src/pricing/discount-half-price.ts +1 -1
  180. package/src/pricing/free-delivery.test.ts +3 -8
  181. package/src/pricing/free-delivery.ts +5 -2
  182. package/src/pricing/free-payment.ts +5 -2
  183. package/src/pricing/licenced-enrollment.test.ts +33 -34
  184. package/src/pricing/order-delivery.test.ts +3 -5
  185. package/src/pricing/order-delivery.ts +1 -1
  186. package/src/pricing/order-discount.test.ts +3 -3
  187. package/src/pricing/order-discount.ts +1 -1
  188. package/src/pricing/order-items-discount.ts +1 -1
  189. package/src/pricing/order-items.ts +1 -1
  190. package/src/pricing/order-payment.ts +1 -1
  191. package/src/pricing/order-round.ts +1 -1
  192. package/src/pricing/plugins-index.test.ts +1 -1
  193. package/src/pricing/product-catalog-price.ts +1 -1
  194. package/src/pricing/product-discount.ts +2 -5
  195. package/src/pricing/product-price-rateconversion.ts +1 -1
  196. package/src/pricing/product-round.ts +1 -1
  197. package/src/pricing/product-swiss-tax.test.ts +112 -86
  198. package/src/pricing/product-swiss-tax.ts +11 -8
  199. package/src/pricing/tax/ch.test.ts +16 -16
  200. package/src/quotations/manual.ts +1 -1
  201. package/src/warehousing/eth-minter.ts +8 -6
  202. package/src/warehousing/store.ts +1 -1
  203. package/src/worker/bulk-import.ts +2 -2
  204. package/src/worker/email.ts +1 -1
  205. package/src/worker/enrollment-order-generator.ts +5 -5
  206. package/src/worker/error-notifications.ts +1 -1
  207. package/src/worker/export-token.ts +8 -3
  208. package/src/worker/external.ts +1 -1
  209. package/src/worker/heartbeat.ts +1 -1
  210. package/src/worker/http-request.ts +1 -1
  211. package/src/worker/message.ts +1 -2
  212. package/src/worker/push-notification.ts +1 -1
  213. package/src/worker/sms.ts +1 -1
  214. package/src/worker/update-coinbase-rates.ts +3 -3
  215. package/src/worker/update-ecb-rates.ts +3 -3
  216. package/src/worker/update-token-ownership.ts +1 -1
  217. package/src/worker/zombie-killer.ts +1 -1
@@ -13,10 +13,10 @@ describe('HalfPrice', () => {
13
13
  const context = {
14
14
  modules: {
15
15
  users: {
16
- findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] }))
17
- }
16
+ findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] })),
17
+ },
18
18
  },
19
- order: { userId: 'user-id' }
19
+ order: { userId: 'user-id' },
20
20
  };
21
21
  const actions = await HalfPrice.actions({ context } as any);
22
22
  expect(await actions.isValidForSystemTriggering()).toBeTruthy();
@@ -27,14 +27,22 @@ describe('HalfPrice', () => {
27
27
  it('discountForPricingAdapterKey', async () => {
28
28
  const context = {};
29
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();
30
+ expect(
31
+ actions.discountForPricingAdapterKey({
32
+ pricingAdapterKey: 'shop.unchained.pricing.product-discount',
33
+ } as any),
34
+ ).toEqual({ rate: 0.5 });
35
+ expect(
36
+ actions.discountForPricingAdapterKey({
37
+ pricingAdapterKey: 'shop.unchained.pricing.other-discount',
38
+ } as any),
39
+ ).toBeNull();
32
40
  });
33
41
 
34
42
  it('isValidForCodeTriggering', async () => {
35
43
  const context = {};
36
44
  const actions = await HalfPrice.actions({ context } as any);
37
-
38
- expect(await actions.isValidForCodeTriggering({code: ''})).toBeFalsy();
45
+
46
+ expect(await actions.isValidForCodeTriggering({ code: '' })).toBeFalsy();
39
47
  });
40
48
  });
@@ -1,4 +1,4 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
1
+ import { IDiscountAdapter } from '@unchainedshop/utils';
2
2
  import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
3
3
  import { ProductDiscountConfiguration } from '@unchainedshop/core-products';
4
4
 
@@ -1,12 +1,7 @@
1
- import { DeliveryFreePrice } from "./free-delivery.js";
2
-
3
-
4
-
5
- describe("DeliveryFreePrice", () => {
1
+ import { DeliveryFreePrice } from './free-delivery.js';
6
2
 
3
+ describe('DeliveryFreePrice', () => {
7
4
  it('should return true', () => {
8
5
  expect(DeliveryFreePrice.isActivatedFor(undefined as any)).toBeTruthy();
9
-
10
6
  });
11
-
12
- })
7
+ });
@@ -1,5 +1,8 @@
1
- import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
2
- import { IDeliveryPricingAdapter } from '@unchainedshop/types/delivery.pricing.js';
1
+ import {
2
+ DeliveryPricingAdapter,
3
+ DeliveryPricingDirector,
4
+ IDeliveryPricingAdapter,
5
+ } from '@unchainedshop/core-delivery';
3
6
 
4
7
  export const DeliveryFreePrice: IDeliveryPricingAdapter = {
5
8
  ...DeliveryPricingAdapter,
@@ -1,5 +1,8 @@
1
- import { PaymentPricingAdapter, PaymentPricingDirector } from '@unchainedshop/core-payment';
2
- import { IPaymentPricingAdapter } from '@unchainedshop/types/payments.pricing.js';
1
+ import {
2
+ PaymentPricingAdapter,
3
+ PaymentPricingDirector,
4
+ IPaymentPricingAdapter,
5
+ } from '@unchainedshop/core-payment';
3
6
 
4
7
  export const PaymentFreePrice: IPaymentPricingAdapter = {
5
8
  ...PaymentPricingAdapter,
@@ -1,37 +1,36 @@
1
- import { rangeMatcher } from "../enrollments/licensed.js";
1
+ import { rangeMatcher } from '../enrollments/licensed.js';
2
2
 
3
3
  describe('rangeMatcher', () => {
4
- const now = new Date();
5
-
6
- const tomorrow = new Date();
7
- tomorrow.setDate(tomorrow.getDate() + 1);
8
- const tomorrowTimestamp = tomorrow.getTime();
9
- const yesterday = new Date();
10
- yesterday.setDate(yesterday.getDate() - 1);
11
- const yesterdayTimestamp = yesterday.getTime();
12
-
13
- it('matches correctly when the date is within the range', () => {
14
- const range = { start: yesterday, end: tomorrow };
15
- const matcher = rangeMatcher(now);
16
- expect(matcher(range)).toBe(true);
17
- });
18
-
19
- it('does not match when the date is before the start of the range', () => {
20
- const range = { start: tomorrow, end: tomorrow };
21
- const matcher = rangeMatcher(yesterday);
22
- expect(matcher(range)).toBe(false);
23
- });
24
-
25
- it('does not match when the date is after the end of the range', () => {
26
- const range = { start: yesterday, end: yesterday };
27
- const matcher = rangeMatcher(tomorrow);
28
- expect(matcher(range)).toBe(false);
29
- });
30
-
31
- it('matches correctly when the date is not provided', () => {
32
- const range = { start: yesterdayTimestamp, end: tomorrowTimestamp };
33
- const matcher = rangeMatcher();
34
- expect(matcher(range)).toBe(true);
35
- });
4
+ const now = new Date();
5
+
6
+ const tomorrow = new Date();
7
+ tomorrow.setDate(tomorrow.getDate() + 1);
8
+ const tomorrowTimestamp = tomorrow.getTime();
9
+ const yesterday = new Date();
10
+ yesterday.setDate(yesterday.getDate() - 1);
11
+ const yesterdayTimestamp = yesterday.getTime();
12
+
13
+ it('matches correctly when the date is within the range', () => {
14
+ const range = { start: yesterday, end: tomorrow };
15
+ const matcher = rangeMatcher(now);
16
+ expect(matcher(range)).toBe(true);
17
+ });
18
+
19
+ it('does not match when the date is before the start of the range', () => {
20
+ const range = { start: tomorrow, end: tomorrow };
21
+ const matcher = rangeMatcher(yesterday);
22
+ expect(matcher(range)).toBe(false);
23
+ });
24
+
25
+ it('does not match when the date is after the end of the range', () => {
26
+ const range = { start: yesterday, end: yesterday };
27
+ const matcher = rangeMatcher(tomorrow);
28
+ expect(matcher(range)).toBe(false);
29
+ });
30
+
31
+ it('matches correctly when the date is not provided', () => {
32
+ const range = { start: yesterdayTimestamp, end: tomorrowTimestamp };
33
+ const matcher = rangeMatcher();
34
+ expect(matcher(range)).toBe(true);
36
35
  });
37
-
36
+ });
@@ -1,9 +1,7 @@
1
- import { OrderDelivery } from "./order-delivery.js";
2
-
3
-
4
- describe("OrderDelivery ", () => {
1
+ import { OrderDelivery } from './order-delivery.js';
5
2
 
3
+ describe('OrderDelivery ', () => {
6
4
  it('isActivatedFor', () => {
7
5
  expect(OrderDelivery.isActivatedFor({} as any)).toBeTruthy();
8
6
  });
9
- })
7
+ });
@@ -1,4 +1,4 @@
1
- import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing.js';
1
+ import { IOrderPricingAdapter } from '@unchainedshop/core-orders';
2
2
  import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
3
3
 
4
4
  export const OrderDelivery: IOrderPricingAdapter = {
@@ -1,7 +1,7 @@
1
- import { OrderDiscount } from "./order-discount.js";
1
+ import { OrderDiscount } from './order-discount.js';
2
2
 
3
- describe("OrderDelivery ", () => {
3
+ describe('OrderDelivery ', () => {
4
4
  it('isActivatedFor', () => {
5
5
  expect(OrderDiscount.isActivatedFor({} as any)).toBeTruthy();
6
6
  });
7
- })
7
+ });
@@ -1,4 +1,4 @@
1
- import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing.js';
1
+ import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/core-orders';
2
2
  import {
3
3
  OrderPricingDirector,
4
4
  OrderPricingAdapter,
@@ -1,4 +1,4 @@
1
- import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing.js';
1
+ import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/core-orders';
2
2
  import {
3
3
  OrderPricingDirector,
4
4
  OrderPricingAdapter,
@@ -1,4 +1,4 @@
1
- import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing.js';
1
+ import { IOrderPricingAdapter } from '@unchainedshop/core-orders';
2
2
  import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
3
3
 
4
4
  const OrderItems: IOrderPricingAdapter = {
@@ -1,4 +1,4 @@
1
- import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing.js';
1
+ import { IOrderPricingAdapter } from '@unchainedshop/core-orders';
2
2
  import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
3
3
 
4
4
  const OrderPayment: IOrderPricingAdapter = {
@@ -1,5 +1,5 @@
1
1
  import { OrderPricingAdapter, OrderPricingDirector } from '@unchainedshop/core-orders';
2
- import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing.js';
2
+ import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/core-orders';
3
3
 
4
4
  interface PriceRoundSettings {
5
5
  defaultPrecision: number;
@@ -1,3 +1,3 @@
1
1
  describe('Plugins', () => {
2
- it.todo("Plugins Tests")
2
+ it.todo('Plugins Tests');
3
3
  });
@@ -1,4 +1,4 @@
1
- import { IProductPricingAdapter } from '@unchainedshop/types/products.pricing.js';
1
+ import { IProductPricingAdapter } from '@unchainedshop/core-products';
2
2
  import { ProductPricingDirector, ProductPricingAdapter } from '@unchainedshop/core-products';
3
3
  import { resolveBestCurrency } from '@unchainedshop/utils';
4
4
  import memoizee from 'memoizee';
@@ -1,8 +1,5 @@
1
- import type { Discount } from '@unchainedshop/types/discount.js';
2
- import {
3
- IProductPricingAdapter,
4
- ProductPricingRowCategory,
5
- } from '@unchainedshop/types/products.pricing.js';
1
+ import type { Discount } from '@unchainedshop/utils';
2
+ import { IProductPricingAdapter, ProductPricingRowCategory } from '@unchainedshop/core-products';
6
3
  import {
7
4
  ProductPricingDirector,
8
5
  ProductPricingAdapter,
@@ -1,4 +1,4 @@
1
- import { IProductPricingAdapter } from '@unchainedshop/types/products.pricing.js';
1
+ import { IProductPricingAdapter } from '@unchainedshop/core-products';
2
2
  import { ProductPricingDirector, ProductPricingAdapter } from '@unchainedshop/core-products';
3
3
 
4
4
  export const ProductPriceRateConversion: IProductPricingAdapter = {
@@ -1,4 +1,4 @@
1
- import { IProductPricingAdapter } from '@unchainedshop/types/products.pricing.js';
1
+ import { IProductPricingAdapter } from '@unchainedshop/core-products';
2
2
  import { ProductPricingAdapter, ProductPricingDirector } from '@unchainedshop/core-products';
3
3
 
4
4
  interface PriceRoundSettings {
@@ -1,100 +1,126 @@
1
1
  import { getTaxRate, isDeliveryAddressInSwitzerland } from './product-swiss-tax.js';
2
2
 
3
- describe("ProductSwissTax", () => {
3
+ describe('ProductSwissTax', () => {
4
+ describe('getTaxRate', () => {
5
+ it('default rate', () => {
6
+ expect(
7
+ getTaxRate({
8
+ product: {} as any,
9
+ order: {} as any,
10
+ } as any),
11
+ ).toBe(0.081);
12
+ });
4
13
 
14
+ it('reduced rate', () => {
15
+ expect(
16
+ getTaxRate({
17
+ product: {
18
+ tags: ['swiss-tax-category:reduced'],
19
+ },
20
+ order: {},
21
+ } as any),
22
+ ).toBe(0.026);
23
+ });
5
24
 
6
- describe('getTaxRate', () => {
7
- it('default rate', () => {
8
- expect(getTaxRate({
9
- product: {} as any,
10
- order: {} as any,
11
- })).toBe(0.081);
12
- });
25
+ it('special rate', () => {
26
+ expect(
27
+ getTaxRate({
28
+ product: {
29
+ tags: ['swiss-tax-category:special'],
30
+ },
31
+ order: {},
32
+ } as any),
33
+ ).toBe(0.038);
34
+ });
13
35
 
14
- it('reduced rate', () => {
15
- expect(getTaxRate({
16
- product: {
17
- tags: ['swiss-tax-category:reduced']
18
- } as any,
19
- order: {} as any,
20
- })).toBe(0.026);
36
+ it('default rate', () => {
37
+ expect(
38
+ getTaxRate({
39
+ product: {
40
+ tags: ['swiss-tax-category:default'],
41
+ },
42
+ order: {},
43
+ } as any),
44
+ ).toBe(0.081);
45
+ });
21
46
  });
22
47
 
23
- it('special rate', () => {
24
- expect(getTaxRate({
25
- product: {
26
- tags: ['swiss-tax-category:special']
27
- } as any,
28
- order: {} as any,
29
- })).toBe(0.038);
30
- });
48
+ describe('isDeliveryAddressInSwitzerland', () => {
49
+ const context = {
50
+ modules: {
51
+ orders: {
52
+ deliveries: {
53
+ findDelivery: import.meta.jest.fn(async ({ orderDeliveryId }) => {
54
+ if (orderDeliveryId === 'CH' || orderDeliveryId === 'LI')
55
+ return { context: { address: { countryCode: 'CH' } } };
56
+ if (orderDeliveryId === null) return { context: { address: null } };
57
+ return { context: { address: { countryCode: 'RT' } } };
58
+ }),
59
+ },
60
+ },
61
+ },
62
+ order: {
63
+ deliveryId: 'CH',
64
+ billingAddress: { countryCode: 'LI' },
65
+ },
66
+ country: 'CH',
67
+ };
68
+ it('Should return true when passed country code CH', async () => {
69
+ expect(
70
+ await isDeliveryAddressInSwitzerland({ ...context, country: 'ch', order: null } as any),
71
+ ).toBe(true);
72
+ });
31
73
 
32
- it('default rate', () => {
33
- expect(getTaxRate({
34
- product: {
35
- tags: ['swiss-tax-category:default']
36
- } as any,
37
- order: {} as any,
38
- })).toBe(0.081);
39
- });
74
+ it('Should return true when passed country code LI', async () => {
75
+ expect(
76
+ await isDeliveryAddressInSwitzerland({ ...context, country: 'LI', order: null } as any),
77
+ ).toBe(true);
78
+ });
40
79
 
41
- })
80
+ it('Should return false when country is neither CH nor LI and order is null', async () => {
81
+ expect(
82
+ await isDeliveryAddressInSwitzerland({ ...context, country: 'ET', order: null } as any),
83
+ ).toBe(false);
84
+ });
42
85
 
43
- describe('isDeliveryAddressInSwitzerland', () => {
44
- const context = {
45
- modules: {
46
- orders: {
47
- deliveries: {
48
- findDelivery: import.meta.jest.fn(async({orderDeliveryId}) =>{
49
- if(orderDeliveryId === 'CH' || orderDeliveryId === 'LI' )
50
- return {context: { address: { countryCode: 'CH'}}}
51
- if(orderDeliveryId === null)
52
- return {context: { address: null}}
53
- return {context: { address: {countryCode: 'RT'}}}
54
- })
55
- }
56
- }
57
- },
58
- order : {
59
- deliveryId: 'CH',
60
- billingAddress: {countryCode: 'LI'}
61
- },
62
- country: 'CH'
63
- }
64
- it('Should return true when passed country code CH', async () => {
65
- expect(await isDeliveryAddressInSwitzerland({...context, country: 'ch', order: null})).toBe(true);
66
- });
86
+ it('Order should take precedence over country parameter', async () => {
87
+ // not CH or LI order so returns false
88
+ expect(
89
+ await isDeliveryAddressInSwitzerland({
90
+ ...context,
91
+ country: 'CH',
92
+ order: {
93
+ deliveryId: 'ET',
94
+ billingAddress: { countryCode: 'ET' },
95
+ },
96
+ } as any),
97
+ ).toBe(false);
98
+ });
67
99
 
68
- it('Should return true when passed country code LI', async () => {
69
- expect(await isDeliveryAddressInSwitzerland({...context, country: 'LI', order: null})).toBe(true);
70
- });
71
-
72
- it('Should return false when country is neither CH nor LI and order is null', async () => {
73
- expect(await isDeliveryAddressInSwitzerland({...context, country: 'ET', order: null})).toBe(false);
74
- });
100
+ it('If order is not from CH and LI but billingAddress is, it should take precedence over country ', async () => {
101
+ expect(
102
+ await isDeliveryAddressInSwitzerland({
103
+ ...context,
104
+ country: 'IT',
105
+ order: {
106
+ deliveryId: null,
107
+ billingAddress: { countryCode: 'CH' },
108
+ },
109
+ } as any),
110
+ ).toBe(true);
111
+ });
75
112
 
76
- it('Order should take precedence over country parameter', async () => {
77
- // not CH or LI order so returns false
78
- expect(await isDeliveryAddressInSwitzerland({...context, country: 'CH', order : {
79
- deliveryId: 'ET',
80
- billingAddress: {countryCode: 'ET'}
81
- }})).toBe(false);
82
- });
83
-
84
- it('If order is not from CH and LI but billingAddress is, it should take precedence over country ', async () => {
85
- expect(await isDeliveryAddressInSwitzerland({...context, country: 'IT', order : {
86
- deliveryId: null,
87
- billingAddress: { countryCode: 'CH'}
88
- }})).toBe(true);
89
- });
90
-
91
- it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
92
- expect(await isDeliveryAddressInSwitzerland({...context, country: null, order : {
93
- deliveryId: null,
94
- billingAddress: {countryCode: 'HH'}
95
- }})).toBe(false);
113
+ it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
114
+ expect(
115
+ await isDeliveryAddressInSwitzerland({
116
+ ...context,
117
+ country: null,
118
+ order: {
119
+ deliveryId: null,
120
+ billingAddress: { countryCode: 'HH' },
121
+ },
122
+ } as any),
123
+ ).toBe(false);
124
+ });
96
125
  });
97
126
  });
98
-
99
-
100
- })
@@ -1,13 +1,12 @@
1
- import { ProductPricingDirector, ProductPricingAdapter } from '@unchainedshop/core-products';
2
1
  import {
3
- IProductPricingAdapter,
4
- ProductPricingRowCategory,
5
- } from '@unchainedshop/types/products.pricing.js';
6
- import { Product } from '@unchainedshop/types/products.js';
7
- import { Order } from '@unchainedshop/types/orders.js';
2
+ ProductPricingDirector,
3
+ ProductPricingAdapter,
4
+ ProductPricingAdapterContext,
5
+ } from '@unchainedshop/core-products';
6
+ import { IProductPricingAdapter, ProductPricingRowCategory } from '@unchainedshop/core-products';
8
7
  import { SwissTaxCategories } from './tax/ch.js';
9
8
 
10
- export const getTaxRate = (context: { product: Product; order?: Order }) => {
9
+ export const getTaxRate = (context: ProductPricingAdapterContext) => {
11
10
  const { product, order } = context;
12
11
 
13
12
  const productSpecialTaxTag = product.tags?.find((tag) =>
@@ -21,7 +20,11 @@ export const getTaxRate = (context: { product: Product; order?: Order }) => {
21
20
  return taxCategory.rate(order?.ordered);
22
21
  };
23
22
 
24
- export const isDeliveryAddressInSwitzerland = async ({ order, country, modules }) => {
23
+ export const isDeliveryAddressInSwitzerland = async ({
24
+ order,
25
+ country,
26
+ modules,
27
+ }: ProductPricingAdapterContext) => {
25
28
  let countryCode = country?.toUpperCase().trim();
26
29
 
27
30
  if (order) {
@@ -1,18 +1,18 @@
1
- import { SwissTaxCategories } from "./ch";
1
+ import { SwissTaxCategories } from './ch';
2
2
 
3
3
  describe('SwissTaxCategories', () => {
4
- it('DEFAULT rate', () => {
5
- expect(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1))).toBe(0.077);
6
- expect(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1))).toBe(0.081);
7
- });
8
-
9
- it('REDUCED rate', () => {
10
- expect(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1))).toBe(0.025);
11
- expect(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1))).toBe(0.026);
12
- });
13
-
14
- it('SPECIAL rate', () => {
15
- expect(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1))).toBe(0.037);
16
- expect(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1))).toBe(0.038);
17
- });
18
- });
4
+ it('DEFAULT rate', () => {
5
+ expect(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1))).toBe(0.077);
6
+ expect(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1))).toBe(0.081);
7
+ });
8
+
9
+ it('REDUCED rate', () => {
10
+ expect(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1))).toBe(0.025);
11
+ expect(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1))).toBe(0.026);
12
+ });
13
+
14
+ it('SPECIAL rate', () => {
15
+ expect(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1))).toBe(0.037);
16
+ expect(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1))).toBe(0.038);
17
+ });
18
+ });
@@ -1,4 +1,4 @@
1
- import { IQuotationAdapter } from '@unchainedshop/types/quotations.js';
1
+ import { IQuotationAdapter } from '@unchainedshop/core-quotations';
2
2
  import { QuotationDirector, QuotationAdapter } from '@unchainedshop/core-quotations';
3
3
 
4
4
  const ManualOffering: IQuotationAdapter = {
@@ -3,15 +3,16 @@ import {
3
3
  WarehousingAdapter,
4
4
  WarehousingProviderType,
5
5
  } from '@unchainedshop/core-warehousing';
6
- import { ProductContractStandard, ProductType } from '@unchainedshop/types/products.js';
6
+ import { ProductContractStandard } from '@unchainedshop/core-products';
7
7
  import {
8
8
  IWarehousingAdapter,
9
9
  WarehousingContext,
10
10
  WarehousingError,
11
- } from '@unchainedshop/types/warehousing.js';
11
+ } from '@unchainedshop/core-warehousing';
12
12
  import { systemLocale } from '@unchainedshop/utils';
13
13
  import { generateDbObjectId } from '@unchainedshop/mongodb';
14
- import { Context } from '@unchainedshop/types/api.js';
14
+ import { UnchainedCore } from '@unchainedshop/core';
15
+ import { ProductTypes } from '@unchainedshop/core-products';
15
16
 
16
17
  const { MINTER_TOKEN_OFFSET = '0' } = process.env;
17
18
 
@@ -30,7 +31,8 @@ const ETHMinter: IWarehousingAdapter = {
30
31
  },
31
32
 
32
33
  actions: (configuration, context) => {
33
- const { product, orderPosition, token, modules, locale } = context as WarehousingContext & Context;
34
+ const { product, orderPosition, token, modules, locale } = context as WarehousingContext &
35
+ UnchainedCore;
34
36
  const { contractAddress, contractStandard, tokenId, supply, ercMetadataProperties } =
35
37
  product?.tokenization || {};
36
38
 
@@ -53,7 +55,7 @@ const ETHMinter: IWarehousingAdapter = {
53
55
  ...WarehousingAdapter.actions(configuration, context),
54
56
 
55
57
  isActive() {
56
- return product?.type === ProductType.TokenizedProduct;
58
+ return product?.type === ProductTypes.TokenizedProduct;
57
59
  },
58
60
 
59
61
  configurationError() {
@@ -116,7 +118,7 @@ const ETHMinter: IWarehousingAdapter = {
116
118
  const url = file && (await modules.files.getUrl(file, {}));
117
119
  const text = await modules.products.texts.findLocalizedText({
118
120
  productId: product._id,
119
- locale: locale?.normalized || systemLocale.normalized,
121
+ locale: locale?.baseName || systemLocale.baseName,
120
122
  });
121
123
 
122
124
  const name = `${text.title} #${chainTokenId}`;
@@ -3,7 +3,7 @@ import {
3
3
  WarehousingAdapter,
4
4
  WarehousingProviderType,
5
5
  } from '@unchainedshop/core-warehousing';
6
- import { IWarehousingAdapter } from '@unchainedshop/types/warehousing.js';
6
+ import { IWarehousingAdapter } from '@unchainedshop/core-warehousing';
7
7
 
8
8
  const Store: IWarehousingAdapter = {
9
9
  ...WarehousingAdapter,
@@ -1,9 +1,9 @@
1
- import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
2
1
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
3
2
  import { createLogger, LogLevel } from '@unchainedshop/logger';
4
3
  import JSONStream from 'JSONStream';
5
4
  import { EventIterator } from 'event-iterator';
6
- import { UnchainedCore } from '@unchainedshop/types/core.js';
5
+ import { UnchainedCore } from '@unchainedshop/core';
6
+ import { IWorkerAdapter } from '@unchainedshop/core-worker';
7
7
 
8
8
  const logger = createLogger('unchained:platform:bulk-import');
9
9
 
@@ -3,7 +3,7 @@ import { join, isAbsolute } from 'path';
3
3
  import { tmpdir } from 'os';
4
4
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
5
5
  import { createLogger } from '@unchainedshop/logger';
6
- import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
6
+ import { IWorkerAdapter } from '@unchainedshop/core-worker';
7
7
  import open from 'open';
8
8
  import nodemailer from 'nodemailer';
9
9