@unchainedshop/plugins 2.14.2 → 3.0.0-alpha3

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 (220) 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/cryptopay/plugin.js +3 -3
  15. package/lib/payment/cryptopay/plugin.js.map +1 -1
  16. package/lib/payment/datatrans-v2/index.js +1 -1
  17. package/lib/payment/datatrans-v2/index.js.map +1 -1
  18. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
  19. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
  20. package/lib/payment/paypal-checkout.js +7 -1
  21. package/lib/payment/paypal-checkout.js.map +1 -1
  22. package/lib/payment/payrexx/index.js +0 -1
  23. package/lib/payment/payrexx/index.js.map +1 -1
  24. package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
  25. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  26. package/lib/payment/saferpay/adapter.d.ts +1 -1
  27. package/lib/payment/saferpay/adapter.d.ts.map +1 -1
  28. package/lib/payment/saferpay/api/api/SaferpayClient.d.ts +1 -1
  29. package/lib/payment/saferpay/api/api/SaferpayClient.d.ts.map +1 -1
  30. package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
  31. package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
  32. package/lib/payment/stripe/stripe.d.ts +3 -3
  33. package/lib/payment/stripe/stripe.d.ts.map +1 -1
  34. package/lib/payment/stripe/stripe.js +1 -1
  35. package/lib/plugins-index.d.ts +2 -33
  36. package/lib/plugins-index.d.ts.map +1 -1
  37. package/lib/plugins-index.js +16 -71
  38. package/lib/plugins-index.js.map +1 -1
  39. package/lib/presets/base-express.d.ts +3 -0
  40. package/lib/presets/base-express.d.ts.map +1 -0
  41. package/lib/presets/base-express.js +6 -0
  42. package/lib/presets/base-express.js.map +1 -0
  43. package/lib/presets/base-modules.d.ts +29 -0
  44. package/lib/presets/base-modules.d.ts.map +1 -0
  45. package/lib/presets/base-modules.js +40 -0
  46. package/lib/presets/base-modules.js.map +1 -0
  47. package/lib/presets/countries/ch.d.ts +4 -0
  48. package/lib/presets/countries/ch.d.ts.map +1 -0
  49. package/lib/presets/countries/ch.js +4 -0
  50. package/lib/presets/countries/ch.js.map +1 -0
  51. package/lib/presets/crypto-express.d.ts +4 -0
  52. package/lib/presets/crypto-express.d.ts.map +1 -0
  53. package/lib/presets/crypto-express.js +9 -0
  54. package/lib/presets/crypto-express.js.map +1 -0
  55. package/lib/presets/crypto-modules.d.ts +11 -0
  56. package/lib/presets/crypto-modules.d.ts.map +1 -0
  57. package/lib/presets/crypto-modules.js +14 -0
  58. package/lib/presets/crypto-modules.js.map +1 -0
  59. package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
  60. package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
  61. package/lib/pricing/delivery-swiss-tax.js +1 -1
  62. package/lib/pricing/delivery-swiss-tax.js.map +1 -1
  63. package/lib/pricing/discount-100-off.d.ts +1 -1
  64. package/lib/pricing/discount-100-off.d.ts.map +1 -1
  65. package/lib/pricing/discount-half-price-manual.d.ts +1 -1
  66. package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
  67. package/lib/pricing/discount-half-price.d.ts +1 -1
  68. package/lib/pricing/discount-half-price.d.ts.map +1 -1
  69. package/lib/pricing/free-delivery.d.ts +1 -1
  70. package/lib/pricing/free-delivery.d.ts.map +1 -1
  71. package/lib/pricing/free-delivery.js +1 -1
  72. package/lib/pricing/free-delivery.js.map +1 -1
  73. package/lib/pricing/free-payment.d.ts +1 -1
  74. package/lib/pricing/free-payment.d.ts.map +1 -1
  75. package/lib/pricing/free-payment.js +1 -1
  76. package/lib/pricing/free-payment.js.map +1 -1
  77. package/lib/pricing/order-delivery.d.ts +1 -1
  78. package/lib/pricing/order-delivery.d.ts.map +1 -1
  79. package/lib/pricing/order-discount.d.ts +1 -1
  80. package/lib/pricing/order-discount.d.ts.map +1 -1
  81. package/lib/pricing/order-discount.js +1 -1
  82. package/lib/pricing/order-discount.js.map +1 -1
  83. package/lib/pricing/order-items-discount.js +1 -1
  84. package/lib/pricing/order-items-discount.js.map +1 -1
  85. package/lib/pricing/order-round.d.ts +1 -1
  86. package/lib/pricing/order-round.d.ts.map +1 -1
  87. package/lib/pricing/order-round.js +1 -1
  88. package/lib/pricing/order-round.js.map +1 -1
  89. package/lib/pricing/product-catalog-price.d.ts +2 -1
  90. package/lib/pricing/product-catalog-price.d.ts.map +1 -1
  91. package/lib/pricing/product-catalog-price.js +17 -4
  92. package/lib/pricing/product-catalog-price.js.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-price-rateconversion.js +1 -1
  98. package/lib/pricing/product-price-rateconversion.js.map +1 -1
  99. package/lib/pricing/product-round.d.ts +1 -1
  100. package/lib/pricing/product-round.d.ts.map +1 -1
  101. package/lib/pricing/product-swiss-tax.d.ts +4 -12
  102. package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
  103. package/lib/pricing/product-swiss-tax.js +3 -3
  104. package/lib/pricing/product-swiss-tax.js.map +1 -1
  105. package/lib/warehousing/eth-minter.js +4 -3
  106. package/lib/warehousing/eth-minter.js.map +1 -1
  107. package/lib/worker/bulk-import.d.ts +1 -1
  108. package/lib/worker/bulk-import.d.ts.map +1 -1
  109. package/lib/worker/bulk-import.js.map +1 -1
  110. package/lib/worker/enrollment-order-generator.d.ts.map +1 -1
  111. package/lib/worker/enrollment-order-generator.js +1 -0
  112. package/lib/worker/enrollment-order-generator.js.map +1 -1
  113. package/lib/worker/error-notifications.d.ts +1 -1
  114. package/lib/worker/error-notifications.d.ts.map +1 -1
  115. package/lib/worker/error-notifications.js +1 -1
  116. package/lib/worker/error-notifications.js.map +1 -1
  117. package/lib/worker/export-token.d.ts +2 -2
  118. package/lib/worker/export-token.d.ts.map +1 -1
  119. package/lib/worker/export-token.js +1 -1
  120. package/lib/worker/export-token.js.map +1 -1
  121. package/lib/worker/external.d.ts +1 -1
  122. package/lib/worker/external.d.ts.map +1 -1
  123. package/lib/worker/http-request.d.ts +1 -1
  124. package/lib/worker/http-request.d.ts.map +1 -1
  125. package/lib/worker/message.d.ts +1 -1
  126. package/lib/worker/message.d.ts.map +1 -1
  127. package/lib/worker/message.js.map +1 -1
  128. package/lib/worker/update-ecb-rates.js +2 -2
  129. package/lib/worker/update-ecb-rates.js.map +1 -1
  130. package/lib/worker/update-token-ownership.d.ts +1 -1
  131. package/lib/worker/update-token-ownership.d.ts.map +1 -1
  132. package/lib/worker/zombie-killer.d.ts +1 -1
  133. package/lib/worker/zombie-killer.d.ts.map +1 -1
  134. package/package.json +23 -21
  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 +1 -1
  140. package/src/files/gridfs/gridfs-adapter.ts +1 -1
  141. package/src/files/gridfs/gridfs-webhook.ts +1 -1
  142. package/src/files/minio/minio-adapter.ts +1 -1
  143. package/src/filters/local-search.ts +4 -4
  144. package/src/filters/strict-equal.ts +1 -1
  145. package/src/payment/apple-iap/adapter.ts +3 -3
  146. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
  147. package/src/payment/braintree.ts +1 -1
  148. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
  149. package/src/payment/cryptopay/middleware.ts +3 -3
  150. package/src/payment/cryptopay/plugin.ts +5 -5
  151. package/src/payment/datatrans-v2/index.ts +2 -2
  152. package/src/payment/datatrans-v2/middleware.ts +1 -1
  153. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
  154. package/src/payment/invoice-prepaid.ts +1 -1
  155. package/src/payment/invoice.ts +1 -1
  156. package/src/payment/paypal-checkout.ts +8 -2
  157. package/src/payment/payrexx/index.ts +1 -2
  158. package/src/payment/payrexx/middleware.ts +1 -1
  159. package/src/payment/postfinance-checkout/index.ts +1 -1
  160. package/src/payment/postfinance-checkout/middleware.ts +1 -1
  161. package/src/payment/postfinance-checkout/utils.ts +1 -1
  162. package/src/payment/saferpay/adapter.ts +2 -2
  163. package/src/payment/saferpay/api/api/SaferpayClient.ts +1 -1
  164. package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
  165. package/src/payment/saferpay/middleware.ts +1 -1
  166. package/src/payment/stripe/index.ts +1 -1
  167. package/src/payment/stripe/middleware.ts +1 -1
  168. package/src/payment/stripe/stripe.ts +4 -4
  169. package/src/plugins-index.ts +18 -101
  170. package/src/presets/base-express.ts +7 -0
  171. package/src/presets/base-modules.ts +56 -0
  172. package/src/presets/countries/ch.ts +3 -0
  173. package/src/presets/crypto-express.ts +12 -0
  174. package/src/presets/crypto-modules.ts +23 -0
  175. package/src/pricing/delivery-swiss-tax.ts +3 -6
  176. package/src/pricing/discount-100-off.ts +1 -1
  177. package/src/pricing/discount-half-price-manual.ts +1 -1
  178. package/src/pricing/discount-half-price.ts +1 -1
  179. package/src/pricing/free-delivery.ts +5 -2
  180. package/src/pricing/free-payment.ts +5 -2
  181. package/src/pricing/order-delivery.ts +1 -1
  182. package/src/pricing/order-discount.ts +1 -1
  183. package/src/pricing/order-items-discount.ts +1 -1
  184. package/src/pricing/order-items.ts +1 -1
  185. package/src/pricing/order-payment.ts +1 -1
  186. package/src/pricing/order-round.ts +1 -1
  187. package/src/pricing/product-catalog-price.ts +24 -7
  188. package/src/pricing/product-discount.ts +2 -5
  189. package/src/pricing/product-price-rateconversion.ts +3 -2
  190. package/src/pricing/product-round.ts +1 -1
  191. package/src/pricing/product-swiss-tax.test.ts +1 -0
  192. package/src/pricing/product-swiss-tax.ts +11 -8
  193. package/src/quotations/manual.ts +1 -1
  194. package/src/warehousing/eth-minter.ts +8 -6
  195. package/src/warehousing/store.ts +1 -1
  196. package/src/worker/bulk-import.ts +2 -2
  197. package/src/worker/email.ts +1 -1
  198. package/src/worker/enrollment-order-generator.ts +8 -6
  199. package/src/worker/error-notifications.ts +1 -1
  200. package/src/worker/export-token.ts +8 -3
  201. package/src/worker/external.ts +1 -1
  202. package/src/worker/heartbeat.ts +1 -1
  203. package/src/worker/http-request.ts +1 -1
  204. package/src/worker/message.ts +1 -2
  205. package/src/worker/push-notification.ts +1 -1
  206. package/src/worker/sms.ts +1 -1
  207. package/src/worker/update-coinbase-rates.ts +2 -2
  208. package/src/worker/update-ecb-rates.ts +4 -4
  209. package/src/worker/update-token-ownership.ts +1 -1
  210. package/src/worker/zombie-killer.ts +1 -1
  211. package/lib/accounts/google-oauth.d.ts +0 -4
  212. package/lib/accounts/google-oauth.d.ts.map +0 -1
  213. package/lib/accounts/google-oauth.js +0 -145
  214. package/lib/accounts/google-oauth.js.map +0 -1
  215. package/lib/accounts/linkedin-oauth.d.ts +0 -4
  216. package/lib/accounts/linkedin-oauth.d.ts.map +0 -1
  217. package/lib/accounts/linkedin-oauth.js +0 -82
  218. package/lib/accounts/linkedin-oauth.js.map +0 -1
  219. package/src/accounts/google-oauth.ts +0 -181
  220. package/src/accounts/linkedin-oauth.ts +0 -103
