@unchainedshop/api 2.0.0-beta7 → 2.0.0-beta9

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 (565) hide show
  1. package/jest.config.js +9 -0
  2. package/lib/acl.d.ts +2 -0
  3. package/lib/acl.js +2 -2
  4. package/lib/acl.js.map +1 -1
  5. package/lib/api-index.d.ts +4 -6
  6. package/lib/api-index.js +5 -13
  7. package/lib/api-index.js.map +1 -1
  8. package/lib/context.d.ts +0 -1
  9. package/lib/context.js +0 -12
  10. package/lib/context.js.map +1 -1
  11. package/lib/createGraphQLServer.d.ts +1 -1
  12. package/lib/createGraphQLServer.js +13 -50
  13. package/lib/createGraphQLServer.js.map +1 -1
  14. package/lib/errors.d.ts +20 -0
  15. package/lib/errors.js +20 -0
  16. package/lib/errors.js.map +1 -1
  17. package/lib/express/createApolloMiddleware.d.ts +4 -0
  18. package/lib/express/createApolloMiddleware.js +34 -0
  19. package/lib/express/createApolloMiddleware.js.map +1 -0
  20. package/lib/express/createBulkImportMiddleware.d.ts +2 -0
  21. package/lib/express/createBulkImportMiddleware.js +79 -0
  22. package/lib/express/createBulkImportMiddleware.js.map +1 -0
  23. package/lib/express/createERCMetadataMiddleware.d.ts +3 -0
  24. package/lib/express/createERCMetadataMiddleware.js +57 -0
  25. package/lib/express/createERCMetadataMiddleware.js.map +1 -0
  26. package/lib/express/createSingleSignOnMiddleware.d.ts +6 -0
  27. package/lib/express/createSingleSignOnMiddleware.js +71 -0
  28. package/lib/express/createSingleSignOnMiddleware.js.map +1 -0
  29. package/lib/express/index.d.ts +6 -0
  30. package/lib/express/index.js +27 -0
  31. package/lib/express/index.js.map +1 -0
  32. package/lib/loaders/index.js +5 -9
  33. package/lib/loaders/index.js.map +1 -1
  34. package/lib/resolvers/mutations/accounts/changePassword.d.ts +0 -2
  35. package/lib/resolvers/mutations/accounts/changePassword.js +14 -3
  36. package/lib/resolvers/mutations/accounts/changePassword.js.map +1 -1
  37. package/lib/resolvers/mutations/accounts/createUser.js +19 -5
  38. package/lib/resolvers/mutations/accounts/createUser.js.map +1 -1
  39. package/lib/resolvers/mutations/accounts/disableTOTP.js +15 -2
  40. package/lib/resolvers/mutations/accounts/disableTOTP.js.map +1 -1
  41. package/lib/resolvers/mutations/accounts/enableTOTP.js +12 -1
  42. package/lib/resolvers/mutations/accounts/enableTOTP.js.map +1 -1
  43. package/lib/resolvers/mutations/accounts/enrollUser.js +18 -5
  44. package/lib/resolvers/mutations/accounts/enrollUser.js.map +1 -1
  45. package/lib/resolvers/mutations/accounts/forgotPassword.js +11 -1
  46. package/lib/resolvers/mutations/accounts/forgotPassword.js.map +1 -1
  47. package/lib/resolvers/mutations/accounts/impersonate.js +1 -1
  48. package/lib/resolvers/mutations/accounts/impersonate.js.map +1 -1
  49. package/lib/resolvers/mutations/accounts/loginWithPassword.d.ts +0 -1
  50. package/lib/resolvers/mutations/accounts/loginWithPassword.js +22 -4
  51. package/lib/resolvers/mutations/accounts/loginWithPassword.js.map +1 -1
  52. package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js +13 -1
  53. package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js.map +1 -1
  54. package/lib/resolvers/mutations/accounts/logout.d.ts +1 -1
  55. package/lib/resolvers/mutations/accounts/logout.js +6 -2
  56. package/lib/resolvers/mutations/accounts/logout.js.map +1 -1
  57. package/lib/resolvers/mutations/accounts/logoutAllSessions.js +4 -1
  58. package/lib/resolvers/mutations/accounts/logoutAllSessions.js.map +1 -1
  59. package/lib/resolvers/mutations/accounts/resetPassword.d.ts +0 -1
  60. package/lib/resolvers/mutations/accounts/resetPassword.js +18 -3
  61. package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
  62. package/lib/resolvers/mutations/accounts/setPassword.d.ts +0 -1
  63. package/lib/resolvers/mutations/accounts/setPassword.js +1 -1
  64. package/lib/resolvers/mutations/accounts/setPassword.js.map +1 -1
  65. package/lib/resolvers/mutations/assortments/addAssortmentFilter.js +1 -2
  66. package/lib/resolvers/mutations/assortments/addAssortmentFilter.js.map +1 -1
  67. package/lib/resolvers/mutations/assortments/addAssortmentLink.js +16 -9
  68. package/lib/resolvers/mutations/assortments/addAssortmentLink.js.map +1 -1
  69. package/lib/resolvers/mutations/assortments/addAssortmentMedia.js +2 -3
  70. package/lib/resolvers/mutations/assortments/addAssortmentMedia.js.map +1 -1
  71. package/lib/resolvers/mutations/assortments/addAssortmentProduct.js +1 -2
  72. package/lib/resolvers/mutations/assortments/addAssortmentProduct.js.map +1 -1
  73. package/lib/resolvers/mutations/assortments/createAssortment.js +1 -2
  74. package/lib/resolvers/mutations/assortments/createAssortment.js.map +1 -1
  75. package/lib/resolvers/mutations/assortments/prepareAssortmentMediaUpload.js +0 -1
  76. package/lib/resolvers/mutations/assortments/prepareAssortmentMediaUpload.js.map +1 -1
  77. package/lib/resolvers/mutations/assortments/removeAssortment.js +1 -1
  78. package/lib/resolvers/mutations/assortments/removeAssortment.js.map +1 -1
  79. package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js +1 -1
  80. package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js.map +1 -1
  81. package/lib/resolvers/mutations/assortments/removeAssortmentLink.js +1 -1
  82. package/lib/resolvers/mutations/assortments/removeAssortmentLink.js.map +1 -1
  83. package/lib/resolvers/mutations/assortments/removeAssortmentMedia.js +2 -2
  84. package/lib/resolvers/mutations/assortments/removeAssortmentMedia.js.map +1 -1
  85. package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js +1 -1
  86. package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js.map +1 -1
  87. package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.js +1 -1
  88. package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.js.map +1 -1
  89. package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.js +1 -1
  90. package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.js.map +1 -1
  91. package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.js +1 -1
  92. package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.js.map +1 -1
  93. package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.js +1 -1
  94. package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.js.map +1 -1
  95. package/lib/resolvers/mutations/assortments/setBaseAssortment.js +1 -1
  96. package/lib/resolvers/mutations/assortments/setBaseAssortment.js.map +1 -1
  97. package/lib/resolvers/mutations/assortments/updateAssortment.js +1 -1
  98. package/lib/resolvers/mutations/assortments/updateAssortment.js.map +1 -1
  99. package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.js +1 -1
  100. package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.js.map +1 -1
  101. package/lib/resolvers/mutations/assortments/updateAssortmentTexts.js +1 -1
  102. package/lib/resolvers/mutations/assortments/updateAssortmentTexts.js.map +1 -1
  103. package/lib/resolvers/mutations/bookmarks/bookmark.js +2 -2
  104. package/lib/resolvers/mutations/bookmarks/bookmark.js.map +1 -1
  105. package/lib/resolvers/mutations/bookmarks/createBookmark.js +1 -1
  106. package/lib/resolvers/mutations/bookmarks/createBookmark.js.map +1 -1
  107. package/lib/resolvers/mutations/countries/createCountry.js +1 -2
  108. package/lib/resolvers/mutations/countries/createCountry.js.map +1 -1
  109. package/lib/resolvers/mutations/countries/removeCountry.js +1 -1
  110. package/lib/resolvers/mutations/countries/removeCountry.js.map +1 -1
  111. package/lib/resolvers/mutations/countries/updateCountry.js +1 -1
  112. package/lib/resolvers/mutations/countries/updateCountry.js.map +1 -1
  113. package/lib/resolvers/mutations/currencies/createCurrency.js +1 -2
  114. package/lib/resolvers/mutations/currencies/createCurrency.js.map +1 -1
  115. package/lib/resolvers/mutations/currencies/removeCurrency.js +1 -1
  116. package/lib/resolvers/mutations/currencies/removeCurrency.js.map +1 -1
  117. package/lib/resolvers/mutations/currencies/updateCurrency.js +1 -1
  118. package/lib/resolvers/mutations/currencies/updateCurrency.js.map +1 -1
  119. package/lib/resolvers/mutations/delivery/createDeliveryProvider.js +1 -2
  120. package/lib/resolvers/mutations/delivery/createDeliveryProvider.js.map +1 -1
  121. package/lib/resolvers/mutations/delivery/removeDeliveryProvider.js +1 -1
  122. package/lib/resolvers/mutations/delivery/removeDeliveryProvider.js.map +1 -1
  123. package/lib/resolvers/mutations/delivery/updateDeliveryProvider.js +1 -1
  124. package/lib/resolvers/mutations/delivery/updateDeliveryProvider.js.map +1 -1
  125. package/lib/resolvers/mutations/enrollments/activateEnrollment.js +1 -1
  126. package/lib/resolvers/mutations/enrollments/activateEnrollment.js.map +1 -1
  127. package/lib/resolvers/mutations/enrollments/terminateEnrollment.js +1 -1
  128. package/lib/resolvers/mutations/enrollments/terminateEnrollment.js.map +1 -1
  129. package/lib/resolvers/mutations/enrollments/updateEnrollment.d.ts +1 -1
  130. package/lib/resolvers/mutations/enrollments/updateEnrollment.js +5 -5
  131. package/lib/resolvers/mutations/enrollments/updateEnrollment.js.map +1 -1
  132. package/lib/resolvers/mutations/filters/createFilter.js +1 -2
  133. package/lib/resolvers/mutations/filters/createFilter.js.map +1 -1
  134. package/lib/resolvers/mutations/filters/createFilterOption.js +1 -1
  135. package/lib/resolvers/mutations/filters/createFilterOption.js.map +1 -1
  136. package/lib/resolvers/mutations/filters/removeFilter.d.ts +1 -1
  137. package/lib/resolvers/mutations/filters/removeFilter.js +4 -4
  138. package/lib/resolvers/mutations/filters/removeFilter.js.map +1 -1
  139. package/lib/resolvers/mutations/filters/updateFilter.js +1 -1
  140. package/lib/resolvers/mutations/filters/updateFilter.js.map +1 -1
  141. package/lib/resolvers/mutations/filters/updateFilterTexts.js +1 -1
  142. package/lib/resolvers/mutations/filters/updateFilterTexts.js.map +1 -1
  143. package/lib/resolvers/mutations/index.d.ts +2 -1
  144. package/lib/resolvers/mutations/index.js +2 -0
  145. package/lib/resolvers/mutations/index.js.map +1 -1
  146. package/lib/resolvers/mutations/languages/createLanguage.js +1 -2
  147. package/lib/resolvers/mutations/languages/createLanguage.js.map +1 -1
  148. package/lib/resolvers/mutations/languages/removeLanguage.js +1 -1
  149. package/lib/resolvers/mutations/languages/removeLanguage.js.map +1 -1
  150. package/lib/resolvers/mutations/languages/updateLanguage.js +1 -1
  151. package/lib/resolvers/mutations/languages/updateLanguage.js.map +1 -1
  152. package/lib/resolvers/mutations/orders/createCart.js +1 -1
  153. package/lib/resolvers/mutations/orders/createCart.js.map +1 -1
  154. package/lib/resolvers/mutations/orders/payOrder.js +1 -1
  155. package/lib/resolvers/mutations/orders/payOrder.js.map +1 -1
  156. package/lib/resolvers/mutations/orders/removeOrder.js +1 -1
  157. package/lib/resolvers/mutations/orders/removeOrder.js.map +1 -1
  158. package/lib/resolvers/mutations/pageView.d.ts +1 -1
  159. package/lib/resolvers/mutations/pageView.js +2 -2
  160. package/lib/resolvers/mutations/pageView.js.map +1 -1
  161. package/lib/resolvers/mutations/payment/createPaymentProvider.js +1 -2
  162. package/lib/resolvers/mutations/payment/createPaymentProvider.js.map +1 -1
  163. package/lib/resolvers/mutations/payment/registerPaymentCredentials.js +2 -2
  164. package/lib/resolvers/mutations/payment/registerPaymentCredentials.js.map +1 -1
  165. package/lib/resolvers/mutations/payment/removePaymentProvider.js +1 -1
  166. package/lib/resolvers/mutations/payment/removePaymentProvider.js.map +1 -1
  167. package/lib/resolvers/mutations/payment/updatePaymentProvider.js +1 -1
  168. package/lib/resolvers/mutations/payment/updatePaymentProvider.js.map +1 -1
  169. package/lib/resolvers/mutations/products/addProductAssignment.js +1 -1
  170. package/lib/resolvers/mutations/products/addProductAssignment.js.map +1 -1
  171. package/lib/resolvers/mutations/products/addProductMedia.js +1 -2
  172. package/lib/resolvers/mutations/products/addProductMedia.js.map +1 -1
  173. package/lib/resolvers/mutations/products/addProductReviewVote.js +1 -1
  174. package/lib/resolvers/mutations/products/addProductReviewVote.js.map +1 -1
  175. package/lib/resolvers/mutations/products/createProduct.js +1 -2
  176. package/lib/resolvers/mutations/products/createProduct.js.map +1 -1
  177. package/lib/resolvers/mutations/products/createProductBundleItem.js +1 -1
  178. package/lib/resolvers/mutations/products/createProductBundleItem.js.map +1 -1
  179. package/lib/resolvers/mutations/products/createProductReview.js +1 -1
  180. package/lib/resolvers/mutations/products/createProductReview.js.map +1 -1
  181. package/lib/resolvers/mutations/products/createProductVariation.js +1 -2
  182. package/lib/resolvers/mutations/products/createProductVariation.js.map +1 -1
  183. package/lib/resolvers/mutations/products/createProductVariationOption.js +4 -1
  184. package/lib/resolvers/mutations/products/createProductVariationOption.js.map +1 -1
  185. package/lib/resolvers/mutations/products/prepareProductMediaUpload.js +0 -1
  186. package/lib/resolvers/mutations/products/prepareProductMediaUpload.js.map +1 -1
  187. package/lib/resolvers/mutations/products/publishProduct.js +1 -1
  188. package/lib/resolvers/mutations/products/publishProduct.js.map +1 -1
  189. package/lib/resolvers/mutations/products/removeBundleItem.js +2 -2
  190. package/lib/resolvers/mutations/products/removeBundleItem.js.map +1 -1
  191. package/lib/resolvers/mutations/products/removeProduct.d.ts +1 -1
  192. package/lib/resolvers/mutations/products/removeProduct.js +17 -8
  193. package/lib/resolvers/mutations/products/removeProduct.js.map +1 -1
  194. package/lib/resolvers/mutations/products/removeProductAssignment.js +1 -1
  195. package/lib/resolvers/mutations/products/removeProductAssignment.js.map +1 -1
  196. package/lib/resolvers/mutations/products/removeProductMedia.js +2 -2
  197. package/lib/resolvers/mutations/products/removeProductMedia.js.map +1 -1
  198. package/lib/resolvers/mutations/products/removeProductReview.js +1 -1
  199. package/lib/resolvers/mutations/products/removeProductReview.js.map +1 -1
  200. package/lib/resolvers/mutations/products/removeProductReviewVote.js +1 -1
  201. package/lib/resolvers/mutations/products/removeProductReviewVote.js.map +1 -1
  202. package/lib/resolvers/mutations/products/removeProductVariation.js +1 -1
  203. package/lib/resolvers/mutations/products/removeProductVariation.js.map +1 -1
  204. package/lib/resolvers/mutations/products/removeProductVariationOption.js +1 -1
  205. package/lib/resolvers/mutations/products/removeProductVariationOption.js.map +1 -1
  206. package/lib/resolvers/mutations/products/reorderProductMedia.js +1 -1
  207. package/lib/resolvers/mutations/products/reorderProductMedia.js.map +1 -1
  208. package/lib/resolvers/mutations/products/unpublishProduct.js +1 -1
  209. package/lib/resolvers/mutations/products/unpublishProduct.js.map +1 -1
  210. package/lib/resolvers/mutations/products/updateProduct.js +1 -1
  211. package/lib/resolvers/mutations/products/updateProduct.js.map +1 -1
  212. package/lib/resolvers/mutations/products/updateProductCommerce.js +1 -1
  213. package/lib/resolvers/mutations/products/updateProductCommerce.js.map +1 -1
  214. package/lib/resolvers/mutations/products/updateProductMediaTexts.js +1 -1
  215. package/lib/resolvers/mutations/products/updateProductMediaTexts.js.map +1 -1
  216. package/lib/resolvers/mutations/products/updateProductPlan.js +1 -1
  217. package/lib/resolvers/mutations/products/updateProductPlan.js.map +1 -1
  218. package/lib/resolvers/mutations/products/updateProductReview.js +1 -1
  219. package/lib/resolvers/mutations/products/updateProductReview.js.map +1 -1
  220. package/lib/resolvers/mutations/products/updateProductSupply.js +1 -1
  221. package/lib/resolvers/mutations/products/updateProductSupply.js.map +1 -1
  222. package/lib/resolvers/mutations/products/updateProductTexts.js +1 -1
  223. package/lib/resolvers/mutations/products/updateProductTexts.js.map +1 -1
  224. package/lib/resolvers/mutations/products/updateProductTokenization.js +1 -1
  225. package/lib/resolvers/mutations/products/updateProductTokenization.js.map +1 -1
  226. package/lib/resolvers/mutations/products/updateProductVariationTexts.js +1 -1
  227. package/lib/resolvers/mutations/products/updateProductVariationTexts.js.map +1 -1
  228. package/lib/resolvers/mutations/products/updateProductWarehousing.js +1 -1
  229. package/lib/resolvers/mutations/products/updateProductWarehousing.js.map +1 -1
  230. package/lib/resolvers/mutations/users/prepareUserAvatarUpload.js +0 -1
  231. package/lib/resolvers/mutations/users/prepareUserAvatarUpload.js.map +1 -1
  232. package/lib/resolvers/mutations/users/removeUser.d.ts +4 -0
  233. package/lib/resolvers/mutations/users/removeUser.js +11 -0
  234. package/lib/resolvers/mutations/users/removeUser.js.map +1 -0
  235. package/lib/resolvers/mutations/users/setRoles.js +1 -1
  236. package/lib/resolvers/mutations/users/setRoles.js.map +1 -1
  237. package/lib/resolvers/mutations/users/setUserTags.js +1 -1
  238. package/lib/resolvers/mutations/users/setUserTags.js.map +1 -1
  239. package/lib/resolvers/mutations/users/updateUserAvatar.js +1 -2
  240. package/lib/resolvers/mutations/users/updateUserAvatar.js.map +1 -1
  241. package/lib/resolvers/mutations/users/updateUserProfile.js +1 -1
  242. package/lib/resolvers/mutations/users/updateUserProfile.js.map +1 -1
  243. package/lib/resolvers/mutations/utils/getOrderCart.js +1 -1
  244. package/lib/resolvers/mutations/utils/getOrderCart.js.map +1 -1
  245. package/lib/resolvers/mutations/warehousing/createWarehousingProvider.js +1 -2
  246. package/lib/resolvers/mutations/warehousing/createWarehousingProvider.js.map +1 -1
  247. package/lib/resolvers/mutations/warehousing/removeWarehousingProvider.js +1 -1
  248. package/lib/resolvers/mutations/warehousing/removeWarehousingProvider.js.map +1 -1
  249. package/lib/resolvers/mutations/warehousing/updateWarehousingProvider.js +1 -1
  250. package/lib/resolvers/mutations/warehousing/updateWarehousingProvider.js.map +1 -1
  251. package/lib/resolvers/mutations/worker/addWork.js +1 -1
  252. package/lib/resolvers/mutations/worker/addWork.js.map +1 -1
  253. package/lib/resolvers/mutations/worker/finishWork.js +1 -1
  254. package/lib/resolvers/mutations/worker/finishWork.js.map +1 -1
  255. package/lib/resolvers/mutations/worker/removeWork.js +1 -1
  256. package/lib/resolvers/mutations/worker/removeWork.js.map +1 -1
  257. package/lib/resolvers/queries/products/productCatalogPrices.js +0 -1
  258. package/lib/resolvers/queries/products/productCatalogPrices.js.map +1 -1
  259. package/lib/resolvers/queries/users/users.d.ts +2 -1
  260. package/lib/resolvers/queries/users/users.js.map +1 -1
  261. package/lib/resolvers/queries/worker/workQueue.d.ts +1 -1
  262. package/lib/resolvers/queries/worker/workQueue.js +1 -1
  263. package/lib/resolvers/queries/worker/workQueue.js.map +1 -1
  264. package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +2 -2
  265. package/lib/resolvers/type/assortment/assortment-filter-types.js +0 -1
  266. package/lib/resolvers/type/assortment/assortment-filter-types.js.map +1 -1
  267. package/lib/resolvers/type/assortment/assortment-link-types.d.ts +2 -2
  268. package/lib/resolvers/type/assortment/assortment-link-types.js +0 -2
  269. package/lib/resolvers/type/assortment/assortment-link-types.js.map +1 -1
  270. package/lib/resolvers/type/assortment/assortment-media-types.d.ts +1 -1
  271. package/lib/resolvers/type/assortment/assortment-media-types.js +2 -0
  272. package/lib/resolvers/type/assortment/assortment-media-types.js.map +1 -1
  273. package/lib/resolvers/type/assortment/assortment-path-link-types.d.ts +1 -4
  274. package/lib/resolvers/type/assortment/assortment-path-link-types.js +1 -7
  275. package/lib/resolvers/type/assortment/assortment-path-link-types.js.map +1 -1
  276. package/lib/resolvers/type/assortment/assortment-product-types.d.ts +2 -2
  277. package/lib/resolvers/type/assortment/assortment-product-types.js +0 -2
  278. package/lib/resolvers/type/assortment/assortment-product-types.js.map +1 -1
  279. package/lib/resolvers/type/assortment/assortment-types.d.ts +1 -1
  280. package/lib/resolvers/type/assortment/assortment-types.js +8 -4
  281. package/lib/resolvers/type/assortment/assortment-types.js.map +1 -1
  282. package/lib/resolvers/type/bookmark-types.d.ts +1 -1
  283. package/lib/resolvers/type/bookmark-types.js +0 -1
  284. package/lib/resolvers/type/bookmark-types.js.map +1 -1
  285. package/lib/resolvers/type/country-types.d.ts +1 -1
  286. package/lib/resolvers/type/delivery-provider-types.d.ts +1 -1
  287. package/lib/resolvers/type/enrollment/enrollment-delivery-types.d.ts +2 -2
  288. package/lib/resolvers/type/enrollment/enrollment-payment-types.d.ts +2 -2
  289. package/lib/resolvers/type/enrollment/enrollment-period-types.d.ts +2 -2
  290. package/lib/resolvers/type/enrollment/enrollment-plan-tyes.d.ts +2 -2
  291. package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js +0 -1
  292. package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js.map +1 -1
  293. package/lib/resolvers/type/enrollment/enrollment-types.d.ts +2 -2
  294. package/lib/resolvers/type/event-types.d.ts +1 -1
  295. package/lib/resolvers/type/filter/filter-option-types.d.ts +2 -2
  296. package/lib/resolvers/type/filter/filter-types.d.ts +2 -2
  297. package/lib/resolvers/type/index.d.ts +1 -0
  298. package/lib/resolvers/type/login-method-response-types.d.ts +1 -0
  299. package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +1 -1
  300. package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +1 -1
  301. package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts +1 -1
  302. package/lib/resolvers/type/order/order-discount-types.d.ts +1 -1
  303. package/lib/resolvers/type/order/order-global-discount-types.d.ts +1 -1
  304. package/lib/resolvers/type/order/order-item-discount-types.d.ts +1 -1
  305. package/lib/resolvers/type/order/order-item-types.d.ts +1 -1
  306. package/lib/resolvers/type/order/order-item-types.js +0 -3
  307. package/lib/resolvers/type/order/order-item-types.js.map +1 -1
  308. package/lib/resolvers/type/order/order-payment-card-types.d.ts +1 -1
  309. package/lib/resolvers/type/order/order-payment-discount-types.d.ts +1 -1
  310. package/lib/resolvers/type/order/order-payment-generic-types.d.ts +1 -1
  311. package/lib/resolvers/type/order/order-payment-invoice-types.d.ts +1 -1
  312. package/lib/resolvers/type/order/order-types.d.ts +1 -1
  313. package/lib/resolvers/type/price-types.d.ts +1 -1
  314. package/lib/resolvers/type/product/product-assortment-path-types.js +1 -0
  315. package/lib/resolvers/type/product/product-assortment-path-types.js.map +1 -1
  316. package/lib/resolvers/type/product/product-bundle-item-types.js +0 -1
  317. package/lib/resolvers/type/product/product-bundle-item-types.js.map +1 -1
  318. package/lib/resolvers/type/product/product-configurable-types.js +1 -0
  319. package/lib/resolvers/type/product/product-configurable-types.js.map +1 -1
  320. package/lib/resolvers/type/product/product-discount.d.ts +1 -1
  321. package/lib/resolvers/type/product/product-media-types.js +2 -0
  322. package/lib/resolvers/type/product/product-media-types.js.map +1 -1
  323. package/lib/resolvers/type/product/product-plan-types.js +1 -12
  324. package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
  325. package/lib/resolvers/type/product/product-review-types.d.ts +1 -1
  326. package/lib/resolvers/type/product/product-review-types.js +0 -1
  327. package/lib/resolvers/type/product/product-review-types.js.map +1 -1
  328. package/lib/resolvers/type/product/product-variation-assignment-types.js +0 -1
  329. package/lib/resolvers/type/product/product-variation-assignment-types.js.map +1 -1
  330. package/lib/resolvers/type/quotation-types.d.ts +2 -2
  331. package/lib/resolvers/type/quotation-types.js +0 -1
  332. package/lib/resolvers/type/quotation-types.js.map +1 -1
  333. package/lib/resolvers/type/shop-types.d.ts +1 -1
  334. package/lib/resolvers/type/token-types.d.ts +1 -1
  335. package/lib/resolvers/type/token-types.js +2 -1
  336. package/lib/resolvers/type/token-types.js.map +1 -1
  337. package/lib/resolvers/type/user-types.d.ts +4 -3
  338. package/lib/resolvers/type/user-types.js +10 -21
  339. package/lib/resolvers/type/user-types.js.map +1 -1
  340. package/lib/resolvers/type/webauthn-credentials-types.d.ts +1 -1
  341. package/lib/resolvers/type/work-types.d.ts +1 -1
  342. package/lib/roles/admin.js +3 -72
  343. package/lib/roles/admin.js.map +1 -1
  344. package/lib/schema/{types/log.d.ts → directives.d.ts} +0 -0
  345. package/lib/schema/directives.js +15 -0
  346. package/lib/schema/directives.js.map +1 -0
  347. package/lib/schema/index.js +2 -1
  348. package/lib/schema/index.js.map +1 -1
  349. package/lib/schema/inputTypes.js +0 -15
  350. package/lib/schema/inputTypes.js.map +1 -1
  351. package/lib/schema/mutation.js +22 -36
  352. package/lib/schema/mutation.js.map +1 -1
  353. package/lib/schema/query.js +42 -22
  354. package/lib/schema/query.js.map +1 -1
  355. package/lib/schema/types/assortment.js +10 -10
  356. package/lib/schema/types/color.js +1 -1
  357. package/lib/schema/types/country.js +1 -1
  358. package/lib/schema/types/currency.js +1 -1
  359. package/lib/schema/types/delivery.js +3 -2
  360. package/lib/schema/types/delivery.js.map +1 -1
  361. package/lib/schema/types/dimensions.js +1 -1
  362. package/lib/schema/types/discount.js +1 -1
  363. package/lib/schema/types/filter.js +5 -8
  364. package/lib/schema/types/filter.js.map +1 -1
  365. package/lib/schema/types/geo-position.js +1 -1
  366. package/lib/schema/types/language.js +1 -1
  367. package/lib/schema/types/media.js +1 -1
  368. package/lib/schema/types/payment.js +3 -3
  369. package/lib/schema/types/price.js +2 -2
  370. package/lib/schema/types/product/bundle-product.js +2 -3
  371. package/lib/schema/types/product/bundle-product.js.map +1 -1
  372. package/lib/schema/types/product/configurable-product.js +7 -7
  373. package/lib/schema/types/product/plan-product.js +3 -3
  374. package/lib/schema/types/product/product.js +11 -11
  375. package/lib/schema/types/product/simple-product.js +4 -4
  376. package/lib/schema/types/product/tokenized-product.js +3 -3
  377. package/lib/schema/types/search.js +3 -8
  378. package/lib/schema/types/search.js.map +1 -1
  379. package/lib/schema/types/shop.js +2 -2
  380. package/lib/schema/types/types.js +1 -1
  381. package/lib/schema/types/user.js +4 -3
  382. package/lib/schema/types/user.js.map +1 -1
  383. package/lib/schema/types/warehousing.js +3 -3
  384. package/package.json +26 -12
  385. package/src/acl.ts +2 -2
  386. package/src/api-index.ts +6 -27
  387. package/src/context.ts +0 -18
  388. package/src/createGraphQLServer.ts +14 -68
  389. package/src/errors.ts +85 -0
  390. package/src/express/createApolloMiddleware.ts +40 -0
  391. package/src/express/createBulkImportMiddleware.ts +87 -0
  392. package/src/express/createERCMetadataMiddleware.ts +73 -0
  393. package/src/express/createSingleSignOnMiddleware.ts +84 -0
  394. package/src/express/index.ts +48 -0
  395. package/src/loaders/index.ts +27 -35
  396. package/src/resolvers/mutations/accounts/changePassword.ts +11 -6
  397. package/src/resolvers/mutations/accounts/createUser.ts +21 -6
  398. package/src/resolvers/mutations/accounts/disableTOTP.ts +13 -3
  399. package/src/resolvers/mutations/accounts/enableTOTP.ts +9 -2
  400. package/src/resolvers/mutations/accounts/enrollUser.ts +20 -5
  401. package/src/resolvers/mutations/accounts/forgotPassword.ts +8 -1
  402. package/src/resolvers/mutations/accounts/impersonate.ts +1 -1
  403. package/src/resolvers/mutations/accounts/loginWithPassword.ts +27 -5
  404. package/src/resolvers/mutations/accounts/loginWithWebAuthn.ts +13 -2
  405. package/src/resolvers/mutations/accounts/logout.ts +9 -2
  406. package/src/resolvers/mutations/accounts/logoutAllSessions.ts +7 -1
  407. package/src/resolvers/mutations/accounts/resetPassword.ts +21 -5
  408. package/src/resolvers/mutations/accounts/setPassword.ts +2 -2
  409. package/src/resolvers/mutations/assortments/addAssortmentFilter.ts +5 -9
  410. package/src/resolvers/mutations/assortments/addAssortmentLink.ts +22 -14
  411. package/src/resolvers/mutations/assortments/addAssortmentMedia.ts +2 -6
  412. package/src/resolvers/mutations/assortments/addAssortmentProduct.ts +0 -2
  413. package/src/resolvers/mutations/assortments/createAssortment.ts +4 -8
  414. package/src/resolvers/mutations/assortments/prepareAssortmentMediaUpload.ts +0 -1
  415. package/src/resolvers/mutations/assortments/removeAssortment.ts +1 -1
  416. package/src/resolvers/mutations/assortments/removeAssortmentFilter.ts +1 -1
  417. package/src/resolvers/mutations/assortments/removeAssortmentLink.ts +1 -1
  418. package/src/resolvers/mutations/assortments/removeAssortmentMedia.ts +2 -2
  419. package/src/resolvers/mutations/assortments/removeAssortmentProduct.ts +1 -1
  420. package/src/resolvers/mutations/assortments/reorderAssortmentFilters.ts +3 -6
  421. package/src/resolvers/mutations/assortments/reorderAssortmentLinks.ts +0 -1
  422. package/src/resolvers/mutations/assortments/reorderAssortmentMedia.ts +3 -6
  423. package/src/resolvers/mutations/assortments/reorderAssortmentProducts.ts +0 -1
  424. package/src/resolvers/mutations/assortments/setBaseAssortment.ts +1 -1
  425. package/src/resolvers/mutations/assortments/updateAssortment.ts +1 -1
  426. package/src/resolvers/mutations/assortments/updateAssortmentMediaTexts.ts +1 -1
  427. package/src/resolvers/mutations/assortments/updateAssortmentTexts.ts +1 -1
  428. package/src/resolvers/mutations/bookmarks/bookmark.ts +4 -7
  429. package/src/resolvers/mutations/bookmarks/createBookmark.ts +4 -7
  430. package/src/resolvers/mutations/countries/createCountry.ts +3 -7
  431. package/src/resolvers/mutations/countries/removeCountry.ts +1 -1
  432. package/src/resolvers/mutations/countries/updateCountry.ts +1 -1
  433. package/src/resolvers/mutations/currencies/createCurrency.ts +3 -7
  434. package/src/resolvers/mutations/currencies/removeCurrency.ts +1 -1
  435. package/src/resolvers/mutations/currencies/updateCurrency.ts +1 -1
  436. package/src/resolvers/mutations/delivery/createDeliveryProvider.ts +3 -7
  437. package/src/resolvers/mutations/delivery/removeDeliveryProvider.ts +1 -1
  438. package/src/resolvers/mutations/delivery/updateDeliveryProvider.ts +1 -1
  439. package/src/resolvers/mutations/enrollments/activateEnrollment.ts +1 -1
  440. package/src/resolvers/mutations/enrollments/terminateEnrollment.ts +1 -1
  441. package/src/resolvers/mutations/enrollments/updateEnrollment.ts +5 -5
  442. package/src/resolvers/mutations/filters/createFilter.ts +0 -2
  443. package/src/resolvers/mutations/filters/createFilterOption.ts +5 -1
  444. package/src/resolvers/mutations/filters/removeFilter.ts +4 -4
  445. package/src/resolvers/mutations/filters/updateFilter.ts +1 -1
  446. package/src/resolvers/mutations/filters/updateFilterTexts.ts +1 -1
  447. package/src/resolvers/mutations/index.ts +2 -0
  448. package/src/resolvers/mutations/languages/createLanguage.ts +3 -7
  449. package/src/resolvers/mutations/languages/removeLanguage.ts +1 -1
  450. package/src/resolvers/mutations/languages/updateLanguage.ts +1 -1
  451. package/src/resolvers/mutations/orders/createCart.ts +4 -1
  452. package/src/resolvers/mutations/orders/payOrder.ts +1 -1
  453. package/src/resolvers/mutations/orders/removeOrder.ts +1 -1
  454. package/src/resolvers/mutations/pageView.ts +2 -2
  455. package/src/resolvers/mutations/payment/createPaymentProvider.ts +3 -7
  456. package/src/resolvers/mutations/payment/registerPaymentCredentials.ts +6 -2
  457. package/src/resolvers/mutations/payment/removePaymentProvider.ts +1 -1
  458. package/src/resolvers/mutations/payment/updatePaymentProvider.ts +1 -1
  459. package/src/resolvers/mutations/products/addProductAssignment.ts +4 -8
  460. package/src/resolvers/mutations/products/addProductMedia.ts +1 -2
  461. package/src/resolvers/mutations/products/addProductReviewVote.ts +1 -1
  462. package/src/resolvers/mutations/products/createProduct.ts +4 -8
  463. package/src/resolvers/mutations/products/createProductBundleItem.ts +1 -1
  464. package/src/resolvers/mutations/products/createProductReview.ts +5 -8
  465. package/src/resolvers/mutations/products/createProductVariation.ts +6 -10
  466. package/src/resolvers/mutations/products/createProductVariationOption.ts +4 -5
  467. package/src/resolvers/mutations/products/prepareProductMediaUpload.ts +0 -1
  468. package/src/resolvers/mutations/products/publishProduct.ts +1 -1
  469. package/src/resolvers/mutations/products/removeBundleItem.ts +2 -2
  470. package/src/resolvers/mutations/products/removeProduct.ts +26 -7
  471. package/src/resolvers/mutations/products/removeProductAssignment.ts +1 -1
  472. package/src/resolvers/mutations/products/removeProductMedia.ts +2 -2
  473. package/src/resolvers/mutations/products/removeProductReview.ts +1 -1
  474. package/src/resolvers/mutations/products/removeProductReviewVote.ts +1 -1
  475. package/src/resolvers/mutations/products/removeProductVariation.ts +1 -1
  476. package/src/resolvers/mutations/products/removeProductVariationOption.ts +0 -1
  477. package/src/resolvers/mutations/products/reorderProductMedia.ts +1 -1
  478. package/src/resolvers/mutations/products/unpublishProduct.ts +1 -1
  479. package/src/resolvers/mutations/products/updateProduct.ts +1 -1
  480. package/src/resolvers/mutations/products/updateProductCommerce.ts +1 -1
  481. package/src/resolvers/mutations/products/updateProductMediaTexts.ts +1 -1
  482. package/src/resolvers/mutations/products/updateProductPlan.ts +1 -1
  483. package/src/resolvers/mutations/products/updateProductReview.ts +1 -1
  484. package/src/resolvers/mutations/products/updateProductSupply.ts +1 -1
  485. package/src/resolvers/mutations/products/updateProductTexts.ts +1 -1
  486. package/src/resolvers/mutations/products/updateProductTokenization.ts +1 -1
  487. package/src/resolvers/mutations/products/updateProductVariationTexts.ts +0 -1
  488. package/src/resolvers/mutations/products/updateProductWarehousing.ts +1 -1
  489. package/src/resolvers/mutations/users/prepareUserAvatarUpload.ts +0 -1
  490. package/src/resolvers/mutations/users/removeUser.ts +19 -0
  491. package/src/resolvers/mutations/users/setRoles.ts +1 -1
  492. package/src/resolvers/mutations/users/setUserTags.ts +1 -1
  493. package/src/resolvers/mutations/users/updateUserAvatar.ts +1 -2
  494. package/src/resolvers/mutations/users/updateUserProfile.ts +1 -1
  495. package/src/resolvers/mutations/utils/getOrderCart.ts +1 -1
  496. package/src/resolvers/mutations/warehousing/createWarehousingProvider.ts +3 -7
  497. package/src/resolvers/mutations/warehousing/removeWarehousingProvider.ts +1 -1
  498. package/src/resolvers/mutations/warehousing/updateWarehousingProvider.ts +1 -1
  499. package/src/resolvers/mutations/worker/addWork.ts +1 -1
  500. package/src/resolvers/mutations/worker/finishWork.ts +8 -12
  501. package/src/resolvers/mutations/worker/removeWork.ts +1 -1
  502. package/src/resolvers/queries/products/productCatalogPrices.ts +0 -1
  503. package/src/resolvers/queries/users/users.ts +2 -1
  504. package/src/resolvers/queries/worker/workQueue.ts +1 -1
  505. package/src/resolvers/type/assortment/assortment-filter-types.ts +0 -1
  506. package/src/resolvers/type/assortment/assortment-link-types.ts +0 -2
  507. package/src/resolvers/type/assortment/assortment-media-types.ts +2 -0
  508. package/src/resolvers/type/assortment/assortment-path-link-types.ts +1 -11
  509. package/src/resolvers/type/assortment/assortment-product-types.ts +0 -2
  510. package/src/resolvers/type/assortment/assortment-types.ts +9 -4
  511. package/src/resolvers/type/bookmark-types.ts +0 -1
  512. package/src/resolvers/type/enrollment/enrollment-plan-tyes.ts +0 -1
  513. package/src/resolvers/type/order/order-item-types.ts +0 -3
  514. package/src/resolvers/type/product/product-assortment-path-types.ts +1 -0
  515. package/src/resolvers/type/product/product-bundle-item-types.ts +0 -1
  516. package/src/resolvers/type/product/product-configurable-types.ts +1 -0
  517. package/src/resolvers/type/product/product-media-types.ts +2 -0
  518. package/src/resolvers/type/product/product-plan-types.ts +2 -18
  519. package/src/resolvers/type/product/product-review-types.ts +0 -1
  520. package/src/resolvers/type/product/product-variation-assignment-types.ts +0 -1
  521. package/src/resolvers/type/quotation-types.ts +0 -1
  522. package/src/resolvers/type/token-types.ts +2 -1
  523. package/src/resolvers/type/user-types.ts +14 -25
  524. package/src/roles/admin.ts +3 -72
  525. package/src/schema/directives.js +14 -0
  526. package/src/schema/index.js +2 -1
  527. package/src/schema/inputTypes.js +0 -15
  528. package/src/schema/mutation.js +22 -36
  529. package/src/schema/query.js +42 -22
  530. package/src/schema/types/assortment.js +10 -10
  531. package/src/schema/types/color.js +1 -1
  532. package/src/schema/types/country.js +1 -1
  533. package/src/schema/types/currency.js +1 -1
  534. package/src/schema/types/delivery.js +3 -2
  535. package/src/schema/types/dimensions.js +1 -1
  536. package/src/schema/types/discount.js +1 -1
  537. package/src/schema/types/filter.js +5 -8
  538. package/src/schema/types/geo-position.js +1 -1
  539. package/src/schema/types/language.js +1 -1
  540. package/src/schema/types/media.js +1 -1
  541. package/src/schema/types/payment.js +3 -3
  542. package/src/schema/types/price.js +2 -2
  543. package/src/schema/types/product/bundle-product.js +2 -3
  544. package/src/schema/types/product/configurable-product.js +7 -7
  545. package/src/schema/types/product/plan-product.js +3 -3
  546. package/src/schema/types/product/product.js +11 -11
  547. package/src/schema/types/product/simple-product.js +4 -4
  548. package/src/schema/types/product/tokenized-product.js +3 -3
  549. package/src/schema/types/search.js +3 -8
  550. package/src/schema/types/shop.js +2 -2
  551. package/src/schema/types/types.js +1 -1
  552. package/src/schema/types/user.js +4 -3
  553. package/src/schema/types/warehousing.js +3 -3
  554. package/tests/api-index.test.ts +78 -0
  555. package/lib/createBulkImportServer.d.ts +0 -2
  556. package/lib/createBulkImportServer.js +0 -81
  557. package/lib/createBulkImportServer.js.map +0 -1
  558. package/lib/createERCMetadataServer.d.ts +0 -2
  559. package/lib/createERCMetadataServer.js +0 -59
  560. package/lib/createERCMetadataServer.js.map +0 -1
  561. package/lib/schema/types/log.js +0 -16
  562. package/lib/schema/types/log.js.map +0 -1
  563. package/src/createBulkImportServer.ts +0 -95
  564. package/src/createERCMetadataServer.ts +0 -78
  565. package/src/schema/types/log.js +0 -15
