@unchainedshop/plugins 1.1.3 → 1.1.4

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 (319) hide show
  1. package/lib/delivery/pick-mup.d.ts +1 -0
  2. package/lib/delivery/pick-mup.js +98 -0
  3. package/lib/delivery/pick-mup.js.map +1 -0
  4. package/lib/delivery/post.d.ts +1 -0
  5. package/lib/delivery/post.js +23 -0
  6. package/lib/delivery/post.js.map +1 -0
  7. package/lib/delivery/send-message.d.ts +1 -0
  8. package/lib/delivery/send-message.js +41 -0
  9. package/lib/delivery/send-message.js.map +1 -0
  10. package/lib/delivery/stores.d.ts +1 -0
  11. package/lib/delivery/stores.js +39 -0
  12. package/lib/delivery/stores.js.map +1 -0
  13. package/lib/enrollments/licensed.d.ts +1 -0
  14. package/lib/enrollments/licensed.js +40 -0
  15. package/lib/enrollments/licensed.js.map +1 -0
  16. package/lib/filters/local-search.d.ts +3 -0
  17. package/lib/filters/local-search.js +84 -0
  18. package/lib/filters/local-search.js.map +1 -0
  19. package/lib/filters/strict-equal.d.ts +1 -0
  20. package/lib/filters/strict-equal.js +25 -0
  21. package/lib/filters/strict-equal.js.map +1 -0
  22. package/lib/payment/apple-iap/adapter.d.ts +1 -0
  23. package/lib/payment/apple-iap/adapter.js +284 -0
  24. package/lib/payment/apple-iap/adapter.js.map +1 -0
  25. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +7 -0
  26. package/lib/payment/apple-iap/db/AppleTransactionsCollection.js +5 -0
  27. package/lib/payment/apple-iap/db/AppleTransactionsCollection.js.map +1 -0
  28. package/lib/payment/apple-iap/index.d.ts +2 -0
  29. package/lib/payment/apple-iap/index.js +3 -0
  30. package/lib/payment/apple-iap/index.js.map +1 -0
  31. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +9 -0
  32. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +18 -0
  33. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -0
  34. package/lib/payment/bity/adapter.d.ts +1 -0
  35. package/lib/payment/bity/adapter.js +316 -0
  36. package/lib/payment/bity/adapter.js.map +1 -0
  37. package/lib/payment/bity/db/BityCredentialsCollection.d.ts +11 -0
  38. package/lib/payment/bity/db/BityCredentialsCollection.js +5 -0
  39. package/lib/payment/bity/db/BityCredentialsCollection.js.map +1 -0
  40. package/lib/payment/bity/index.d.ts +2 -0
  41. package/lib/payment/bity/index.js +3 -0
  42. package/lib/payment/bity/index.js.map +1 -0
  43. package/lib/payment/bity/module/configureBityModule.d.ts +11 -0
  44. package/lib/payment/bity/module/configureBityModule.js +33 -0
  45. package/lib/payment/bity/module/configureBityModule.js.map +1 -0
  46. package/lib/payment/braintree.d.ts +1 -0
  47. package/lib/payment/braintree.js +129 -0
  48. package/lib/payment/braintree.js.map +1 -0
  49. package/lib/payment/cryptopay.d.ts +1 -0
  50. package/lib/payment/cryptopay.js +159 -0
  51. package/lib/payment/cryptopay.js.map +1 -0
  52. package/lib/payment/datatrans-v2/api/authorize.d.ts +2 -0
  53. package/lib/payment/datatrans-v2/api/authorize.js +12 -0
  54. package/lib/payment/datatrans-v2/api/authorize.js.map +1 -0
  55. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +2 -0
  56. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js +11 -0
  57. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js.map +1 -0
  58. package/lib/payment/datatrans-v2/api/cancel.d.ts +2 -0
  59. package/lib/payment/datatrans-v2/api/cancel.js +10 -0
  60. package/lib/payment/datatrans-v2/api/cancel.js.map +1 -0
  61. package/lib/payment/datatrans-v2/api/index.d.ts +19 -0
  62. package/lib/payment/datatrans-v2/api/index.js +24 -0
  63. package/lib/payment/datatrans-v2/api/index.js.map +1 -0
  64. package/lib/payment/datatrans-v2/api/init.d.ts +2 -0
  65. package/lib/payment/datatrans-v2/api/init.js +31 -0
  66. package/lib/payment/datatrans-v2/api/init.js.map +1 -0
  67. package/lib/payment/datatrans-v2/api/makeFetcher.d.ts +2 -0
  68. package/lib/payment/datatrans-v2/api/makeFetcher.js +41 -0
  69. package/lib/payment/datatrans-v2/api/makeFetcher.js.map +1 -0
  70. package/lib/payment/datatrans-v2/api/secureFields.d.ts +2 -0
  71. package/lib/payment/datatrans-v2/api/secureFields.js +14 -0
  72. package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -0
  73. package/lib/payment/datatrans-v2/api/settle.d.ts +2 -0
  74. package/lib/payment/datatrans-v2/api/settle.js +10 -0
  75. package/lib/payment/datatrans-v2/api/settle.js.map +1 -0
  76. package/lib/payment/datatrans-v2/api/status.d.ts +2 -0
  77. package/lib/payment/datatrans-v2/api/status.js +7 -0
  78. package/lib/payment/datatrans-v2/api/status.js.map +1 -0
  79. package/lib/payment/datatrans-v2/api/validate.d.ts +2 -0
  80. package/lib/payment/datatrans-v2/api/validate.js +10 -0
  81. package/lib/payment/datatrans-v2/api/validate.js.map +1 -0
  82. package/lib/payment/datatrans-v2/generateSignature.d.ts +10 -0
  83. package/lib/payment/datatrans-v2/generateSignature.js +19 -0
  84. package/lib/payment/datatrans-v2/generateSignature.js.map +1 -0
  85. package/lib/payment/datatrans-v2/getPaths.d.ts +9 -0
  86. package/lib/payment/datatrans-v2/getPaths.js +9 -0
  87. package/lib/payment/datatrans-v2/getPaths.js.map +1 -0
  88. package/lib/payment/datatrans-v2/index.d.ts +1 -0
  89. package/lib/payment/datatrans-v2/index.js +384 -0
  90. package/lib/payment/datatrans-v2/index.js.map +1 -0
  91. package/lib/payment/datatrans-v2/middleware.d.ts +1 -0
  92. package/lib/payment/datatrans-v2/middleware.js +111 -0
  93. package/lib/payment/datatrans-v2/middleware.js.map +1 -0
  94. package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +11 -0
  95. package/lib/payment/datatrans-v2/parseRegistrationData.js +26 -0
  96. package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -0
  97. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +7 -0
  98. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +10 -0
  99. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -0
  100. package/lib/payment/datatrans-v2/splitProperties.d.ts +8 -0
  101. package/lib/payment/datatrans-v2/splitProperties.js +58 -0
  102. package/lib/payment/datatrans-v2/splitProperties.js.map +1 -0
  103. package/lib/payment/invoice-prepaid.d.ts +1 -0
  104. package/lib/payment/invoice-prepaid.js +30 -0
  105. package/lib/payment/invoice-prepaid.js.map +1 -0
  106. package/lib/payment/invoice.d.ts +1 -0
  107. package/lib/payment/invoice.js +27 -0
  108. package/lib/payment/invoice.js.map +1 -0
  109. package/lib/payment/paypal-checkout.d.ts +1 -0
  110. package/lib/payment/paypal-checkout.js +82 -0
  111. package/lib/payment/paypal-checkout.js.map +1 -0
  112. package/lib/payment/postfinance-checkout/api.d.ts +11 -0
  113. package/lib/payment/postfinance-checkout/api.js +109 -0
  114. package/lib/payment/postfinance-checkout/api.js.map +1 -0
  115. package/lib/payment/postfinance-checkout/index.d.ts +1 -0
  116. package/lib/payment/postfinance-checkout/index.js +186 -0
  117. package/lib/payment/postfinance-checkout/index.js.map +1 -0
  118. package/lib/payment/postfinance-checkout/middleware.d.ts +1 -0
  119. package/lib/payment/postfinance-checkout/middleware.js +42 -0
  120. package/lib/payment/postfinance-checkout/middleware.js.map +1 -0
  121. package/lib/payment/postfinance-checkout/types.d.ts +23 -0
  122. package/lib/payment/postfinance-checkout/types.js +12 -0
  123. package/lib/payment/postfinance-checkout/types.js.map +1 -0
  124. package/lib/payment/postfinance-checkout/utils.d.ts +4 -0
  125. package/lib/payment/postfinance-checkout/utils.js +20 -0
  126. package/lib/payment/postfinance-checkout/utils.js.map +1 -0
  127. package/lib/payment/stripe.d.ts +1 -0
  128. package/lib/payment/stripe.js +214 -0
  129. package/lib/payment/stripe.js.map +1 -0
  130. package/lib/payment/worldline-saferpay/index.d.ts +1 -0
  131. package/lib/payment/worldline-saferpay/index.js +112 -0
  132. package/lib/payment/worldline-saferpay/index.js.map +1 -0
  133. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +14 -0
  134. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +29 -0
  135. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -0
  136. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.d.ts +9 -0
  137. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js +28 -0
  138. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js.map +1 -0
  139. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -0
  140. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +2 -0
  141. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -0
  142. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.d.ts +1 -0
  143. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js +2 -0
  144. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js.map +1 -0
  145. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +73 -0
  146. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js +2 -0
  147. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js.map +1 -0
  148. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +53 -0
  149. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js +2 -0
  150. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js.map +1 -0
  151. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.d.ts +13 -0
  152. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js +2 -0
  153. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js.map +1 -0
  154. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.d.ts +9 -0
  155. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js +2 -0
  156. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js.map +1 -0
  157. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.d.ts +5 -0
  158. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js +2 -0
  159. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js.map +1 -0
  160. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +13 -0
  161. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js +2 -0
  162. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js.map +1 -0
  163. package/lib/pricing/delivery-swiss-tax.d.ts +15 -0
  164. package/lib/pricing/delivery-swiss-tax.js +98 -0
  165. package/lib/pricing/delivery-swiss-tax.js.map +1 -0
  166. package/lib/pricing/discount-100-off.d.ts +1 -0
  167. package/lib/pricing/discount-100-off.js +34 -0
  168. package/lib/pricing/discount-100-off.js.map +1 -0
  169. package/lib/pricing/discount-half-price-manual.d.ts +1 -0
  170. package/lib/pricing/discount-half-price-manual.js +34 -0
  171. package/lib/pricing/discount-half-price-manual.js.map +1 -0
  172. package/lib/pricing/discount-half-price.d.ts +1 -0
  173. package/lib/pricing/discount-half-price.js +37 -0
  174. package/lib/pricing/discount-half-price.js.map +1 -0
  175. package/lib/pricing/free-delivery.d.ts +2 -0
  176. package/lib/pricing/free-delivery.js +26 -0
  177. package/lib/pricing/free-delivery.js.map +1 -0
  178. package/lib/pricing/free-payment.d.ts +2 -0
  179. package/lib/pricing/free-payment.js +26 -0
  180. package/lib/pricing/free-payment.js.map +1 -0
  181. package/lib/pricing/order-delivery.d.ts +1 -0
  182. package/lib/pricing/order-delivery.js +33 -0
  183. package/lib/pricing/order-delivery.js.map +1 -0
  184. package/lib/pricing/order-discount.d.ts +1 -0
  185. package/lib/pricing/order-discount.js +110 -0
  186. package/lib/pricing/order-discount.js.map +1 -0
  187. package/lib/pricing/order-items-discount.d.ts +1 -0
  188. package/lib/pricing/order-items-discount.js +88 -0
  189. package/lib/pricing/order-items-discount.js.map +1 -0
  190. package/lib/pricing/order-items.d.ts +1 -0
  191. package/lib/pricing/order-items.js +44 -0
  192. package/lib/pricing/order-items.js.map +1 -0
  193. package/lib/pricing/order-payment.d.ts +1 -0
  194. package/lib/pricing/order-payment.js +33 -0
  195. package/lib/pricing/order-payment.js.map +1 -0
  196. package/lib/pricing/product-catalog-price.d.ts +1 -0
  197. package/lib/pricing/product-catalog-price.js +37 -0
  198. package/lib/pricing/product-catalog-price.js.map +1 -0
  199. package/lib/pricing/product-discount.d.ts +1 -0
  200. package/lib/pricing/product-discount.js +55 -0
  201. package/lib/pricing/product-discount.js.map +1 -0
  202. package/lib/pricing/product-price-ECB-interbank-exchange.d.ts +1 -0
  203. package/lib/pricing/product-price-ECB-interbank-exchange.js +90 -0
  204. package/lib/pricing/product-price-ECB-interbank-exchange.js.map +1 -0
  205. package/lib/pricing/product-price-coinbase-exchange.d.ts +1 -0
  206. package/lib/pricing/product-price-coinbase-exchange.js +60 -0
  207. package/lib/pricing/product-price-coinbase-exchange.js.map +1 -0
  208. package/lib/pricing/product-price-cryptopay.d.ts +1 -0
  209. package/lib/pricing/product-price-cryptopay.js +21 -0
  210. package/lib/pricing/product-price-cryptopay.js.map +1 -0
  211. package/lib/pricing/product-price-rateconversion.d.ts +1 -0
  212. package/lib/pricing/product-price-rateconversion.js +51 -0
  213. package/lib/pricing/product-price-rateconversion.js.map +1 -0
  214. package/lib/pricing/product-price-round.d.ts +11 -0
  215. package/lib/pricing/product-price-round.js +54 -0
  216. package/lib/pricing/product-price-round.js.map +1 -0
  217. package/lib/pricing/product-swiss-tax.d.ts +13 -0
  218. package/lib/pricing/product-swiss-tax.js +102 -0
  219. package/lib/pricing/product-swiss-tax.js.map +1 -0
  220. package/lib/pricing/utils/cache.d.ts +9 -0
  221. package/lib/pricing/utils/cache.js +28 -0
  222. package/lib/pricing/utils/cache.js.map +1 -0
  223. package/lib/quotations/manual.d.ts +1 -0
  224. package/lib/quotations/manual.js +21 -0
  225. package/lib/quotations/manual.js.map +1 -0
  226. package/lib/warehousing/google-sheets.d.ts +1 -0
  227. package/lib/warehousing/google-sheets.js +153 -0
  228. package/lib/warehousing/google-sheets.js.map +1 -0
  229. package/lib/warehousing/store.d.ts +1 -0
  230. package/lib/warehousing/store.js +33 -0
  231. package/lib/warehousing/store.js.map +1 -0
  232. package/lib/worker/BulkImportWorker.js +3 -3
  233. package/lib/worker/BulkImportWorker.js.map +1 -1
  234. package/lib/worker/GenerateOrderWorker.js +1 -1
  235. package/lib/worker/GenerateOrderWorker.js.map +1 -1
  236. package/lib/worker/email.js +55 -4
  237. package/lib/worker/email.js.map +1 -1
  238. package/package.json +18 -2
  239. package/src/delivery/pick-mup.ts +119 -0
  240. package/src/delivery/post.ts +30 -0
  241. package/src/delivery/send-message.ts +54 -0
  242. package/src/delivery/stores.ts +49 -0
  243. package/src/enrollments/licensed.ts +49 -0
  244. package/src/filters/local-search.ts +105 -0
  245. package/src/filters/strict-equal.ts +31 -0
  246. package/src/payment/apple-iap/adapter.ts +390 -0
  247. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +13 -0
  248. package/src/payment/apple-iap/index.ts +3 -0
  249. package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +31 -0
  250. package/src/payment/bity/adapter.ts +417 -0
  251. package/src/payment/bity/db/BityCredentialsCollection.ts +17 -0
  252. package/src/payment/bity/index.ts +3 -0
  253. package/src/payment/bity/module/configureBityModule.ts +46 -0
  254. package/src/payment/braintree.ts +147 -0
  255. package/src/payment/cryptopay.ts +195 -0
  256. package/src/payment/datatrans-v2/api/authorize.ts +17 -0
  257. package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +20 -0
  258. package/src/payment/datatrans-v2/api/cancel.ts +13 -0
  259. package/src/payment/datatrans-v2/api/index.ts +24 -0
  260. package/src/payment/datatrans-v2/api/init.ts +40 -0
  261. package/src/payment/datatrans-v2/api/makeFetcher.ts +49 -0
  262. package/src/payment/datatrans-v2/api/secureFields.ts +19 -0
  263. package/src/payment/datatrans-v2/api/settle.ts +13 -0
  264. package/src/payment/datatrans-v2/api/status.ts +8 -0
  265. package/src/payment/datatrans-v2/api/types.d.ts +378 -0
  266. package/src/payment/datatrans-v2/api/validate.ts +13 -0
  267. package/src/payment/datatrans-v2/generateSignature.ts +24 -0
  268. package/src/payment/datatrans-v2/getPaths.ts +24 -0
  269. package/src/payment/datatrans-v2/index.ts +476 -0
  270. package/src/payment/datatrans-v2/middleware.ts +147 -0
  271. package/src/payment/datatrans-v2/parseRegistrationData.ts +32 -0
  272. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +16 -0
  273. package/src/payment/datatrans-v2/splitProperties.ts +63 -0
  274. package/src/payment/invoice-prepaid.ts +40 -0
  275. package/src/payment/invoice.ts +36 -0
  276. package/src/payment/paypal-checkout.ts +107 -0
  277. package/src/payment/postfinance-checkout/api.ts +142 -0
  278. package/src/payment/postfinance-checkout/index.ts +241 -0
  279. package/src/payment/postfinance-checkout/middleware.ts +54 -0
  280. package/src/payment/postfinance-checkout/types.ts +27 -0
  281. package/src/payment/postfinance-checkout/utils.ts +35 -0
  282. package/src/payment/stripe.ts +278 -0
  283. package/src/payment/worldline-saferpay/index.ts +140 -0
  284. package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +54 -0
  285. package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.ts +36 -0
  286. package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +8 -0
  287. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.ts +26 -0
  288. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +75 -0
  289. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +55 -0
  290. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Request.ts +14 -0
  291. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Response.ts +9 -0
  292. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.ts +6 -0
  293. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +15 -0
  294. package/src/pricing/delivery-swiss-tax.ts +115 -0
  295. package/src/pricing/discount-100-off.ts +44 -0
  296. package/src/pricing/discount-half-price-manual.ts +43 -0
  297. package/src/pricing/discount-half-price.ts +46 -0
  298. package/src/pricing/free-delivery.ts +31 -0
  299. package/src/pricing/free-payment.ts +32 -0
  300. package/src/pricing/order-delivery.ts +45 -0
  301. package/src/pricing/order-discount.ts +158 -0
  302. package/src/pricing/order-items-discount.ts +116 -0
  303. package/src/pricing/order-items.ts +61 -0
  304. package/src/pricing/order-payment.ts +46 -0
  305. package/src/pricing/product-catalog-price.ts +56 -0
  306. package/src/pricing/product-discount.ts +69 -0
  307. package/src/pricing/product-price-ECB-interbank-exchange.ts +108 -0
  308. package/src/pricing/product-price-coinbase-exchange.ts +82 -0
  309. package/src/pricing/product-price-cryptopay.ts +25 -0
  310. package/src/pricing/product-price-rateconversion.ts +73 -0
  311. package/src/pricing/product-price-round.ts +78 -0
  312. package/src/pricing/product-swiss-tax.ts +117 -0
  313. package/src/pricing/utils/cache.js +32 -0
  314. package/src/quotations/manual.ts +27 -0
  315. package/src/warehousing/google-sheets.ts +165 -0
  316. package/src/warehousing/store.ts +47 -0
  317. package/src/worker/BulkImportWorker.ts +3 -3
  318. package/src/worker/GenerateOrderWorker.ts +1 -1
  319. package/src/worker/email.ts +56 -4