@@ -1,4 +1,4 @@
1
- import { IEnrollmentAdapter } from '@unchainedshop/types/enrollments.js';
1
+ import { IEnrollmentAdapter } from '@unchainedshop/core-enrollments';
2
2
  import { EnrollmentDirector, EnrollmentAdapter } from '@unchainedshop/core-enrollments';
3
3
 
4
4
  export const rangeMatcher = (date = new Date()) => {
@@ -10,7 +10,7 @@ import {
10
10
  resolveExpirationDate,
11
11
  IFileAdapter,
12
12
  } from '@unchainedshop/file-upload';
13
- import { UploadFileData } from '@unchainedshop/types/files.js';
13
+ import { UploadFileData } from '@unchainedshop/core-files';
14
14
  import sign from './sign.js';
15
15
 
16
16
  const { ROOT_URL } = process.env;
@@ -2,7 +2,7 @@ import { pipeline, finished } from 'stream/promises';
2
2
  import { PassThrough } from 'stream';
3
3
  import { log, LogLevel } from '@unchainedshop/logger';
4
4
  import { buildHashedFilename } from '@unchainedshop/file-upload';
5
- import { Context } from '@unchainedshop/types/api.js';
5
+ import { Context } from '@unchainedshop/api';
6
6
  import express from 'express';
7
7
  import sign from './sign.js';
8
8
  import { configureGridFSFileUploadModule } from './index.js';
@@ -2,7 +2,7 @@ import https from 'https';
2
2
  import http, { OutgoingHttpHeaders } from 'http';
3
3
  import { Readable } from 'stream';
4
4
  import { URL } from 'url';
5
- import { UploadFileData } from '@unchainedshop/types/files.js';
5
+ import { UploadFileData } from '@unchainedshop/core-files';
6
6
  import {
7
7
  FileAdapter,
8
8
  FileDirector,
@@ -1,8 +1,8 @@
1
1
  import { FilterDirector, FilterAdapter } from '@unchainedshop/core-filters';
2
- import { IFilterAdapter } from '@unchainedshop/types/filters.js';
2
+ import { IFilterAdapter } from '@unchainedshop/core-filters';
3
3
  import { mongodb } from '@unchainedshop/mongodb';
4
- import { ProductText } from '@unchainedshop/types/products.js';
5
- import { AssortmentText } from '@unchainedshop/types/assortments.js';
4
+ import { ProductText } from '@unchainedshop/core-products';
5
+ import { AssortmentText } from '@unchainedshop/core-assortments';
6
6
 
7
7
  function escapeStringRegexp(string) {
8
8
  if (typeof string !== 'string') {
@@ -49,7 +49,7 @@ const LocalSearch: IFilterAdapter = {
49
49
  };
50
50
 
51
51
  if (productIds) {
52
- selector.productId = { $in: [...new Set(productIds)] };
52
+ selector.productId = { $in: [...new Set(productIds)] as any };
53
53
  }
54
54
 
55
55
  const products = await params.modules.products.texts.findTexts(selector, {
@@ -1,4 +1,4 @@
1
- import { IFilterAdapter } from '@unchainedshop/types/filters.js';
1
+ import { IFilterAdapter } from '@unchainedshop/core-filters';
2
2
  import { FilterDirector, FilterAdapter } from '@unchainedshop/core-filters';
3
3
 
4
4
  const StrictQualFilter: IFilterAdapter = {
@@ -1,10 +1,10 @@
1
1
  /// <reference lib="dom" />
2
- import { Context } from '@unchainedshop/types/api.js';
3
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
2
+ import { Context } from '@unchainedshop/api';
3
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
4
4
  import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
5
5
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
6
6
  import { createLogger } from '@unchainedshop/logger';
7
- import { UnchainedCore } from '@unchainedshop/types/core.js';
7
+ import { UnchainedCore } from '@unchainedshop/core';
8
8
  import { AppleTransactionsModule } from './module/configureAppleTransactionsModule.js';
9
9
 
10
10
  const logger = createLogger('unchained:core-payment:iap');
@@ -1,5 +1,5 @@
1
1
  import { mongodb } from '@unchainedshop/mongodb';
2
- import { TimestampFields } from '@unchainedshop/types/common.js';
2
+ import type { TimestampFields } from '@unchainedshop/mongodb';
3
3
 
4
4
  export type AppleTransaction = {
5
5
  _id?: string;
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
 
@@ -1,5 +1,5 @@
1
- import { TimestampFields } from '@unchainedshop/types/common.js';
2
1
  import { mongodb } from '@unchainedshop/mongodb';
2
+ import type { TimestampFields } from '@unchainedshop/mongodb';
3
3
 
4
4
  export type CryptopayTransaction = {
5
5
  _id?: string;
@@ -1,10 +1,10 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
- import { Context } from '@unchainedshop/types/api.js';
2
+ import { Context } from '@unchainedshop/api';
3
3
 
4
- import { UnchainedCore } from '@unchainedshop/types/core.js';
4
+ import { UnchainedCore } from '@unchainedshop/core';
5
5
  import { OrderStatus } from '@unchainedshop/core-orders';
6
- import { ProductPriceRate } from '@unchainedshop/types/products.pricing.js';
7
6
  import type { CryptopayModule } from './module/configureCryptopayModule.js';
7
+ import { ProductPriceRate } from '@unchainedshop/core-products';
8
8
 
9
9
  const { CRYPTOPAY_SECRET, CRYPTOPAY_MAX_RATE_AGE = '360' } = process.env;
10
10
 
@@ -1,11 +1,11 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { ethers } from 'ethers';
4
4
  import { BIP32Factory } from 'bip32';
5
5
  import * as ecc from 'tiny-secp256k1';
6
- import * as bitcoin from 'bitcoinjs-lib';
6
+ import { networks, payments } from 'bitcoinjs-lib';
7
7
  import { createLogger } from '@unchainedshop/logger';
8
- import { UnchainedCore } from '@unchainedshop/types/core.js';
8
+ import { UnchainedCore } from '@unchainedshop/core';
9
9
  import { OrderPricingSheet } from '@unchainedshop/core-orders';
10
10
  import { CryptopayModule } from './module/configureCryptopayModule.js';
11
11
 
@@ -151,7 +151,7 @@ const Cryptopay: IPaymentAdapter = {
151
151
 
152
152
  const cryptoAddresses: CryptopayAddress[] = [];
153
153
  if (CRYPTOPAY_BTC_XPUB) {
154
- const network = CRYPTOPAY_BTC_TESTNET ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
154
+ const network = CRYPTOPAY_BTC_TESTNET ? networks.testnet : networks.bitcoin;
155
155
  const bip32 = BIP32Factory(ecc);
156
156
  const hardenedMaster = bip32.fromBase58(CRYPTOPAY_BTC_XPUB, network);
157
157
  const btcDerivationNumber = await modules.cryptopay.getNextDerivationNumber(
@@ -161,7 +161,7 @@ const Cryptopay: IPaymentAdapter = {
161
161
  const child = hardenedMaster.derivePath(derivationPath);
162
162
  cryptoAddresses.push({
163
163
  currency: CryptopayCurrencies.BTC,
164
- address: bitcoin.payments.p2pkh({
164
+ address: payments.p2pkh({
165
165
  pubkey: child.publicKey,
166
166
  network,
167
167
  }).address,
@@ -1,7 +1,7 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentError, PaymentDirector } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
- import { PaymentPricingRowCategory } from '@unchainedshop/types/payments.pricing.js';
4
+ import { PaymentPricingRowCategory } from '@unchainedshop/core-payment';
5
5
  import createDatatransAPI from './api/index.js';
6
6
  import type {
7
7
  AuthorizeAuthenticatedResponseSuccess,
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
- import { Context } from '@unchainedshop/types/api.js';
2
+ import { Context } from '@unchainedshop/api';
3
3
  import generateSignature, { Security } from './generateSignature.js';
4
4
 
5
5
  import type { StatusResponseSuccess } from './api/types.js';
@@ -1,5 +1,5 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- import { Order } from '@unchainedshop/types/orders.js';
1
+ import { UnchainedCore } from '@unchainedshop/core';
2
+ import { Order } from '@unchainedshop/core-orders';
3
3
 
4
4
  const roundedAmountFromOrder = (
5
5
  order: Order,
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentProviderType } from '@unchainedshop/core-payment';
3
3
 
4
4
  const InvoicePrepaid: IPaymentAdapter = {
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentProviderType } from '@unchainedshop/core-payment';
3
3
 
4
4
  const Invoice: IPaymentAdapter = {
@@ -1,7 +1,13 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
- import checkoutNodeJssdk from '@paypal/checkout-server-sdk';
4
+
5
+ let checkoutNodeJssdk;
6
+ try {
7
+ checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
8
+ } catch {
9
+ /* */
10
+ }
5
11
 
6
12
  const logger = createLogger('unchained:core-payment');
7
13
 
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
  import { mapOrderDataToGatewayObject, mapUserToGatewayObject } from './payrexx.js';
@@ -89,7 +89,6 @@ const Payrexx: IPaymentAdapter = {
89
89
 
90
90
  async register(/* transactionResponse */) {
91
91
  // const { transactionId } = transactionResponse;
92
- // console.log({ transactionResponse });
93
92
  throw new Error('Not implemented');
94
93
  // const result = (await api().status({
95
94
  // transactionId,
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
 
4
4
  const logger = createLogger('unchained:core-payment:payrexx:webhook');
@@ -2,7 +2,7 @@ import {
2
2
  IPaymentActions,
3
3
  IPaymentAdapter,
4
4
  PaymentChargeActionResult,
5
- } from '@unchainedshop/types/payments.js';
5
+ } from '@unchainedshop/core-payment';
6
6
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
7
7
  import { createLogger } from '@unchainedshop/logger';
8
8
 
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { WebhookData } from './types.js';
4
4
  import { getTransaction, getTransactionCompletion } from './api.js';
@@ -1,4 +1,4 @@
1
- import { Order, OrdersModule } from '@unchainedshop/types/orders.js';
1
+ import { Order, OrdersModule } from '@unchainedshop/core-orders';
2
2
  import * as pf from 'postfinancecheckout';
3
3
 
4
4
  const { PostFinanceCheckout } = pf;
@@ -1,6 +1,6 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
- import { UnchainedCore } from '@unchainedshop/types/core.js';
3
+ import { UnchainedCore } from '@unchainedshop/core';
4
4
  import { mongodb } from '@unchainedshop/mongodb';
5
5
  import { PaymentPageInitializeInput, SaferpayClient } from './api/index.js';
6
6
  import { buildSignature } from './buildSignature.js';
@@ -1,4 +1,4 @@
1
- import { OrderPayment } from '@unchainedshop/types/orders.payments.js';
1
+ import { OrderPayment } from '@unchainedshop/core-orders';
2
2
  import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel.js';
3
3
  import { TransactionCaptureInput, TransactionCaptureResponse } from '../models/TransactionCapture.js';
4
4
  import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert.js';
@@ -1,5 +1,5 @@
1
1
  import { mongodb } from '@unchainedshop/mongodb';
2
- import { TimestampFields } from '@unchainedshop/types/common.js';
2
+ import type { TimestampFields } from '@unchainedshop/mongodb';
3
3
 
4
4
  export type SaferpayTransaction = {
5
5
  orderPaymentId: any;
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { buildSignature } from './buildSignature.js';
4
4
  import { SaferpayTransactionsModule } from './module/configureSaferpayTransactionsModule.js';
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
  import stripe, { createOrderPaymentIntent, createRegistrationIntent } from './stripe.js';
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import stripe from './stripe.js';
4
4
 
@@ -1,12 +1,12 @@
1
- import { Order } from '@unchainedshop/types/orders.js';
2
- import { OrderPayment } from '@unchainedshop/types/orders.payments.js';
3
- import { IOrderPricingSheet } from '@unchainedshop/types/orders.pricing.js';
1
+ import { Order } from '@unchainedshop/core-orders';
2
+ import { OrderPayment } from '@unchainedshop/core-orders';
3
+ import { IOrderPricingSheet } from '@unchainedshop/core-orders';
4
4
  import Stripe from 'stripe';
5
5
 
6
6
  const { STRIPE_SECRET, STRIPE_WEBHOOK_ENVIRONMENT, EMAIL_WEBSITE_NAME } = process.env;
7
7
 
8
8
  const stripe = new Stripe(STRIPE_SECRET, {
9
- apiVersion: '2024-04-10',
9
+ apiVersion: '2024-06-20',
10
10
  });
11
11
 
12
12
  const environment = STRIPE_WEBHOOK_ENVIRONMENT ?? null;
@@ -1,138 +1,72 @@
1
- import { useMiddlewareWithCurrentContext } from '@unchainedshop/api/express/index.js';
2
- import { ModuleInput, UnchainedCore } from '@unchainedshop/types/core.js';
1
+ import { ModuleInput, UnchainedCore } from '@unchainedshop/core';
3
2
  import express from 'express';
4
3
 
4
+ import baseModules from './presets/base-modules.js';
5
+ import './presets/countries/ch.js';
6
+ import cryptoModules from './presets/crypto-modules.js';
7
+
8
+ import connectCryptoToExpress from './presets/crypto-express.js';
9
+ import connectBaseToExpress from './presets/base-express.js';
10
+
5
11
  // Delivery
6
- import './delivery/post.js';
7
- import './delivery/pick-mup.js';
8
12
  import './delivery/send-message.js';
9
13
  import './delivery/stores.js';
10
14
 
11
15
  // Payment
12
- import './payment/invoice.js';
13
16
  import './payment/invoice-prepaid.js';
14
17
  import './payment/paypal-checkout.js';
15
18
  import { datatransHandler } from './payment/datatrans-v2/index.js';
16
- import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay/index.js';
17
19
  import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap/index.js';
18
20
  import { stripeHandler } from './payment/stripe/index.js';
19
21
  import { postfinanceCheckoutHandler } from './payment/postfinance-checkout/index.js';
20
22
  import { configureSaferpayTransactionsModule, saferpayHandler } from './payment/saferpay/index.js';
21
23
  import { payrexxHandler } from './payment/payrexx/index.js';
22
24
 
23
- // Warehousing
24
- import './warehousing/store.js';
25
- import './warehousing/eth-minter.js';
26
-
27
- // Pricing
28
- import './pricing/free-payment.js';
29
- import './pricing/free-delivery.js';
30
- import './pricing/order-items.js';
31
- import './pricing/order-discount.js';
32
- import './pricing/order-delivery.js';
33
- import './pricing/order-payment.js';
34
- import './pricing/product-catalog-price.js';
35
- import './pricing/product-price-rateconversion.js';
36
- import './pricing/product-discount.js';
37
- import './pricing/product-swiss-tax.js';
38
- import './pricing/delivery-swiss-tax.js';
39
-
40
25
  // Filter & Search
41
26
  import './filters/strict-equal.js';
42
27
  import './filters/local-search.js';
43
28
 
44
- // Quotations
45
- import './quotations/manual.js';
46
-
47
- // Enrollments
48
- import './enrollments/licensed.js';
49
-
50
- // Event Queue
51
- import './events/node-event-emitter.js';
52
-
53
29
  // Workers
54
- import './worker/bulk-import.js';
55
- import './worker/zombie-killer.js';
56
- import './worker/message.js';
57
- import './worker/external.js';
58
- import './worker/http-request.js';
59
- import './worker/heartbeat.js';
60
- import './worker/email.js';
61
30
  import './worker/sms.js';
62
31
  import './worker/push-notification.js';
63
- import './worker/update-ecb-rates.js';
64
- import './worker/error-notifications.js';
65
- import './worker/update-coinbase-rates.js';
66
- import { configureExportToken } from './worker/export-token.js';
67
32
  import { configureGenerateOrderAutoscheduling } from './worker/enrollment-order-generator.js';
68
33
 
69
- // Asset Management
70
- import './files/gridfs/gridfs-adapter.js';
71
- import { gridfsHandler } from './files/gridfs/gridfs-webhook.js';
72
- import { configureGridFSFileUploadModule } from './files/gridfs/index.js';
73
-
74
- import './accounts/google-oauth.js';
75
- import './accounts/linkedin-oauth.js';
76
-
77
34
  const {
78
- CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay',
79
35
  STRIPE_WEBHOOK_PATH = '/payment/stripe',
80
36
  PAYREXX_WEBHOOK_PATH = '/payment/payrexx',
81
37
  PFCHECKOUT_WEBHOOK_PATH = '/payment/postfinance-checkout',
82
38
  DATATRANS_WEBHOOK_PATH = '/payment/datatrans/webhook',
83
39
  APPLE_IAP_WEBHOOK_PATH = '/payment/apple-iap',
84
- // MINIO_PUT_SERVER_PATH = '/minio',
85
- GRIDFS_PUT_SERVER_PATH = '/gridfs',
86
40
  SAFERPAY_WEBHOOK_PATH = '/payment/saferpay/webhook',
87
41
  } = process.env;
88
42
 
89
- // import './files/minio/minio-adapter';
90
- // import { minioHandler } from './files/minio/minio-webhook';
91
-
92
43
  export const defaultModules: Record<
93
44
  string,
94
45
  {
95
46
  configure: (params: ModuleInput<any>) => any;
96
47
  }
97
48
  > = {
49
+ ...baseModules,
50
+ ...cryptoModules,
98
51
  appleTransactions: {
99
52
  configure: configureAppleTransactionsModule,
100
53
  },
101
54
  saferpayTransactions: {
102
55
  configure: configureSaferpayTransactionsModule,
103
56
  },
104
- gridfsFileUploads: {
105
- configure: configureGridFSFileUploadModule,
106
- },
107
- cryptopay: {
108
- configure: configureCryptopayModule,
109
- },
110
57
  };
111
58
 
112
59
  export const connectDefaultPluginsToExpress4 = (
113
60
  app,
114
61
  { unchainedAPI }: { unchainedAPI: UnchainedCore },
115
62
  ) => {
116
- useMiddlewareWithCurrentContext(app, GRIDFS_PUT_SERVER_PATH, gridfsHandler);
63
+ connectBaseToExpress(app);
64
+ connectCryptoToExpress(app, unchainedAPI);
117
65
 
118
- useMiddlewareWithCurrentContext(app, CRYPTOPAY_WEBHOOK_PATH, express.json(), cryptopayHandler);
66
+ app.use(STRIPE_WEBHOOK_PATH, express.raw({ type: 'application/json' }), stripeHandler);
67
+ app.use(PFCHECKOUT_WEBHOOK_PATH, express.json(), postfinanceCheckoutHandler);
119
68
 
120
- useMiddlewareWithCurrentContext(
121
- app,
122
- STRIPE_WEBHOOK_PATH,
123
- express.raw({ type: 'application/json' }),
124
- stripeHandler,
125
- );
126
-
127
- useMiddlewareWithCurrentContext(
128
- app,
129
- PFCHECKOUT_WEBHOOK_PATH,
130
- express.json(),
131
- postfinanceCheckoutHandler,
132
- );
133
-
134
- useMiddlewareWithCurrentContext(
135
- app,
69
+ app.use(
136
70
  DATATRANS_WEBHOOK_PATH,
137
71
  express.text({
138
72
  type: 'application/json',
@@ -140,8 +74,7 @@ export const connectDefaultPluginsToExpress4 = (
140
74
  datatransHandler,
141
75
  );
142
76
 
143
- useMiddlewareWithCurrentContext(
144
- app,
77
+ app.use(
145
78
  APPLE_IAP_WEBHOOK_PATH,
146
79
  express.json({
147
80
  strict: false,
@@ -149,24 +82,8 @@ export const connectDefaultPluginsToExpress4 = (
149
82
  appleIAPHandler,
150
83
  );
151
84
 
152
- useMiddlewareWithCurrentContext(
153
- app,
154
- PAYREXX_WEBHOOK_PATH,
155
- express.json({ type: 'application/json' }),
156
- payrexxHandler,
157
- );
158
-
159
- useMiddlewareWithCurrentContext(app, SAFERPAY_WEBHOOK_PATH, saferpayHandler);
160
-
161
- // useMiddlewareWithCurrentContext(
162
- // app,
163
- // MINIO_PUT_SERVER_PATH,
164
- // express.json({
165
- // strict: false,
166
- // }),
167
- // minioHandler
168
- // );
85
+ app.use(PAYREXX_WEBHOOK_PATH, express.json({ type: 'application/json' }), payrexxHandler);
86
+ app.use(SAFERPAY_WEBHOOK_PATH, saferpayHandler);
169
87
 
170
- configureExportToken(unchainedAPI);
171
88
  configureGenerateOrderAutoscheduling();
172
89
  };
@@ -0,0 +1,7 @@
1
+ import { gridfsHandler } from '../files/gridfs/gridfs-webhook.js';
2
+
3
+ const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
4
+
5
+ export default (app) => {
6
+ app.use(GRIDFS_PUT_SERVER_PATH, gridfsHandler);
7
+ };
@@ -0,0 +1,56 @@
1
+ import { ModuleInput } from '@unchainedshop/core';
2
+
3
+ // Delivery
4
+ import '../delivery/post.js';
5
+
6
+ // Payment
7
+ import '../payment/invoice.js';
8
+
9
+ // Warehousing
10
+ import '../warehousing/store.js';
11
+
12
+ // Pricing
13
+ import '../pricing/free-payment.js';
14
+ import '../pricing/free-delivery.js';
15
+ import '../pricing/order-items.js';
16
+ import '../pricing/order-discount.js';
17
+ import '../pricing/order-delivery.js';
18
+ import '../pricing/order-payment.js';
19
+ import '../pricing/product-catalog-price.js';
20
+ import '../pricing/product-discount.js';
21
+
22
+ // Quotations
23
+ import '../quotations/manual.js';
24
+
25
+ // Enrollments
26
+ import '../enrollments/licensed.js';
27
+
28
+ // Event Queue
29
+ import '../events/node-event-emitter.js';
30
+
31
+ // Workers
32
+ import '../worker/bulk-import.js';
33
+ import '../worker/zombie-killer.js';
34
+ import '../worker/message.js';
35
+ import '../worker/external.js';
36
+ import '../worker/http-request.js';
37
+ import '../worker/heartbeat.js';
38
+ import '../worker/email.js';
39
+ import '../worker/error-notifications.js';
40
+
41
+ // Asset Management
42
+ import '../files/gridfs/gridfs-adapter.js';
43
+ import { configureGridFSFileUploadModule } from '../files/gridfs/index.js';
44
+
45
+ const modules: Record<
46
+ string,
47
+ {
48
+ configure: (params: ModuleInput<any>) => any;
49
+ }
50
+ > = {
51
+ gridfsFileUploads: {
52
+ configure: configureGridFSFileUploadModule,
53
+ },
54
+ };
55
+
56
+ export default modules;
@@ -0,0 +1,3 @@
1
+ import '../../delivery/pick-mup.js';
2
+ import '../../pricing/product-swiss-tax.js';
3
+ import '../../pricing/delivery-swiss-tax.js';
@@ -0,0 +1,12 @@
1
+ import { UnchainedCore } from '@unchainedshop/core';
2
+ import express from 'express';
3
+
4
+ import { cryptopayHandler } from '../payment/cryptopay/index.js';
5
+ import { configureExportToken } from '../worker/export-token.js';
6
+
7
+ const { CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay' } = process.env;
8
+
9
+ export default (app, unchainedAPI: UnchainedCore) => {
10
+ app.use(CRYPTOPAY_WEBHOOK_PATH, express.json(), cryptopayHandler);
11
+ configureExportToken(unchainedAPI);
12
+ };
@@ -0,0 +1,23 @@
1
+ import { ModuleInput } from '@unchainedshop/core';
2
+ import { configureCryptopayModule } from '../payment/cryptopay/index.js';
3
+
4
+ // Warehousing
5
+ import '../warehousing/eth-minter.js';
6
+
7
+ import '../pricing/product-price-rateconversion.js';
8
+ import '../worker/update-ecb-rates.js';
9
+ import '../worker/update-coinbase-rates.js';
10
+ import '../worker/export-token.js';
11
+
12
+ const modules: Record<
13
+ string,
14
+ {
15
+ configure: (params: ModuleInput<any>) => any;
16
+ }
17
+ > = {
18
+ cryptopay: {
19
+ configure: configureCryptopayModule,
20
+ },
21
+ };
22
+
23
+ export default modules;
@@ -1,11 +1,8 @@
1
1
  import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
2
- import {
3
- DeliveryPricingRowCategory,
4
- IDeliveryPricingAdapter,
5
- } from '@unchainedshop/types/delivery.pricing.js';
2
+ import { DeliveryPricingRowCategory, IDeliveryPricingAdapter } from '@unchainedshop/core-delivery';
6
3
 
7
- import { Order } from '@unchainedshop/types/orders.js';
8
- import { DeliveryProvider } from '@unchainedshop/types/delivery.js';
4
+ import { Order } from '@unchainedshop/core-orders';
5
+ import { DeliveryProvider } from '@unchainedshop/core-delivery';
9
6
  import { SwissTaxCategories } from './tax/ch.js';
10
7
 
11
8
  const getTaxRate = ({ order, provider }: { order?: Order; provider?: DeliveryProvider }) => {