package/jest.config.js CHANGED
@@ -2,4 +2,13 @@
2
2
  export default {
3
3
  preset: 'ts-jest',
4
4
  testEnvironment: 'node',
5
+ extensionsToTreatAsEsm: ['.ts'],
6
+ transform: {
7
+ '^.+\\.tsx?$': [
8
+ 'ts-jest',
9
+ {
10
+ useESM: true,
11
+ },
12
+ ],
13
+ },
5
14
  };
package/lib/acl.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { CheckPermissionArgs } from '@unchainedshop/types/roles';
2
+ export declare const ensureActionExists: (action: any, userOptions: any) => void;
3
+ export declare const ensureIsFunction: (fn: any, action: any, options: any, key: any) => void;
2
4
  declare const checkAction: (context: any, action: any, args?: CheckPermissionArgs, options?: any) => Promise<void>;
3
5
  declare const checkResolver: (action: any, userOptions?: any) => (fn: any, name?: string) => (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
4
6
  declare const checkTypeResolver: (action: any, key: any) => (obj: any, params: any, context: any) => Promise<any>;
package/lib/acl.js CHANGED
@@ -6,12 +6,12 @@ const defaultOptions = {
6
6
  };
7
7
  const emptyObject = {};
8
8
  const emptyArray = [];
9
- const ensureActionExists = (action, userOptions) => {
9
+ export const ensureActionExists = (action, userOptions) => {
10
10
  if (!action) {
11
11
  throw new PermissionSystemError({ userOptions });
12
12
  }
13
13
  };
14
- const ensureIsFunction = (fn, action, options, key) => {
14
+ export const ensureIsFunction = (fn, action, options, key) => {
15
15
  if (typeof fn !== 'function') {
16
16
  throw new PermissionSystemError({
17
17
  action,
package/lib/acl.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"acl.js","sourceRoot":"","sources":["../src/acl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEpE,M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,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,IAAI,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,UAAU,EAAE;QAClC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;IACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC,CAAC;AAEJ,MAAM,iBAAiB,GAAG,SAAS,iBAAiB,CAAC,MAAM,EAAE,WAAiB;IAC5E,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxC,OAAO,SAAS,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU;QAC/C,MAAM,EAAE,GAAG,UAAU,CAAC,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO;YACL,YAAY,EAAE,IAAI;YAClB,GAAG;gBACD,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;gBACzD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;oBAC/B,KAAK;oBACL,YAAY,EAAE,IAAI;oBAClB,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,6BAA6B;AAC7B,iCAAiC;AACjC,eAAe,iBAAiB,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAC"}
@@ -1,14 +1,12 @@
1
1
  import { UnchainedServerOptions } from '@unchainedshop/types/api';
2
2
  import type { ApolloServer } from '@apollo/server';
3
- import { createContextResolver, getCurrentContextResolver, setCurrentContextResolver } from './context';
3
+ import { createContextResolver, setCurrentContextResolver, getCurrentContextResolver } from './context';
4
4
  export * from './context';
5
5
  export * as acl from './acl';
6
6
  export * as errors from './errors';
7
+ export * as express from './express';
7
8
  export { hashPassword } from './hashPassword';
8
9
  export * as roles from './roles';
9
10
  export { createContextResolver, getCurrentContextResolver, setCurrentContextResolver };
10
- export declare const startAPIServer: (options: UnchainedServerOptions) => Promise<{
11
- apolloGraphQLServer: ApolloServer;
12
- bulkImportServer: any;
13
- ercMetadataServer: any;
14
- }>;
11
+ export declare const loadJSON: (filename: any) => any;
12
+ export declare const startAPIServer: (options: UnchainedServerOptions) => Promise<ApolloServer>;
package/lib/api-index.js CHANGED
@@ -1,16 +1,15 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import createBulkImportServer from './createBulkImportServer';
4
3
  import createGraphQLServer from './createGraphQLServer';
5
- import { createContextResolver, getCurrentContextResolver, setCurrentContextResolver } from './context';
6
- import createERCMetadataServer from './createERCMetadataServer';
4
+ import { createContextResolver, setCurrentContextResolver, getCurrentContextResolver } from './context';
7
5
  export * from './context';
8
6
  export * as acl from './acl';
9
7
  export * as errors from './errors';
8
+ export * as express from './express';
10
9
  export { hashPassword } from './hashPassword';
11
10
  export * as roles from './roles';
12
11
  export { createContextResolver, getCurrentContextResolver, setCurrentContextResolver };
13
- const loadJSON = (filename) => {
12
+ export const loadJSON = (filename) => {
14
13
  try {
15
14
  const base = typeof __filename !== 'undefined' && __filename;
16
15
  if (!base)
@@ -28,20 +27,13 @@ const loadJSON = (filename) => {
28
27
  const packageJson = loadJSON('../package.json');
29
28
  const UNCHAINED_API_VERSION = process.env.UNCHAINED_API_VERSION || packageJson?.version || '1.2.x';
30
29
  export const startAPIServer = async (options) => {
31
- const { unchainedAPI, roles, expressApp, context: customContext, ...apolloServerOptions } = options || {};
30
+ const { unchainedAPI, roles, context: customContext, ...apolloServerOptions } = options || {};
32
31
  const contextResolver = createContextResolver(unchainedAPI, roles, UNCHAINED_API_VERSION);
33
32
  setCurrentContextResolver(customContext
34
33
  ? ({ req, res }) => {
35
34
  return customContext({ req, res }, contextResolver);
36
35
  }
37
36
  : contextResolver);
38
- const apolloGraphQLServer = await createGraphQLServer(expressApp, apolloServerOptions);
39
- const bulkImportServer = createBulkImportServer(expressApp);
40
- const ercMetadataServer = createERCMetadataServer(expressApp);
41
- return {
42
- apolloGraphQLServer,
43
- bulkImportServer,
44
- ercMetadataServer,
45
- };
37
+ return createGraphQLServer(apolloServerOptions);
46
38
  };
47
39
  //# sourceMappingURL=api-index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-index.js","sourceRoot":"","sources":["../src/api-index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACxG,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,CAAC;AAEvF,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE;IAC5B,IAAI;QACF,MAAM,IAAI,GAAG,OAAO,UAAU,KAAK,WAAW,IAAI,UAAU,CAAC;QAC7D,IAAI,CAAC,IAAI;YACP,OAAO;gBACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;aACzC,CAAC;QACJ,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;QAChE,MAAM,IAAI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OAA+B,EAAyB,EAAE;IAC7F,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE9F,MAAM,eAAe,GAAG,qBAAqB,CAAC,YAAY,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC;IAE1F,yBAAyB,CACvB,aAAa;QACX,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE;YACf,OAAO,aAAa,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;QACtD,CAAC;QACH,CAAC,CAAC,eAAe,CACpB,CAAC;IAEF,OAAO,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;AAClD,CAAC,CAAC"}
package/lib/context.d.ts CHANGED
@@ -3,4 +3,3 @@ import { UnchainedCore } from '@unchainedshop/types/core';
3
3
  export declare const getCurrentContextResolver: () => UnchainedContextResolver;
4
4
  export declare const setCurrentContextResolver: (newContext: UnchainedContextResolver) => void;
5
5
  export declare const createContextResolver: (unchainedAPI: UnchainedCore, roles: any, version: string) => UnchainedContextResolver;
6
- export declare const useMiddlewareWithCurrentContext: (expressApp: any, path: any, ...middleware: any[]) => void;
package/lib/context.js CHANGED
@@ -22,16 +22,4 @@ export const createContextResolver = (unchainedAPI, roles, version) => async ({
22
22
  version,
23
23
  };
24
24
  };
25
- export const useMiddlewareWithCurrentContext = (expressApp, path, ...middleware) => {
26
- const addContext = async function middlewareWithContext(req, res, next) {
27
- try {
28
- req.unchainedContext = await context({ req, res });
29
- next();
30
- }
31
- catch (error) {
32
- next(error);
33
- }
34
- };
35
- expressApp.use(path, addContext, ...middleware);
36
- };
37
25
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,MAAM,WAAW,CAAC;AAC3C,OAAO,E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AI,CAAC,KAAK,CAAC,CAAC;SACb;IACH,CAAC,CAAC;IAEF,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,CAAC;AAClD,CAAC,CAAC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,IAAI,OAAO,CAAC;AAEZ,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAA6B,EAAE,CAAC,OAAO,CAAC;AAEjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,UAAoC,EAAE,EAAE;IAChF,OAAO,GAAG,UAAU,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAChC,CAAC,YAA2B,EAAE,KAAU,EAAE,OAAe,EAA4B,EAAE,CACvF,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,aAAa,EAAE,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAErE,OAAO;QACL,GAAG;QACH,GAAG;QACH,GAAG,aAAa;QAChB,GAAG,YAAY;QACf,GAAG,WAAW;QACd,GAAG,aAAa;QAChB,OAAO;QACP,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { ApolloServer } from '@apollo/server';
2
- declare const _default: (expressApp: any, options: any) => Promise<ApolloServer<import("@apollo/server").BaseContext>>;
2
+ declare const _default: (options: any) => Promise<ApolloServer<import("@apollo/server").BaseContext>>;
3
3
  export default _default;
@@ -1,47 +1,34 @@
1
1
  import { ApolloServer } from '@apollo/server';
2
- import { expressMiddleware } from '@apollo/server/express4';
3
- import { GraphQLError } from 'graphql';
4
- import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs';
5
2
  import { log, LogLevel } from '@unchainedshop/logger';
6
- import cors from 'cors';
7
- import bodyParser from 'body-parser';
8
3
  import typeDefs from './schema';
9
4
  import resolvers from './resolvers';
10
- import { getCurrentContextResolver } from './context';
11
5
  const { APOLLO_ENGINE_KEY } = process.env;
12
6
  const logGraphQLServerError = (error) => {
13
7
  try {
14
- const { message, extensions: { exception: { stacktrace, ...parameters }, ...extensions }, ...rest } = error;
15
- log(`${message} ${extensions && extensions.code}`, {
8
+ const { message, extensions: { stacktrace, ...parameters }, ...rest } = error;
9
+ log(`${message} ${parameters && parameters.code}`, {
16
10
  level: LogLevel.Error,
17
- ...extensions,
11
+ ...parameters,
18
12
  ...rest,
19
13
  });
20
- console.error(stacktrace, parameters); // eslint-disable-line
14
+ if (stacktrace && process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {
15
+ const nativeError = new Error(message);
16
+ nativeError.stack = stacktrace.join('\n');
17
+ nativeError.name = parameters.code;
18
+ // eslint-disable-next-line
19
+ console.error(nativeError);
20
+ }
21
21
  }
22
22
  catch (e) { } // eslint-disable-line
23
23
  };
24
- export default async (expressApp, options) => {
25
- const { corsOrigins = null, // no cookie handling
26
- typeDefs: additionalTypeDefs = [], resolvers: additionalResolvers = [], engine = {}, ...apolloServerOptions } = options || {};
27
- const context = getCurrentContextResolver();
24
+ export default async (options) => {
25
+ const { typeDefs: additionalTypeDefs = [], resolvers: additionalResolvers = [], engine = {}, ...apolloServerOptions } = options || {};
28
26
  const server = new ApolloServer({
29
27
  typeDefs: [...typeDefs, ...additionalTypeDefs],
30
28
  resolvers: [resolvers, ...additionalResolvers],
31
29
  formatError: (error) => {
32
30
  logGraphQLServerError(error);
33
- const { message, path, extensions: { exception, code, ...extensions }, // eslint-disable-line
34
- } = error;
35
- const apolloError = new GraphQLError(message, {
36
- extensions: {
37
- code,
38
- ...extensions,
39
- },
40
- });
41
- // eslint-disable-next-line
42
- // @ts-ignore
43
- apolloError.path = path;
44
- return apolloError;
31
+ return error;
45
32
  },
46
33
  apollo: APOLLO_ENGINE_KEY
47
34
  ? {
@@ -53,30 +40,6 @@ export default async (expressApp, options) => {
53
40
  ...apolloServerOptions,
54
41
  });
55
42
  await server.start();
56
- const originFn = corsOrigins && Array.isArray(corsOrigins)
57
- ? (origin, callback) => {
58
- if (corsOrigins.length === 0 || !origin) {
59
- callback(null, true);
60
- return;
61
- }
62
- if (corsOrigins.indexOf(origin) !== -1) {
63
- callback(null, true);
64
- }
65
- else {
66
- callback(new Error('Not allowed by CORS'));
67
- }
68
- }
69
- : corsOrigins;
70
- expressApp.use('/graphql', cors(!originFn
71
- ? undefined
72
- : {
73
- origin: originFn,
74
- credentials: true,
75
- }), bodyParser.json(), graphqlUploadExpress(), expressMiddleware(server, {
76
- context,
77
- }));
78
- // expressApp.use(handleUploads({ maxFileSize: 10000000, maxFiles: 10 }));
79
- // expressApp.use(middleware);
80
43
  return server;
81
44
  };
82
45
  //# sourceMappingURL=createGraphQLServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createGraphQLServer.js","sourceRoot":"","sources":["../src/createGraphQLServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,IAAI,MAAM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C;YACvC,WAAW,CAAC,KAAK,GAAI,UAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxD,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,IAAc,CAAC;YAC7C,2BAA2B;YAC3B,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;SAC5B;KACF;IAAC,OAAO,CAAC,EAAE,GAAE,CAAC,sBAAsB;AACvC,CAAC,CAAC;AAEF,eAAe,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/B,MAAM,EACJ,QAAQ,EAAE,kBAAkB,GAAG,EAAE,EACjC,SAAS,EAAE,mBAAmB,GAAG,EAAE,EACnC,MAAM,GAAG,EAAE,EACX,GAAG,mBAAmB,EACvB,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC;QAC9B,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,kBAAkB,CAAC;QAC9C,SAAS,EAAE,CAAC,SAAS,EAAE,GAAG,mBAAmB,CAAC;QAC9C,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,EAAE,iBAAiB;YACvB,CAAC,CAAC;gBACE,GAAG,EAAE,iBAAiB;gBACtB,gBAAgB,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,CAAC;gBACpF,GAAG,MAAM;aACV;YACH,CAAC,CAAC,SAAS;QACb,GAAG,mBAAmB;KACvB,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
package/lib/errors.d.ts CHANGED
@@ -53,3 +53,23 @@ export declare const WarehousingProviderNotFoundError: any;
53
53
  export declare const InvalidIdError: any;
54
54
  export declare const ProviderConfigurationInvalid: any;
55
55
  export declare const TokenWrongStatusError: any;
56
+ export declare const CyclicAssortmentLinkNotSupportedError: any;
57
+ export declare const EmailAlreadyExistsError: any;
58
+ export declare const UsernameAlreadyExistsError: any;
59
+ export declare const UsernameOrEmailRequiredError: any;
60
+ export declare const TwoFactorCodeDidNotMatchError: any;
61
+ export declare const TwoFactorCodeRequiredError: any;
62
+ export declare const TwoFactorAlreadySetError: any;
63
+ export declare const TwoFactorNotSetError: any;
64
+ export declare const InvalidCredentialsError: any;
65
+ export declare const InvalidResetTokenError: any;
66
+ export declare const NoEmailSetError: any;
67
+ export declare const ResetPasswordLinkExpiredError: any;
68
+ export declare const ResetPasswordLinkUnknownAddressError: any;
69
+ export declare const AuthenticationFailedError: any;
70
+ export declare const UserDeactivatedError: any;
71
+ export declare const AuthOperationFailedError: any;
72
+ export declare const ProductLinkedToActiveVariationError: any;
73
+ export declare const ProductLinkedToActiveBundleError: any;
74
+ export declare const ProductLinkedToEnrollmentError: any;
75
+ export declare const ProductLinkedToQuotationError: any;
package/lib/errors.js CHANGED
@@ -63,4 +63,24 @@ export const WarehousingProviderNotFoundError = createError('WarehousingProvider
63
63
  export const InvalidIdError = createError('InvalidIdError', 'Invalid ID provided');
64
64
  export const ProviderConfigurationInvalid = createError('ProviderConfigurationInvalid', 'Provider Configuration invalid (check if the Adapter Key exists)');
65
65
  export const TokenWrongStatusError = createError('TokenWrongStatusError', 'The current status of the token does not allow this operation');
66
+ export const CyclicAssortmentLinkNotSupportedError = createError('CyclicAssortmentLinkNotSupported', 'Cyclic assortment link detected, make sure child assortment is not assigned as a parent on the assortment graph');
67
+ export const EmailAlreadyExistsError = createError('EmailAlreadyExists', 'Email already exist in the database');
68
+ export const UsernameAlreadyExistsError = createError('UsernameAlreadyExists', 'Username already exist in the database');
69
+ export const UsernameOrEmailRequiredError = createError('UsernameOrEmailRequired', 'No username or email is provided.');
70
+ export const TwoFactorCodeDidNotMatchError = createError('TwoFactorCodeDidNotMatch', "2FA code didn't match");
71
+ export const TwoFactorCodeRequiredError = createError('TwoFactorCodeRequired', '2FA code required');
72
+ export const TwoFactorAlreadySetError = createError('TwoFactorAlreadySet', '2FA already set for user');
73
+ export const TwoFactorNotSetError = createError('TwoFactorNotSet', '2FA not set for user');
74
+ export const InvalidCredentialsError = createError('InvalidCredentials', 'Incorrect credential provided');
75
+ export const InvalidResetTokenError = createError('InvalidResetTokenError', 'Token validation failed');
76
+ export const NoEmailSetError = createError('NoEmailSet', 'User has no email set');
77
+ export const ResetPasswordLinkExpiredError = createError('ResetPasswordLinkExpired', 'Token does not exist or is expired');
78
+ export const ResetPasswordLinkUnknownAddressError = createError('ResetPasswordLinkUnknownAddress', 'Valid token but no email address found for the entry');
79
+ export const AuthenticationFailedError = createError('AuthenticationFailed', 'Failed to authenticate the user');
80
+ export const UserDeactivatedError = createError('UserDeactivatedError', 'User is deactivated, so not allowed to login');
81
+ export const AuthOperationFailedError = createError('AuthOperationFailed', 'Operation failed, please make sure you have provided all required parameters');
82
+ export const ProductLinkedToActiveVariationError = createError('ProductLinkedToActiveVariation', 'Product is part of a active variation, remove it from any active/draft variation before deleting');
83
+ export const ProductLinkedToActiveBundleError = createError('ProductLinkedToActiveBundle', 'Product is part of a active/draft bundle item, remove it from any active/draft bundle item before deleting');
84
+ export const ProductLinkedToEnrollmentError = createError('ProductLinkedToEnrollment', 'Product is part of a active/paused subscriptions item, remove it from any active/paused subscriptions item before deleting');
85
+ export const ProductLinkedToQuotationError = createError('ProductLinkedToQuotation', 'Product is part of a requested/proposed quotations item, remove it from any requested/proposed quotations item before deleting');
66
86
  //# sourceMappingURL=errors.js.map
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAAe,EAAO,EAAE,CAChE,KAAM,SAAQ,YAAY;IACxB,YAAY,E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,iCAAiC,CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAC7C,sBAAsB,EACtB,8CAA8C,CAC/C,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CACjD,qBAAqB,EACrB,8EAA8E,CAC/E,CAAC;AAEF,MAAM,CAAC,MAAM,mCAAmC,GAAG,WAAW,CAC5D,gCAAgC,EAChC,kGAAkG,CACnG,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAG,WAAW,CACzD,6BAA6B,EAC7B,4GAA4G,CAC7G,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG,WAAW,CACvD,2BAA2B,EAC3B,4HAA4H,CAC7H,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,WAAW,CACtD,0BAA0B,EAC1B,gIAAgI,CACjI,CAAC"}
@@ -0,0 +1,4 @@
1
+ export default function createApolloMiddleware(contextResolver: any, { apolloGraphQLServer, corsOrigins }: {
2
+ apolloGraphQLServer: any;
3
+ corsOrigins?: any;
4
+ }): any[];
@@ -0,0 +1,34 @@
1
+ import cors from 'cors';
2
+ import { expressMiddleware } from '@apollo/server/express4';
3
+ import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs';
4
+ import e from 'express';
5
+ export default function createApolloMiddleware(contextResolver, { apolloGraphQLServer, corsOrigins = undefined }) {
6
+ const originFn = corsOrigins && Array.isArray(corsOrigins)
7
+ ? (origin, callback) => {
8
+ if (corsOrigins.length === 0 || !origin) {
9
+ callback(null, true);
10
+ return;
11
+ }
12
+ if (corsOrigins.indexOf(origin) !== -1) {
13
+ callback(null, true);
14
+ }
15
+ else {
16
+ callback(new Error('Not allowed by CORS'));
17
+ }
18
+ }
19
+ : corsOrigins;
20
+ return [
21
+ cors(!originFn
22
+ ? undefined
23
+ : {
24
+ origin: originFn,
25
+ credentials: true,
26
+ }),
27
+ e.json(),
28
+ graphqlUploadExpress({ maxFileSize: 10000000, maxFiles: 10 }),
29
+ expressMiddleware(apolloGraphQLServer, {
30
+ context: contextResolver,
31
+ }),
32
+ ];
33
+ }
34
+ //# sourceMappingURL=createApolloMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createApolloMiddleware.js","sourceRoot":"","sources":["../../src/express/createApolloMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAC3E,OAAO,CAAC,MAAM,SAAS,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,eAAe,EACf,EAAE,mBAAmB,EAAE,WAAW,GAAG,SAAS,EAAE;IAEhD,MAAM,QAAQ,GACZ,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QACvC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YACnB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;gBACvC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACrB,OAAO;aACR;YACD,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBACtC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACtB;iBAAM;gBACL,QAAQ,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;aAC5C;QACH,CAAC;QACH,CAAC,CAAC,WAAW,CAAC;IAElB,OAAO;QACL,IAAI,CACF,CAAC,QAAQ;YACP,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACE,MAAM,EAAE,QAAQ;gBAChB,WAAW,EAAE,IAAI;aAClB,CACN;QACD,CAAC,CAAC,IAAI,EAAE;QACR,oBAAoB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAC7D,iBAAiB,CAAC,mBAAmB,EAAE;YACrC,OAAO,EAAE,eAAe;SACzB,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { UnchainedContextResolver } from '@unchainedshop/types/api';
2
+ export default function bulkImportMiddleware(contextResolver: UnchainedContextResolver): (req: any, res: any) => Promise<void>;
@@ -0,0 +1,79 @@
1
+ import { createLogger } from '@unchainedshop/logger';
2
+ import fs from 'fs';
3
+ import { checkAction } from '../acl';
4
+ import { actions } from '../roles';
5
+ const logger = createLogger('unchained:bulk-import');
6
+ const { BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY } = process.env;
7
+ const errorHandler = (res) => (e) => {
8
+ logger.error(e.message);
9
+ res.writeHead(503);
10
+ res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
11
+ };
12
+ const methodWrongHandler = (res) => () => {
13
+ logger.error('Method not supported, return 404');
14
+ res.writeHead(404);
15
+ res.end();
16
+ };
17
+ const createWriteStreamToFilesystem = (cacheDirectory) => {
18
+ const date = new Date().toISOString();
19
+ const payloadFilePath = `${cacheDirectory}/${date}.json`;
20
+ const stream = fs.createWriteStream(payloadFilePath, { flags: 'a' });
21
+ return stream;
22
+ };
23
+ const createWriteStreamToMongoDB = (BulkImportPayloads) => {
24
+ const date = new Date().toISOString();
25
+ const stream = BulkImportPayloads.openUploadStreamWithId(date, `${date}.json`, {
26
+ contentType: 'application/json',
27
+ });
28
+ return stream;
29
+ };
30
+ export default function bulkImportMiddleware(contextResolver) {
31
+ return async (req, res) => {
32
+ try {
33
+ if (req.method !== 'POST') {
34
+ methodWrongHandler(res)();
35
+ return;
36
+ }
37
+ const context = await contextResolver({ req, res });
38
+ await checkAction(context, actions.bulkImport);
39
+ const input = {
40
+ createShouldUpsertIfIDExists: !!req.query?.createShouldUpsertIfIDExists,
41
+ skipCacheInvalidation: !!req.query?.skipCacheInvalidation,
42
+ fsPayloadCacheDirectory: BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY,
43
+ remoteAddress: context.remoteAddress,
44
+ };
45
+ const stream = input.fsPayloadCacheDirectory
46
+ ? createWriteStreamToFilesystem(input.fsPayloadCacheDirectory)
47
+ : createWriteStreamToMongoDB(context.bulkImporter.BulkImportPayloads);
48
+ req
49
+ .pipe(stream)
50
+ .on('error', errorHandler(res))
51
+ .on('finish', async (file) => {
52
+ try {
53
+ if (input.fsPayloadCacheDirectory) {
54
+ input.payloadFilePath = stream.path;
55
+ }
56
+ else {
57
+ input.payloadId = file._id;
58
+ input.payloadSize = file.length;
59
+ }
60
+ const work = await context.modules.worker.addWork({
61
+ type: 'BULK_IMPORT',
62
+ input: Object.fromEntries(Object.entries(input).filter(([, value]) => Boolean(value))),
63
+ retries: 0,
64
+ priority: 10,
65
+ });
66
+ res.writeHead(200);
67
+ res.end(JSON.stringify(work));
68
+ }
69
+ catch (e) {
70
+ errorHandler(res)(e);
71
+ }
72
+ });
73
+ }
74
+ catch (e) {
75
+ errorHandler(res)(e);
76
+ }
77
+ };
78
+ }
79
+ //# sourceMappingURL=createBulkImportMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBulkImportMiddleware.js","sourceRoot":"","sources":["../../src/express/createBulkImportMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,EAAE,mCAAmC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE5D,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IAClC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CA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M,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;wBACtF,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE,EAAE;qBACb,CAAC,CAAC;oBACH,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;oBACnB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;iBAC/B;gBAAC,OAAO,CAAC,EAAE;oBACV,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;SACN;QAAC,OAAO,CAAC,EAAE;YACV,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACtB;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { UnchainedContextResolver } from '@unchainedshop/types/api';
2
+ import { IncomingMessage } from 'http';
3
+ export default function ercMetadataMiddleware(contextResolver: UnchainedContextResolver): (req: IncomingMessage, res: any) => Promise<void>;
@@ -0,0 +1,57 @@
1
+ import { createLogger } from '@unchainedshop/logger';
2
+ import { systemLocale } from '@unchainedshop/utils';
3
+ import localePkg from 'locale';
4
+ import path from 'path';
5
+ const { Locale } = localePkg;
6
+ const logger = createLogger('unchained:erc-metadata');
7
+ const errorHandler = (res) => (e) => {
8
+ logger.error(e.message);
9
+ res.writeHead(503);
10
+ res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
11
+ };
12
+ const methodWrongHandler = (res) => () => {
13
+ logger.error('Method not supported, return 404');
14
+ res.writeHead(404);
15
+ res.end();
16
+ };
17
+ export default function ercMetadataMiddleware(contextResolver) {
18
+ return async (req, res) => {
19
+ try {
20
+ if (req.method !== 'GET') {
21
+ methodWrongHandler(res)();
22
+ return;
23
+ }
24
+ const context = await contextResolver({ req, res });
25
+ const url = new URL(req.url, process.env.ROOT_URL);
26
+ const parsedPath = path.parse(url.pathname);
27
+ if (parsedPath.ext !== '.json')
28
+ throw new Error('Invalid ERC Metadata URI');
29
+ const [, productId, localeOrTokenFilename, tokenFileName] = url.pathname.split('/');
30
+ const locale = tokenFileName ? localeOrTokenFilename : systemLocale.language;
31
+ const chainTokenId = parsedPath.name;
32
+ const product = await context.modules.products.findProduct({
33
+ productId,
34
+ });
35
+ const [token] = await context.modules.warehousing.findTokens({
36
+ chainTokenId,
37
+ contractAddress: product?.tokenization?.contractAddress,
38
+ });
39
+ const ercMetadata = await context.modules.warehousing.tokenMetadata(chainTokenId, {
40
+ token,
41
+ product,
42
+ locale: new Locale(locale),
43
+ referenceDate: new Date(),
44
+ }, context);
45
+ const body = JSON.stringify(ercMetadata);
46
+ res.writeHead(200, {
47
+ 'Content-Length': Buffer.byteLength(body),
48
+ 'Content-Type': 'text/plain',
49
+ });
50
+ res.end(body);
51
+ }
52
+ catch (e) {
53
+ errorHandler(res)(e);
54
+ }
55
+ };
56
+ }
57
+ //# sourceMappingURL=createERCMetadataMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createERCMetadataMiddleware.js","sourceRoot":"","sources":["../../src/express/createERCMetadataMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,SAAS,MAAM,QAAQ,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;AAE7B,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAAC;AAEtD,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IAClC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACxB,GAAG,CAAC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BAAqB,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;YAC7E,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;YAErC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACzD,SAAS;aACV,CAAC,CAAC;YAEH,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC;gBAC3D,YAAY;gBACZ,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe;aACxD,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CACjE,YAAY,EACZ;gBACE,KAAK;gBACL,OAAO;gBACP,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC;gBAC1B,aAAa,EAAE,IAAI,IAAI,EAAE;aAC1B,EACD,OAAO,CACR,CAAC;YAEF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACzC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;gBACjB,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;gBACzC,cAAc,EAAE,YAAY;aAC7B,CAAC,CAAC;YACH,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACf;QAAC,OAAO,CAAC,EAAE;YACV,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACtB;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /// <reference lib="dom" />
2
+ import { UnchainedContextResolver } from '@unchainedshop/types/api';
3
+ import { IncomingMessage } from 'http';
4
+ export default function singleSignOnMiddleware(contextResolver: UnchainedContextResolver): (req: IncomingMessage & {
5
+ query?: any;
6
+ }, res: any, next: any) => Promise<void>;