@@ -0,0 +1,119 @@
1
+ import { DeliveryProviderType, IDeliveryAdapter } from '@unchainedshop/types/delivery';
2
+ import fetch from 'isomorphic-unfetch';
3
+ import { DeliveryAdapter, DeliveryDirector, DeliveryError } from '@unchainedshop/core-delivery';
4
+
5
+ const fetchPickMupLocations = async (key: string, idsFilter?: string) => {
6
+ // const pickMupUrl = `https://web-api.migros.ch/widgets/stores?key=${key}&verbosity=detail&limit=5000&aggregation_options%5Bempty_buckets%5D=true&filters%5Bmarkets%5D%5B0%5D%5B%5D=super&filters%5Bmarkets%5D%5B0%5D%5B%5D=mno&filters%5Bmarkets%5D%5B0%5D%5B%5D=voi&filters%5Bmarkets%5D%5B0%5D%5B%5D=mp&filters%5Bmarkets%5D%5B0%5D%5B%5D=out&filters%5Bmarkets%5D%5B0%5D%5B%5D=spx&filters%5Bmarkets%5D%5B0%5D%5B%5D=doi&filters%5Bmarkets%5D%5B0%5D%5B%5D=mec&filters%5Bmarkets%5D%5B0%5D%5B%5D=mica&filters%5Bmarkets%5D%5B0%5D%5B%5D=res&filters%5Bmarkets%5D%5B0%5D%5B%5D=flori&filters%5Bmarkets%5D%5B0%5D%5B%5D=gour&filters%5Bmarkets%5D%5B0%5D%5B%5D=alna&filters%5Bmarkets%5D%5B0%5D%5B%5D=cof&filters%5Bmarkets%5D%5B0%5D%5B%5D=chng&filters%5Bservices%5D%5Bsub_type%5D%5B%5D=pickmup&aggregation_groups%5B_custom%5D%5Bopen_on%5D%5Bnow%5D=20190923T11%3A45&aggregation_groups%5B_custom%5D%5Bopen_on%5D%5Bafter_1900%5D=20190923T19%3A01&aggregation_groups%5B_custom%5D%5Bopen_on%5D%5Bsundays%5D=sunday&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=super&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=voi&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=mp&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=mec&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=spx&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=doi&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=mica&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=out&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=flori&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=alna&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=res&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=gour&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=cof&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=res&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=gour&aggregation_groups%5Bmarkets%5D%5B_terms%5D%5B%5D=cof&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=market-service-mig_clean&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=market-service-mig_online&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=pickmup&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=post-service-point&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=subito-selfscanning&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=subito-selfcheckout&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=market-service-mig_bakery&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=counter-mez&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=counter-fisch&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=counter-kaes&aggregation_groups%5Bservices%5D%5Bsub_type%5D%5B_terms%5D%5B%5D=srv`;
7
+ const pickMupUrl = '';
8
+
9
+ const data = await fetch(`${pickMupUrl}${idsFilter ? `&ids[]=${idsFilter}` : ''}`, {
10
+ credentials: 'omit',
11
+ headers: {
12
+ accept: 'application/json, text/javascript, */*; q=0.01',
13
+ 'accept-language': 'de',
14
+ 'sec-fetch-mode': 'cors',
15
+ origin: 'https://filialen.migros.ch',
16
+ DNT: '1',
17
+ 'user-agent':
18
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
19
+ },
20
+ body: null,
21
+ method: 'GET',
22
+ });
23
+ const result = await data.json();
24
+ const { stores = [] } = result || {};
25
+ return stores.flatMap(({ markets = [], location = {}, id } = {}) => {
26
+ return markets.map(({ full_name: fullName }) => {
27
+ // eslint-disable-line
28
+ const {
29
+ geo: { lat, lon },
30
+ zip,
31
+ country,
32
+ address,
33
+ city,
34
+ address2,
35
+ } = location as any;
36
+ return {
37
+ _id: id,
38
+ name: fullName,
39
+ address: {
40
+ addressLine: address,
41
+ addressLine2: address2,
42
+ postalCode: zip,
43
+ countryCode: country,
44
+ city,
45
+ },
46
+ geoPoint: {
47
+ latitude: lat,
48
+ longitude: lon,
49
+ },
50
+ };
51
+ });
52
+ });
53
+ };
54
+
55
+ const PickMup: IDeliveryAdapter = {
56
+ ...DeliveryAdapter,
57
+
58
+ key: 'shop.unchained.pick-mup',
59
+ label: 'Migros Pick M Up',
60
+ version: '1.0',
61
+
62
+ initialConfiguration: [
63
+ {
64
+ key: 'key',
65
+ value: '',
66
+ },
67
+ ],
68
+
69
+ typeSupported: (type) => {
70
+ return type === DeliveryProviderType.PICKUP;
71
+ },
72
+
73
+ actions: (config, context) => {
74
+ const getKey = () => {
75
+ // Load https://filialen.migros.ch/de/filter:market_services-pickmup, open the browser developer tools and look for the sessionKey:
76
+ // <html lang="de" data-setup="{'env': 'production','sessionKey': '8ApUDaqeNER3Mest'}" class="no-js">
77
+ return config.reduce((current, item) => {
78
+ if (item.key === 'key') return item.value;
79
+ return current;
80
+ }, '');
81
+ };
82
+
83
+ return {
84
+ ...DeliveryAdapter.actions(config, context),
85
+
86
+ isActive: () => {
87
+ return true;
88
+ },
89
+
90
+ isAutoReleaseAllowed: () => {
91
+ return true;
92
+ },
93
+
94
+ configurationError: () => {
95
+ // eslint-disable-line
96
+ if (!getKey()) {
97
+ return DeliveryError.INCOMPLETE_CONFIGURATION;
98
+ }
99
+ return null;
100
+ },
101
+
102
+ pickUpLocationById: async (id) => {
103
+ const [foundLocation] = await fetchPickMupLocations(getKey(), id);
104
+ return foundLocation;
105
+ },
106
+
107
+ pickUpLocations: async () => {
108
+ const result = await fetchPickMupLocations(getKey());
109
+ return result;
110
+ },
111
+
112
+ send: async () => {
113
+ return false;
114
+ },
115
+ };
116
+ },
117
+ };
118
+
119
+ DeliveryDirector.registerAdapter(PickMup);
@@ -0,0 +1,30 @@
1
+ import { IDeliveryAdapter } from '@unchainedshop/types/delivery';
2
+ import { DeliveryAdapter, DeliveryDirector, DeliveryProviderType } from '@unchainedshop/core-delivery';
3
+
4
+ const Post: IDeliveryAdapter = {
5
+ ...DeliveryAdapter,
6
+
7
+ key: 'shop.unchained.post',
8
+ label: 'Post (Manual)',
9
+ version: '1.0',
10
+
11
+ typeSupported: (type) => {
12
+ return type === DeliveryProviderType.SHIPPING;
13
+ },
14
+
15
+ actions: (config, context) => {
16
+ return {
17
+ ...DeliveryAdapter.actions(config, context),
18
+
19
+ isActive: () => {
20
+ return true;
21
+ },
22
+
23
+ configurationError: () => {
24
+ return null;
25
+ },
26
+ };
27
+ },
28
+ };
29
+
30
+ DeliveryDirector.registerAdapter(Post);
@@ -0,0 +1,54 @@
1
+ import { IDeliveryAdapter } from '@unchainedshop/types/delivery';
2
+ import { DeliveryAdapter, DeliveryDirector, DeliveryProviderType } from '@unchainedshop/core-delivery';
3
+
4
+ const SendMessage: IDeliveryAdapter = {
5
+ ...DeliveryAdapter,
6
+
7
+ key: 'shop.unchained.delivery.send-message',
8
+ label: 'Forward Delivery via Messaging',
9
+ version: '1.0',
10
+
11
+ initialConfiguration: [
12
+ { key: 'from', value: '' },
13
+ { key: 'to', value: '' },
14
+ { key: 'cc', value: '' },
15
+ ],
16
+
17
+ typeSupported: (type) => {
18
+ return type === DeliveryProviderType.SHIPPING;
19
+ },
20
+
21
+ actions: (config, context) => {
22
+ return {
23
+ ...DeliveryAdapter.actions(config, context),
24
+
25
+ isActive: () => {
26
+ return true;
27
+ },
28
+
29
+ configurationError: () => {
30
+ return null;
31
+ },
32
+
33
+ send: async (transactionContext) => {
34
+ const { modules, order, userId } = context;
35
+
36
+ return modules.worker.addWork(
37
+ {
38
+ type: 'MESSAGE',
39
+ retries: 0,
40
+ input: {
41
+ template: 'DELIVERY',
42
+ orderId: order._id,
43
+ config,
44
+ transactionContext,
45
+ },
46
+ },
47
+ userId,
48
+ );
49
+ },
50
+ };
51
+ },
52
+ };
53
+
54
+ DeliveryDirector.registerAdapter(SendMessage);
@@ -0,0 +1,49 @@
1
+ import { IDeliveryAdapter } from '@unchainedshop/types/delivery';
2
+ import { DeliveryAdapter, DeliveryDirector, DeliveryProviderType } from '@unchainedshop/core-delivery';
3
+
4
+ const PickMup: IDeliveryAdapter = {
5
+ ...DeliveryAdapter,
6
+
7
+ key: 'shop.unchained.stores',
8
+ label: 'Manual Pickup',
9
+ version: '1.0',
10
+
11
+ typeSupported: (type) => {
12
+ return type === DeliveryProviderType.PICKUP;
13
+ },
14
+
15
+ actions: (config, context) => {
16
+ const getStores = () => {
17
+ return config.reduce((current, item) => {
18
+ if (item.key === 'stores') return JSON.parse(item.value);
19
+ return current;
20
+ }, []);
21
+ };
22
+
23
+ return {
24
+ ...DeliveryAdapter.actions(config, context),
25
+
26
+ isActive() {
27
+ return true;
28
+ },
29
+
30
+ isAutoReleaseAllowed() {
31
+ return false;
32
+ },
33
+
34
+ configurationError() {
35
+ return null;
36
+ },
37
+
38
+ pickUpLocationById: async (id) => {
39
+ return getStores().find((store) => store._id === id);
40
+ },
41
+
42
+ pickUpLocations: async () => {
43
+ return getStores();
44
+ },
45
+ };
46
+ },
47
+ };
48
+
49
+ DeliveryDirector.registerAdapter(PickMup);
@@ -0,0 +1,49 @@
1
+ import { IEnrollmentAdapter } from '@unchainedshop/types/enrollments';
2
+ import { EnrollmentDirector, EnrollmentAdapter } from '@unchainedshop/core-enrollments';
3
+
4
+ const rangeMatcher = (date = new Date()) => {
5
+ const timestamp = date.getTime();
6
+ return ({ start, end }) => {
7
+ const startTimestamp = new Date(start).getTime();
8
+ const endTimestamp = new Date(end).getTime();
9
+ return startTimestamp <= timestamp && endTimestamp >= timestamp;
10
+ };
11
+ };
12
+
13
+ const LicensedEnrollments: IEnrollmentAdapter = {
14
+ ...EnrollmentAdapter,
15
+
16
+ key: 'shop.unchained.enrollments.licensed',
17
+ version: '1.0',
18
+ label: 'Simple Licensed Enrollments',
19
+
20
+ isActivatedFor: (productPlan) => {
21
+ return productPlan?.usageCalculationType === 'LICENSED';
22
+ },
23
+
24
+ actions: (params) => {
25
+ return {
26
+ ...EnrollmentAdapter.actions(params),
27
+
28
+ isValidForActivation: async () => {
29
+ const periods = params.enrollment?.periods || [];
30
+ return periods.findIndex(rangeMatcher()) !== -1;
31
+ },
32
+
33
+ isOverdue: async () => {
34
+ return false;
35
+ },
36
+
37
+ configurationForOrder: async (context) => {
38
+ const { period } = context;
39
+ const beginningOfPeriod = period.start.getTime() <= new Date().getTime();
40
+ if (beginningOfPeriod) {
41
+ return context;
42
+ }
43
+ return null;
44
+ },
45
+ };
46
+ },
47
+ };
48
+
49
+ EnrollmentDirector.registerAdapter(LicensedEnrollments);
@@ -0,0 +1,105 @@
1
+ import { FilterDirector, FilterAdapter } from '@unchainedshop/core-filters';
2
+ import { IFilterAdapter } from '@unchainedshop/types/filters';
3
+ import { Query } from '@unchainedshop/types/common';
4
+
5
+ const { AMAZON_DOCUMENTDB_COMPAT_MODE } = process.env;
6
+
7
+ const LocalSearch: IFilterAdapter = {
8
+ ...FilterAdapter,
9
+
10
+ key: 'shop.unchained.filters.local-search',
11
+ label: 'Simple Fulltext search with MongoDB',
12
+ version: '0.1',
13
+ orderIndex: 1,
14
+
15
+ actions: (params) => {
16
+ return {
17
+ ...FilterAdapter.actions(params),
18
+
19
+ searchProducts: async ({ productIds }) => {
20
+ // Search Products
21
+ const { queryString } = params.searchQuery;
22
+
23
+ if (!queryString) return productIds;
24
+
25
+ const selector: Query = AMAZON_DOCUMENTDB_COMPAT_MODE
26
+ ? {
27
+ $or: [
28
+ { title: { $regex: `${queryString}`, $options: 'im' } },
29
+ { subtitle: { $regex: `${queryString}`, $options: 'im' } },
30
+ { vendor: { $regex: `${queryString}`, $options: 'im' } },
31
+ { brand: { $regex: `${queryString}`, $options: 'im' } },
32
+ { description: { $regex: `${queryString}`, $options: 'im' } },
33
+ { labels: { $regex: `${queryString}`, $options: 'im' } },
34
+ ],
35
+ }
36
+ : {
37
+ $text: { $search: queryString },
38
+ };
39
+
40
+ if (productIds) {
41
+ selector.productId = { $in: [...new Set(productIds)] };
42
+ }
43
+
44
+ const products = await params.modules.products.texts.findTexts(selector, {
45
+ projection: {
46
+ productId: 1,
47
+ },
48
+ });
49
+
50
+ return products.map(({ productId }) => productId);
51
+ },
52
+
53
+ // eslint-disable-next-line
54
+ searchAssortments: async ({ assortmentIds }) => {
55
+ const { queryString } = params.searchQuery;
56
+
57
+ if (!queryString) {
58
+ return assortmentIds;
59
+ }
60
+
61
+ const selector: Query = {
62
+ $text: { $search: queryString },
63
+ };
64
+
65
+ if (assortmentIds) {
66
+ selector.assortmentId = { $in: assortmentIds };
67
+ }
68
+
69
+ const assortments = await params.modules.assortments.texts.findTexts(selector, {
70
+ projection: {
71
+ assortmentId: 1,
72
+ },
73
+ });
74
+
75
+ return assortments.map(({ assortmentId }) => assortmentId);
76
+ },
77
+
78
+ async transformFilterSelector(last) {
79
+ const { query = {} } = params.searchQuery;
80
+ const { queryString, filterIds, includeInactive } = query;
81
+
82
+ if (queryString && !filterIds) {
83
+ // Global search without assortment scope:
84
+ // Return all filters
85
+ const selector = { ...last };
86
+ if (selector?.key) {
87
+ // Do not restrict to keys
88
+ delete selector.key;
89
+ }
90
+ if (!includeInactive) {
91
+ // Include only active filters
92
+ selector.isActive = true;
93
+ }
94
+ return selector;
95
+ }
96
+
97
+ return last;
98
+ },
99
+ };
100
+ },
101
+ };
102
+
103
+ export default LocalSearch;
104
+
105
+ FilterDirector.registerAdapter(LocalSearch);
@@ -0,0 +1,31 @@
1
+ import { IFilterAdapter } from '@unchainedshop/types/filters';
2
+ import { FilterDirector, FilterAdapter } from '@unchainedshop/core-filters';
3
+
4
+ const StrictQualFilter: IFilterAdapter = {
5
+ ...FilterAdapter,
6
+
7
+ key: 'shop.unchained.filters.strict-qual',
8
+ label: 'Simple Strict Equal DB Filter',
9
+ version: '0.1',
10
+ orderIndex: 0,
11
+
12
+ actions: (params) => {
13
+ return {
14
+ ...FilterAdapter.actions(params),
15
+
16
+ transformProductSelector: async (lastSelector, options) => {
17
+ const { key, value } = options || {};
18
+
19
+ if (key) {
20
+ return {
21
+ ...lastSelector,
22
+ [key]: value !== undefined ? value : { $exists: true },
23
+ };
24
+ }
25
+ return lastSelector;
26
+ },
27
+ };
28
+ },
29
+ };
30
+
31
+ FilterDirector.registerAdapter(StrictQualFilter);