@unchainedshop/api 3.0.0-rc1 → 3.0.0-rc11

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 (233) hide show
  1. package/lib/api-index.d.ts +1 -1
  2. package/lib/api-index.d.ts.map +1 -1
  3. package/lib/api-index.js +1 -1
  4. package/lib/api-index.js.map +1 -1
  5. package/lib/context.d.ts +0 -1
  6. package/lib/context.d.ts.map +1 -1
  7. package/lib/context.js +4 -19
  8. package/lib/context.js.map +1 -1
  9. package/lib/errors.d.ts +1 -0
  10. package/lib/errors.d.ts.map +1 -1
  11. package/lib/errors.js +1 -0
  12. package/lib/errors.js.map +1 -1
  13. package/lib/express/createBulkImportMiddleware.d.ts +1 -2
  14. package/lib/express/createBulkImportMiddleware.d.ts.map +1 -1
  15. package/lib/express/createBulkImportMiddleware.js.map +1 -1
  16. package/lib/express/createERCMetadataMiddleware.js +1 -1
  17. package/lib/express/createERCMetadataMiddleware.js.map +1 -1
  18. package/lib/express/index.d.ts.map +1 -1
  19. package/lib/express/index.js.map +1 -1
  20. package/lib/fastify/index.d.ts.map +1 -1
  21. package/lib/fastify/index.js.map +1 -1
  22. package/lib/loaders/index.d.ts.map +1 -1
  23. package/lib/loaders/index.js +120 -87
  24. package/lib/loaders/index.js.map +1 -1
  25. package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.d.ts.map +1 -1
  26. package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js +3 -0
  27. package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js.map +1 -1
  28. package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts +4 -1
  29. package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts.map +1 -1
  30. package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts +4 -1
  31. package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts.map +1 -1
  32. package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js +2 -2
  33. package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js.map +1 -1
  34. package/lib/resolvers/mutations/accounts/loginWithWebAuthn.d.ts.map +1 -1
  35. package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js +4 -1
  36. package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js.map +1 -1
  37. package/lib/resolvers/mutations/accounts/resetPassword.d.ts.map +1 -1
  38. package/lib/resolvers/mutations/accounts/resetPassword.js +12 -43
  39. package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
  40. package/lib/resolvers/mutations/accounts/verifyWeb3Address.d.ts.map +1 -1
  41. package/lib/resolvers/mutations/accounts/verifyWeb3Address.js +3 -1
  42. package/lib/resolvers/mutations/accounts/verifyWeb3Address.js.map +1 -1
  43. package/lib/resolvers/mutations/countries/updateCountry.d.ts +1 -3
  44. package/lib/resolvers/mutations/countries/updateCountry.d.ts.map +1 -1
  45. package/lib/resolvers/mutations/countries/updateCountry.js +1 -5
  46. package/lib/resolvers/mutations/countries/updateCountry.js.map +1 -1
  47. package/lib/resolvers/mutations/orders/addCartDiscount.d.ts.map +1 -1
  48. package/lib/resolvers/mutations/orders/addCartDiscount.js +8 -3
  49. package/lib/resolvers/mutations/orders/addCartDiscount.js.map +1 -1
  50. package/lib/resolvers/mutations/orders/addCartProduct.d.ts.map +1 -1
  51. package/lib/resolvers/mutations/orders/addCartProduct.js +8 -3
  52. package/lib/resolvers/mutations/orders/addCartProduct.js.map +1 -1
  53. package/lib/resolvers/mutations/orders/addCartQuotation.d.ts.map +1 -1
  54. package/lib/resolvers/mutations/orders/addCartQuotation.js +8 -3
  55. package/lib/resolvers/mutations/orders/addCartQuotation.js.map +1 -1
  56. package/lib/resolvers/mutations/orders/addMultipleCartProducts.d.ts.map +1 -1
  57. package/lib/resolvers/mutations/orders/addMultipleCartProducts.js +8 -3
  58. package/lib/resolvers/mutations/orders/addMultipleCartProducts.js.map +1 -1
  59. package/lib/resolvers/mutations/orders/checkoutCart.d.ts.map +1 -1
  60. package/lib/resolvers/mutations/orders/checkoutCart.js +10 -5
  61. package/lib/resolvers/mutations/orders/checkoutCart.js.map +1 -1
  62. package/lib/resolvers/mutations/orders/emptyCart.d.ts.map +1 -1
  63. package/lib/resolvers/mutations/orders/emptyCart.js +8 -3
  64. package/lib/resolvers/mutations/orders/emptyCart.js.map +1 -1
  65. package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js +1 -1
  66. package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js.map +1 -1
  67. package/lib/resolvers/mutations/orders/updateCart.d.ts.map +1 -1
  68. package/lib/resolvers/mutations/orders/updateCart.js +8 -3
  69. package/lib/resolvers/mutations/orders/updateCart.js.map +1 -1
  70. package/lib/resolvers/queries/users/validateResetPasswordToken.js +2 -2
  71. package/lib/resolvers/queries/users/validateResetPasswordToken.js.map +1 -1
  72. package/lib/resolvers/type/delivery-provider-types.d.ts +0 -1
  73. package/lib/resolvers/type/delivery-provider-types.d.ts.map +1 -1
  74. package/lib/resolvers/type/delivery-provider-types.js +0 -2
  75. package/lib/resolvers/type/delivery-provider-types.js.map +1 -1
  76. package/lib/resolvers/type/filter/loaded-filter-types.d.ts.map +1 -1
  77. package/lib/resolvers/type/filter/loaded-filter-types.js +1 -2
  78. package/lib/resolvers/type/filter/loaded-filter-types.js.map +1 -1
  79. package/lib/resolvers/type/index.d.ts +37 -46
  80. package/lib/resolvers/type/index.d.ts.map +1 -1
  81. package/lib/resolvers/type/index.js +0 -4
  82. package/lib/resolvers/type/index.js.map +1 -1
  83. package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +2 -3
  84. package/lib/resolvers/type/order/order-delivery-discount-types.d.ts.map +1 -1
  85. package/lib/resolvers/type/order/order-delivery-discount-types.js +1 -3
  86. package/lib/resolvers/type/order/order-delivery-discount-types.js.map +1 -1
  87. package/lib/resolvers/type/order/order-global-discount-types.d.ts +2 -3
  88. package/lib/resolvers/type/order/order-global-discount-types.d.ts.map +1 -1
  89. package/lib/resolvers/type/order/order-global-discount-types.js +1 -3
  90. package/lib/resolvers/type/order/order-global-discount-types.js.map +1 -1
  91. package/lib/resolvers/type/order/order-item-discount-types.d.ts +2 -3
  92. package/lib/resolvers/type/order/order-item-discount-types.d.ts.map +1 -1
  93. package/lib/resolvers/type/order/order-item-discount-types.js +1 -3
  94. package/lib/resolvers/type/order/order-item-discount-types.js.map +1 -1
  95. package/lib/resolvers/type/order/order-item-types.d.ts.map +1 -1
  96. package/lib/resolvers/type/order/order-item-types.js +2 -11
  97. package/lib/resolvers/type/order/order-item-types.js.map +1 -1
  98. package/lib/resolvers/type/order/order-payment-discount-types.d.ts +2 -3
  99. package/lib/resolvers/type/order/order-payment-discount-types.d.ts.map +1 -1
  100. package/lib/resolvers/type/order/order-payment-discount-types.js +1 -7
  101. package/lib/resolvers/type/order/order-payment-discount-types.js.map +1 -1
  102. package/lib/resolvers/type/order/order-types.d.ts +1 -1
  103. package/lib/resolvers/type/order/order-types.d.ts.map +1 -1
  104. package/lib/resolvers/type/order/order-types.js +2 -7
  105. package/lib/resolvers/type/order/order-types.js.map +1 -1
  106. package/lib/resolvers/type/payment/payment-provider-types.d.ts +0 -1
  107. package/lib/resolvers/type/payment/payment-provider-types.d.ts.map +1 -1
  108. package/lib/resolvers/type/payment/payment-provider-types.js +0 -2
  109. package/lib/resolvers/type/payment/payment-provider-types.js.map +1 -1
  110. package/lib/resolvers/type/price-types.d.ts +0 -1
  111. package/lib/resolvers/type/price-types.d.ts.map +1 -1
  112. package/lib/resolvers/type/price-types.js.map +1 -1
  113. package/lib/resolvers/type/product/product-configurable-types.d.ts.map +1 -1
  114. package/lib/resolvers/type/product/product-configurable-types.js +5 -36
  115. package/lib/resolvers/type/product/product-configurable-types.js.map +1 -1
  116. package/lib/resolvers/type/product/product-discount.d.ts +2 -3
  117. package/lib/resolvers/type/product/product-discount.d.ts.map +1 -1
  118. package/lib/resolvers/type/product/product-discount.js +2 -4
  119. package/lib/resolvers/type/product/product-discount.js.map +1 -1
  120. package/lib/resolvers/type/product/product-plan-types.d.ts.map +1 -1
  121. package/lib/resolvers/type/product/product-plan-types.js +3 -7
  122. package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
  123. package/lib/resolvers/type/product/product-simple-types.d.ts +0 -2
  124. package/lib/resolvers/type/product/product-simple-types.d.ts.map +1 -1
  125. package/lib/resolvers/type/product/product-simple-types.js +13 -50
  126. package/lib/resolvers/type/product/product-simple-types.js.map +1 -1
  127. package/lib/resolvers/type/product/product-tokenized-types.d.ts +0 -1
  128. package/lib/resolvers/type/product/product-tokenized-types.d.ts.map +1 -1
  129. package/lib/resolvers/type/product/product-tokenized-types.js +5 -23
  130. package/lib/resolvers/type/product/product-tokenized-types.js.map +1 -1
  131. package/lib/resolvers/type/user-types.d.ts +21 -2
  132. package/lib/resolvers/type/user-types.d.ts.map +1 -1
  133. package/lib/resolvers/type/user-types.js +2 -2
  134. package/lib/resolvers/type/user-types.js.map +1 -1
  135. package/lib/resolvers/type/webauthn-credentials-types.d.ts +26 -9
  136. package/lib/resolvers/type/webauthn-credentials-types.d.ts.map +1 -1
  137. package/lib/resolvers/type/webauthn-credentials-types.js.map +1 -1
  138. package/lib/schema/inputTypes.d.ts.map +1 -1
  139. package/lib/schema/inputTypes.js +0 -1
  140. package/lib/schema/inputTypes.js.map +1 -1
  141. package/lib/schema/mutation.js +2 -2
  142. package/lib/schema/types/dispatch.d.ts.map +1 -1
  143. package/lib/schema/types/dispatch.js +0 -1
  144. package/lib/schema/types/dispatch.js.map +1 -1
  145. package/lib/schema/types/price.d.ts.map +1 -1
  146. package/lib/schema/types/price.js +0 -2
  147. package/lib/schema/types/price.js.map +1 -1
  148. package/lib/schema/types/stock.d.ts.map +1 -1
  149. package/lib/schema/types/stock.js +0 -1
  150. package/lib/schema/types/stock.js.map +1 -1
  151. package/package.json +54 -17
  152. package/src/api-index.ts +1 -1
  153. package/src/context.ts +4 -20
  154. package/src/errors.ts +2 -0
  155. package/src/express/createBulkImportMiddleware.ts +1 -2
  156. package/src/express/createERCMetadataMiddleware.ts +1 -1
  157. package/src/express/index.ts +1 -2
  158. package/src/fastify/index.ts +2 -3
  159. package/src/loaders/index.ts +136 -105
  160. package/src/resolvers/mutations/accounts/addWebAuthnCredentials.ts +3 -0
  161. package/src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts +2 -2
  162. package/src/resolvers/mutations/accounts/loginWithWebAuthn.ts +4 -1
  163. package/src/resolvers/mutations/accounts/resetPassword.ts +13 -46
  164. package/src/resolvers/mutations/accounts/verifyWeb3Address.ts +4 -1
  165. package/src/resolvers/mutations/countries/updateCountry.ts +2 -7
  166. package/src/resolvers/mutations/orders/addCartDiscount.ts +7 -2
  167. package/src/resolvers/mutations/orders/addCartProduct.ts +8 -2
  168. package/src/resolvers/mutations/orders/addCartQuotation.ts +7 -2
  169. package/src/resolvers/mutations/orders/addMultipleCartProducts.ts +7 -2
  170. package/src/resolvers/mutations/orders/checkoutCart.ts +9 -5
  171. package/src/resolvers/mutations/orders/emptyCart.ts +7 -3
  172. package/src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts +1 -1
  173. package/src/resolvers/mutations/orders/updateCart.ts +7 -3
  174. package/src/resolvers/queries/users/validateResetPasswordToken.ts +2 -2
  175. package/src/resolvers/type/delivery-provider-types.ts +0 -3
  176. package/src/resolvers/type/filter/loaded-filter-types.ts +1 -2
  177. package/src/resolvers/type/index.ts +0 -4
  178. package/src/resolvers/type/order/order-delivery-discount-types.ts +1 -3
  179. package/src/resolvers/type/order/order-global-discount-types.ts +2 -3
  180. package/src/resolvers/type/order/order-item-discount-types.ts +1 -3
  181. package/src/resolvers/type/order/order-item-types.ts +3 -11
  182. package/src/resolvers/type/order/order-payment-discount-types.ts +2 -9
  183. package/src/resolvers/type/order/order-types.ts +3 -7
  184. package/src/resolvers/type/payment/payment-provider-types.ts +0 -2
  185. package/src/resolvers/type/price-types.ts +0 -1
  186. package/src/resolvers/type/product/product-configurable-types.ts +5 -49
  187. package/src/resolvers/type/product/product-discount.ts +2 -4
  188. package/src/resolvers/type/product/product-plan-types.ts +3 -11
  189. package/src/resolvers/type/product/product-simple-types.ts +14 -75
  190. package/src/resolvers/type/product/product-tokenized-types.ts +5 -35
  191. package/src/resolvers/type/user-types.ts +28 -12
  192. package/src/resolvers/type/webauthn-credentials-types.ts +29 -17
  193. package/src/schema/inputTypes.ts +0 -1
  194. package/src/schema/mutation.ts +2 -2
  195. package/src/schema/types/dispatch.ts +0 -1
  196. package/src/schema/types/price.ts +0 -2
  197. package/src/schema/types/stock.ts +0 -1
  198. package/tests/api-index.test.ts +4 -4
  199. package/lib/express/passport/access-token-strategy.d.ts +0 -10
  200. package/lib/express/passport/access-token-strategy.d.ts.map +0 -1
  201. package/lib/express/passport/access-token-strategy.js +0 -33
  202. package/lib/express/passport/access-token-strategy.js.map +0 -1
  203. package/lib/express/passport/setup.d.ts +0 -4
  204. package/lib/express/passport/setup.d.ts.map +0 -1
  205. package/lib/express/passport/setup.js +0 -30
  206. package/lib/express/passport/setup.js.map +0 -1
  207. package/lib/resolvers/mutations/products/deleteUserProductReviews.d.ts +0 -5
  208. package/lib/resolvers/mutations/products/deleteUserProductReviews.d.ts.map +0 -1
  209. package/lib/resolvers/mutations/products/deleteUserProductReviews.js +0 -15
  210. package/lib/resolvers/mutations/products/deleteUserProductReviews.js.map +0 -1
  211. package/lib/resolvers/mutations/users/deleteUser.d.ts +0 -6
  212. package/lib/resolvers/mutations/users/deleteUser.d.ts.map +0 -1
  213. package/lib/resolvers/mutations/users/deleteUser.js +0 -15
  214. package/lib/resolvers/mutations/users/deleteUser.js.map +0 -1
  215. package/lib/resolvers/mutations/users/deleteUserProductReviews.d.ts +0 -5
  216. package/lib/resolvers/mutations/users/deleteUserProductReviews.d.ts.map +0 -1
  217. package/lib/resolvers/mutations/users/deleteUserProductReviews.js +0 -15
  218. package/lib/resolvers/mutations/users/deleteUserProductReviews.js.map +0 -1
  219. package/lib/resolvers/mutations/utils/getOrderCart.d.ts +0 -7
  220. package/lib/resolvers/mutations/utils/getOrderCart.d.ts.map +0 -1
  221. package/lib/resolvers/mutations/utils/getOrderCart.js +0 -17
  222. package/lib/resolvers/mutations/utils/getOrderCart.js.map +0 -1
  223. package/lib/resolvers/type/dispatch-types.d.ts +0 -15
  224. package/lib/resolvers/type/dispatch-types.d.ts.map +0 -1
  225. package/lib/resolvers/type/dispatch-types.js +0 -13
  226. package/lib/resolvers/type/dispatch-types.js.map +0 -1
  227. package/lib/resolvers/type/stock-types.d.ts +0 -14
  228. package/lib/resolvers/type/stock-types.d.ts.map +0 -1
  229. package/lib/resolvers/type/stock-types.js +0 -12
  230. package/lib/resolvers/type/stock-types.js.map +0 -1
  231. package/src/resolvers/mutations/utils/getOrderCart.ts +0 -20
  232. package/src/resolvers/type/dispatch-types.ts +0 -27
  233. package/src/resolvers/type/stock-types.ts +0 -25
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/schema/types/dispatch.ts"],"names":[],"mappings":";AAAA,wBAUE"}
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/schema/types/dispatch.ts"],"names":[],"mappings":";AAAA,wBASE"}
@@ -1,7 +1,6 @@
1
1
  export default [
2
2
  /* GraphQL */ `
3
3
  type Dispatch {
4
- _id: ID!
5
4
  deliveryProvider: DeliveryProvider
6
5
  warehousingProvider: WarehousingProvider
7
6
  shipping: DateTime
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/schema/types/dispatch.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;GAQb;CACF,CAAC"}
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/schema/types/dispatch.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;GAOb;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../src/schema/types/price.ts"],"names":[],"mappings":";AAAA,wBAgBE"}
1
+ {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../../src/schema/types/price.ts"],"names":[],"mappings":";AAAA,wBAcE"}
@@ -1,7 +1,6 @@
1
1
  export default [
2
2
  /* GraphQL */ `
3
3
  type Price @cacheControl(maxAge: 60) {
4
- _id: ID!
5
4
  isTaxable: Boolean!
6
5
  isNetPrice: Boolean!
7
6
  amount: Int!
@@ -9,7 +8,6 @@ export default [
9
8
  }
10
9
 
11
10
  type PriceRange @cacheControl(maxAge: 60) {
12
- _id: ID!
13
11
  minPrice: Price!
14
12
  maxPrice: Price!
15
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/schema/types/price.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;;;GAcb;CACF,CAAC"}
1
+ {"version":3,"file":"price.js","sourceRoot":"","sources":["../../../src/schema/types/price.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;GAYb;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"stock.d.ts","sourceRoot":"","sources":["../../../src/schema/types/stock.ts"],"names":[],"mappings":";AAAA,wBASE"}
1
+ {"version":3,"file":"stock.d.ts","sourceRoot":"","sources":["../../../src/schema/types/stock.ts"],"names":[],"mappings":";AAAA,wBAQE"}
@@ -1,7 +1,6 @@
1
1
  export default [
2
2
  /* GraphQL */ `
3
3
  type Stock {
4
- _id: ID!
5
4
  deliveryProvider: DeliveryProvider
6
5
  warehousingProvider: WarehousingProvider
7
6
  quantity: Int
@@ -1 +1 @@
1
- {"version":3,"file":"stock.js","sourceRoot":"","sources":["../../../src/schema/types/stock.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;GAOb;CACF,CAAC"}
1
+ {"version":3,"file":"stock.js","sourceRoot":"","sources":["../../../src/schema/types/stock.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;GAMb;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/api",
3
- "version": "3.0.0-rc1",
3
+ "version": "3.0.0-rc11",
4
4
  "main": "lib/api-index.js",
5
5
  "types": "lib/api-index.d.ts",
6
6
  "type": "module",
@@ -21,31 +21,61 @@
21
21
  "ecommerce",
22
22
  "api"
23
23
  ],
24
- "author": "Joël Meiller",
24
+ "authors": [
25
+ "Joël Meiller",
26
+ "Pascal Kaufmann"
27
+ ],
25
28
  "license": "EUPL-1.2",
26
29
  "bugs": {
27
30
  "url": "https://github.com/unchainedshop/unchained/issues"
28
31
  },
29
32
  "homepage": "https://github.com/unchainedshop/unchained#readme",
30
33
  "peerDependencies": {
31
- "graphql-yoga": "^5.10.6"
34
+ "@fastify/cookie": ">= 11.0 < 12",
35
+ "@fastify/session": ">= 11.0 < 12",
36
+ "@metamask/eth-sig-util": ">= 8.1 < 9",
37
+ "connect-mongo": ">= 5.1.0 < 6",
38
+ "express": ">= 5.0 < 6",
39
+ "express-session": ">= 1.18 < 2",
40
+ "fastify": ">= 5.2 < 6",
41
+ "graphql-yoga": ">= 5.9 < 6.0",
42
+ "passport": ">= 0.7 < 1"
32
43
  },
33
- "optionalDependencies": {
34
- "@fastify/cookie": "^11.0.1",
35
- "@fastify/session": "^11.0.2",
36
- "connect-mongo": "^5.1.0",
37
- "express": "^4.21.2",
38
- "express-session": "^1.18.1",
39
- "fastify": "^5.2.0",
40
- "passport": "^0.7.0"
44
+ "peerDependenciesMeta": {
45
+ "graphql-yoga": {
46
+ "optional": false
47
+ },
48
+ "connect-mongo": {
49
+ "optional": false
50
+ },
51
+ "@metamask/eth-sig-util": {
52
+ "optional": true
53
+ },
54
+ "@fastify/cookie": {
55
+ "optional": true
56
+ },
57
+ "@fastify/session": {
58
+ "optional": true
59
+ },
60
+ "express": {
61
+ "optional": true
62
+ },
63
+ "express-session": {
64
+ "optional": true
65
+ },
66
+ "fastify": {
67
+ "optional": true
68
+ },
69
+ "passport": {
70
+ "optional": true
71
+ }
41
72
  },
42
73
  "dependencies": {
43
- "@metamask/eth-sig-util": "^8.1.1",
44
- "@unchainedshop/core": "^3.0.0-rc1",
45
- "@unchainedshop/events": "^3.0.0-rc1",
46
- "@unchainedshop/logger": "^3.0.0-rc1",
47
- "@unchainedshop/roles": "^3.0.0-rc1",
48
- "@unchainedshop/utils": "^3.0.0-rc1",
74
+ "@unchainedshop/core": "^3.0.0-rc11",
75
+ "@unchainedshop/events": "^3.0.0-rc11",
76
+ "@unchainedshop/logger": "^3.0.0-rc11",
77
+ "@unchainedshop/roles": "^3.0.0-rc11",
78
+ "@unchainedshop/utils": "^3.0.0-rc11",
49
79
  "accounting": "0.4.1",
50
80
  "dataloader": "^2.2.3",
51
81
  "expiry-map": "^2.0.0",
@@ -54,7 +84,14 @@
54
84
  "p-memoize": "^7.1.1"
55
85
  },
56
86
  "devDependencies": {
87
+ "@fastify/cookie": "^11.0.1",
88
+ "@fastify/session": "^11.0.2",
89
+ "@metamask/eth-sig-util": "^8.1.2",
90
+ "@types/express": "^5.0.0",
57
91
  "@types/node": "^22.10.2",
92
+ "express": "^5.0.1",
93
+ "express-session": "^1.18.1",
94
+ "fastify": "^5.2.0",
58
95
  "jest": "^29.7.0",
59
96
  "passport": "^0.7.0",
60
97
  "ts-jest": "^29.2.5",
package/src/api-index.ts CHANGED
@@ -10,8 +10,8 @@ import { UnchainedCore } from '@unchainedshop/core';
10
10
  export * from './context.js';
11
11
  export * from './locale-context.js';
12
12
  export * from './loaders/index.js';
13
+ export * from './errors.js';
13
14
  export * as acl from './acl.js';
14
- export * as errors from './errors.js';
15
15
  export * as roles from './roles/index.js';
16
16
  export { createContextResolver, getCurrentContextResolver, setCurrentContextResolver };
17
17
 
package/src/context.ts CHANGED
@@ -1,5 +1,3 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
1
  import { UnchainedCore } from '@unchainedshop/core';
4
2
  import instantiateLoaders, { UnchainedLoaders } from './loaders/index.js';
5
3
  import { getLocaleContext, UnchainedLocaleContext } from './locale-context.js';
@@ -58,24 +56,10 @@ export type UnchainedContextResolver = (
58
56
  },
59
57
  ) => Promise<Context>;
60
58
 
61
- export const loadJSON = (filename) => {
62
- try {
63
- const base = typeof __filename !== 'undefined' && __filename;
64
- if (!base)
65
- return {
66
- version: process.env.npm_package_version,
67
- };
68
- const absolutePath = path.resolve(path.dirname(base), filename);
69
- const data = JSON.parse(fs.readFileSync(absolutePath, 'utf-8'));
70
- return data;
71
- } catch {
72
- return null;
73
- }
74
- };
75
-
76
- const packageJson = loadJSON('../package.json');
77
-
78
- const { UNCHAINED_API_VERSION = packageJson?.version || '2.x' } = process.env;
59
+ const { default: packageJson } = await import(`${import.meta.dirname}/../package.json`, {
60
+ with: { type: 'json' },
61
+ });
62
+ const { UNCHAINED_API_VERSION = packageJson?.version || '3.x' } = process.env;
79
63
 
80
64
  export const createContextResolver =
81
65
  (
package/src/errors.ts CHANGED
@@ -79,6 +79,8 @@ export const UserWebAuthnCredentialsNotFoundError = createError(
79
79
  'User WebAuth Credentials not found',
80
80
  );
81
81
 
82
+ export const WebAuthnDisabledError = createError('WebAuthnDisabledError', 'WebAuthn disabled');
83
+
82
84
  export const UserWeb3AddressNotFoundError = createError(
83
85
  'UserWeb3AddressNotFoundError',
84
86
  'Web3 Account not found for User',
@@ -1,7 +1,6 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
2
  import { checkAction } from '../acl.js';
3
3
  import { actions } from '../roles/index.js';
4
- import { IncomingMessage } from 'http';
5
4
  import { Context } from '../context.js';
6
5
 
7
6
  const logger = createLogger('unchained:bulk-import');
@@ -19,7 +18,7 @@ const methodWrongHandler = (res) => () => {
19
18
  };
20
19
 
21
20
  export default async function bulkImportMiddleware(
22
- req: IncomingMessage & { query?: any; unchainedContext: Context },
21
+ req: Request & { query?: any; unchainedContext: Context },
23
22
  res,
24
23
  ) {
25
24
  try {
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { Context } from '../context.js';
4
4
  import { Request, RequestHandler } from 'express';
@@ -11,9 +11,8 @@ import { UnchainedCore } from '@unchainedshop/core';
11
11
  import { emit } from '@unchainedshop/events';
12
12
  import { API_EVENTS } from '../events.js';
13
13
  import { User } from '@unchainedshop/core-users';
14
- import { IncomingMessage } from 'http';
15
14
 
16
- const resolveUserRemoteAddress = (req: IncomingMessage) => {
15
+ const resolveUserRemoteAddress = (req: e.Request) => {
17
16
  const remoteAddress =
18
17
  (req.headers['x-real-ip'] as string) ||
19
18
  (req.headers['x-forwarded-for'] as string) ||
@@ -8,12 +8,11 @@ import { UnchainedCore } from '@unchainedshop/core';
8
8
  import { emit } from '@unchainedshop/events';
9
9
  import { API_EVENTS } from '../events.js';
10
10
  import { User } from '@unchainedshop/core-users';
11
- import { IncomingMessage } from 'http';
12
11
  import fastifySession from '@fastify/session';
13
12
  import fastifyCookie from '@fastify/cookie';
14
- import { FastifyInstance } from 'fastify';
13
+ import { FastifyInstance, FastifyRequest } from 'fastify';
15
14
 
16
- const resolveUserRemoteAddress = (req: IncomingMessage) => {
15
+ const resolveUserRemoteAddress = (req: FastifyRequest) => {
17
16
  const remoteAddress =
18
17
  (req.headers['x-real-ip'] as string) ||
19
18
  (req.headers['x-forwarded-for'] as string) ||
@@ -12,6 +12,7 @@ import {
12
12
  AssortmentMediaText,
13
13
  } from '@unchainedshop/core-assortments';
14
14
  import { File } from '@unchainedshop/core-files';
15
+
15
16
  export interface UnchainedLoaders {
16
17
  loaders: {
17
18
  productLoader: InstanceType<typeof DataLoader<{ productId: string }, Product>>;
@@ -54,28 +55,16 @@ export interface UnchainedLoaders {
54
55
  };
55
56
  }
56
57
 
57
- function getLocaleStrings(localeObj: Intl.Locale) {
58
- return [localeObj.baseName, localeObj.language, systemLocale.baseName, systemLocale.language];
59
- }
60
-
61
- function findMatchingText(texts, localeStrings) {
62
- return localeStrings.reduce((acc, localeString) => {
63
- if (acc) return acc;
64
- return texts.find((p) => p.locale.toLowerCase() === localeString.toLowerCase());
65
- }, null);
66
- }
67
-
68
- function getFilteredQueries({ queries, texts, filterFn }) {
69
- return queries.map(({ locale, ...queryParams }) => {
70
- const localeObj = new Intl.Locale(locale);
71
-
72
- const filteredTexts = texts.filter(filterFn(queryParams));
73
- if (!filteredTexts.length) return null;
74
-
75
- const localeStrings = getLocaleStrings(localeObj);
76
- const filterText = findMatchingText(filteredTexts, localeStrings);
77
- return filterText || filteredTexts[0];
78
- });
58
+ function getLocaleStrings(locale: string) {
59
+ const localeObj = new Intl.Locale(locale);
60
+ return [
61
+ ...new Set([
62
+ localeObj.baseName.toLowerCase(),
63
+ localeObj.language.toLowerCase(),
64
+ systemLocale.baseName.toLowerCase(),
65
+ systemLocale.language.toLowerCase(),
66
+ ]),
67
+ ];
79
68
  }
80
69
 
81
70
  const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['loaders']> => {
@@ -89,12 +78,11 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
89
78
  includeLeaves: true,
90
79
  });
91
80
 
92
- return queries.map(({ assortmentId }) => {
93
- return assortments.find((assortment) => {
94
- if (assortment._id !== assortmentId) return false;
95
- return true;
96
- });
97
- });
81
+ const assortmentMap = {};
82
+ for (const assortment of assortments) {
83
+ assortmentMap[assortment._id] = assortment;
84
+ }
85
+ return queries.map((q) => assortmentMap[q.assortmentId]);
98
86
  }),
99
87
 
100
88
  assortmentTextLoader: new DataLoader(async (queries) => {
@@ -109,12 +97,18 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
109
97
  },
110
98
  );
111
99
 
112
- const filterFn =
113
- ({ assortmentId }) =>
114
- (text) =>
115
- text.assortmentId === assortmentId;
116
-
117
- return getFilteredQueries({ queries, texts, filterFn });
100
+ const queryLocales = [...new Set(queries.map((q) => q.locale.toLowerCase()))];
101
+ const textsMap = {};
102
+ const localeMap = Object.fromEntries(
103
+ queryLocales.flatMap((queryLocale) => {
104
+ return getLocaleStrings(queryLocale).map((locale) => [locale, queryLocale]);
105
+ }),
106
+ );
107
+ for (const text of texts) {
108
+ const locale = localeMap[text.locale.toLowerCase()];
109
+ textsMap[`${locale}:${text.assortmentId}`] = text;
110
+ }
111
+ return queries.map((q) => textsMap[`${q.locale.toLowerCase()}:${q.assortmentId}`]);
118
112
  }),
119
113
 
120
114
  assortmentMediaTextLoader: new DataLoader(async (queries) => {
@@ -129,12 +123,18 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
129
123
  },
130
124
  );
131
125
 
132
- const filterFn =
133
- ({ assortmentMediaId }) =>
134
- (text) =>
135
- text.assortmentMediaId === assortmentMediaId;
136
-
137
- return getFilteredQueries({ queries, texts, filterFn });
126
+ const queryLocales = [...new Set(queries.map((q) => q.locale.toLowerCase()))];
127
+ const textsMap = {};
128
+ const localeMap = Object.fromEntries(
129
+ queryLocales.flatMap((queryLocale) => {
130
+ return getLocaleStrings(queryLocale).map((locale) => [locale, queryLocale]);
131
+ }),
132
+ );
133
+ for (const text of texts) {
134
+ const locale = localeMap[text.locale.toLowerCase()];
135
+ textsMap[`${locale}:${text.assortmentMediaId}`] = text;
136
+ }
137
+ return queries.map((q) => textsMap[`${q.locale.toLowerCase()}:${q.assortmentMediaId}`]);
138
138
  }),
139
139
 
140
140
  assortmentMediasLoader: new DataLoader(async (queries) => {
@@ -143,11 +143,15 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
143
143
  assortmentId: { $in: assortmentIds },
144
144
  });
145
145
 
146
- return queries.map((q) => {
147
- return assortmentMediaItems.filter((i) => {
148
- return i.assortmentId === q.assortmentId;
149
- });
150
- });
146
+ const assortmentMediaMap = {};
147
+ for (const assortmentMedia of assortmentMediaItems) {
148
+ if (!assortmentMediaMap[assortmentMedia.assortmentId]) {
149
+ assortmentMediaMap[assortmentMedia.assortmentId] = [assortmentMedia];
150
+ } else {
151
+ assortmentMediaMap[assortmentMedia.assortmentId].push(assortmentMedia);
152
+ }
153
+ }
154
+ return queries.map((q) => assortmentMediaMap[q.assortmentId] || []);
151
155
  }),
152
156
 
153
157
  assortmentLinkLoader: new DataLoader(async (queries) => {
@@ -157,10 +161,11 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
157
161
  parentAssortmentIds,
158
162
  });
159
163
 
160
- return queries.map(({ parentAssortmentId, childAssortmentId }) => {
164
+ // TODO: Optimize
165
+ return queries.map((q) => {
161
166
  return links.find((link) => {
162
- if (link.parentAssortmentId !== parentAssortmentId) return false;
163
- if (childAssortmentId && link.childAssortmentId !== childAssortmentId) return false;
167
+ if (link.parentAssortmentId !== q.parentAssortmentId) return false;
168
+ if (q.childAssortmentId && link.childAssortmentId !== q.childAssortmentId) return false;
164
169
  return true;
165
170
  });
166
171
  });
@@ -183,16 +188,17 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
183
188
  assortmentIds,
184
189
  }));
185
190
 
186
- return queries.map(({ parentAssortmentId, assortmentId }) => {
187
- if (parentAssortmentId) {
191
+ // TODO: Optimize
192
+ return queries.map((q) => {
193
+ if (q.parentAssortmentId) {
188
194
  return linksByParentAssortmentId.filter(
189
- (link) => link.parentAssortmentId === parentAssortmentId,
195
+ (link) => link.parentAssortmentId === q.parentAssortmentId,
190
196
  );
191
197
  }
192
- if (assortmentId) {
198
+ if (q.assortmentId) {
193
199
  return linksByAssortmentId.filter(
194
200
  (link) =>
195
- link.parentAssortmentId === assortmentId || link.childAssortmentId === assortmentId,
201
+ link.parentAssortmentId === q.assortmentId || link.childAssortmentId === q.assortmentId,
196
202
  );
197
203
  }
198
204
  return [];
@@ -206,10 +212,11 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
206
212
  assortmentIds,
207
213
  });
208
214
 
209
- return queries.map(({ assortmentId, productId }) => {
215
+ // TODO: Optimize
216
+ return queries.map((q) => {
210
217
  return assortmentProducts.find((assortmentProduct) => {
211
- if (assortmentProduct.assortmentId !== assortmentId) return false;
212
- if (assortmentProduct.productId !== productId) return false;
218
+ if (assortmentProduct.assortmentId !== q.assortmentId) return false;
219
+ if (assortmentProduct.productId !== q.productId) return false;
213
220
  return true;
214
221
  });
215
222
  });
@@ -223,12 +230,12 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
223
230
  includeInactive: true,
224
231
  });
225
232
 
226
- return queries.map(({ filterId }) => {
227
- return filters.find((product) => {
228
- if (product._id !== filterId) return false;
229
- return true;
230
- });
231
- });
233
+ const filterMap = {};
234
+ for (const filter of filters) {
235
+ filterMap[filter._id] = filter;
236
+ }
237
+
238
+ return queries.map((q) => filterMap[q.filterId]);
232
239
  }),
233
240
 
234
241
  filterTextLoader: new DataLoader(async (queries) => {
@@ -243,11 +250,20 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
243
250
  },
244
251
  );
245
252
 
246
- const filterFn =
247
- ({ filterId, filterOptionValue }) =>
248
- (text) =>
249
- text.filterId === filterId && text.filterOptionValue === filterOptionValue;
250
- return getFilteredQueries({ queries, texts, filterFn });
253
+ const queryLocales = [...new Set(queries.map((q) => q.locale.toLowerCase()))];
254
+ const textsMap = {};
255
+ const localeMap = Object.fromEntries(
256
+ queryLocales.flatMap((queryLocale) => {
257
+ return getLocaleStrings(queryLocale).map((locale) => [locale, queryLocale]);
258
+ }),
259
+ );
260
+ for (const text of texts) {
261
+ const locale = localeMap[text.locale.toLowerCase()];
262
+ textsMap[`${locale}:${text.filterId}:${text.filterOptionValue}`] = text;
263
+ }
264
+ return queries.map(
265
+ (q) => textsMap[`${q.locale.toLowerCase()}:${q.filterId}:${q.filterOptionValue}`],
266
+ );
251
267
  }),
252
268
 
253
269
  productLoader: new DataLoader(async (queries) => {
@@ -260,12 +276,12 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
260
276
  },
261
277
  });
262
278
 
263
- return queries.map(({ productId }) => {
264
- return products.find((product) => {
265
- if (product._id !== productId) return false;
266
- return true;
267
- });
268
- });
279
+ const productMap = {};
280
+ for (const product of products) {
281
+ productMap[product._id] = product;
282
+ }
283
+
284
+ return queries.map((q) => productMap[q.productId]);
269
285
  }),
270
286
 
271
287
  productLoaderBySKU: new DataLoader(async (queries) => {
@@ -278,17 +294,16 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
278
294
  },
279
295
  });
280
296
 
281
- return queries.map(({ sku }) => {
282
- return products.find((product) => {
283
- if (product.warehousing?.sku !== sku) return false;
284
- return true;
285
- });
286
- });
297
+ const productMap = {};
298
+ for (const product of products) {
299
+ productMap[product.warehousing!.sku!] = product;
300
+ }
301
+
302
+ return queries.map((q) => productMap[q.sku]);
287
303
  }),
288
304
 
289
305
  productTextLoader: new DataLoader(async (queries) => {
290
- const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
291
-
306
+ const productIds = [...new Set(queries.map((q) => q.productId))].filter(Boolean);
292
307
  const texts = await unchainedAPI.modules.products.texts.findTexts(
293
308
  { productId: { $in: productIds } },
294
309
  {
@@ -297,13 +312,18 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
297
312
  },
298
313
  },
299
314
  );
300
-
301
- const filterFn =
302
- ({ productId }) =>
303
- (text) =>
304
- text.productId === productId;
305
-
306
- return getFilteredQueries({ queries, texts, filterFn });
315
+ const queryLocales = [...new Set(queries.map((q) => q.locale.toLowerCase()))];
316
+ const textsMap = {};
317
+ const localeMap = Object.fromEntries(
318
+ queryLocales.flatMap((queryLocale) => {
319
+ return getLocaleStrings(queryLocale).map((locale) => [locale, queryLocale]);
320
+ }),
321
+ );
322
+ for (const text of texts) {
323
+ const locale = localeMap[text.locale.toLowerCase()];
324
+ textsMap[`${locale}:${text.productId}`] = text;
325
+ }
326
+ return queries.map((q) => textsMap[`${q.locale.toLowerCase()}:${q.productId}`]);
307
327
  }),
308
328
 
309
329
  productMediaTextLoader: new DataLoader(async (queries) => {
@@ -318,12 +338,18 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
318
338
  },
319
339
  );
320
340
 
321
- const filterFn =
322
- ({ productMediaId }) =>
323
- (text) =>
324
- text.productMediaId === productMediaId;
325
-
326
- return getFilteredQueries({ queries, texts, filterFn });
341
+ const queryLocales = [...new Set(queries.map((q) => q.locale.toLowerCase()))];
342
+ const textsMap = {};
343
+ const localeMap = Object.fromEntries(
344
+ queryLocales.flatMap((queryLocale) => {
345
+ return getLocaleStrings(queryLocale).map((locale) => [locale, queryLocale]);
346
+ }),
347
+ );
348
+ for (const text of texts) {
349
+ const locale = localeMap[text.locale.toLowerCase()];
350
+ textsMap[`${locale}:${text.productMediaId}`] = text;
351
+ }
352
+ return queries.map((q) => textsMap[`${q.locale.toLowerCase()}:${q.productMediaId}`]);
327
353
  }),
328
354
 
329
355
  productMediasLoader: new DataLoader(async (queries) => {
@@ -331,11 +357,16 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
331
357
  const productMediaItems = await unchainedAPI.modules.products.media.findProductMedias({
332
358
  productId: { $in: productIds },
333
359
  });
334
- return queries.map((q) => {
335
- return productMediaItems.filter((i) => {
336
- return i.productId === q.productId;
337
- });
338
- });
360
+
361
+ const productMediaMap = {};
362
+ for (const productMedia of productMediaItems) {
363
+ if (!productMediaMap[productMedia.productId]) {
364
+ productMediaMap[productMedia.productId] = [productMedia];
365
+ } else {
366
+ productMediaMap[productMedia.productId].push(productMedia);
367
+ }
368
+ }
369
+ return queries.map((q) => productMediaMap[q.productId] || []);
339
370
  }),
340
371
 
341
372
  fileLoader: new DataLoader(async (queries) => {
@@ -345,12 +376,12 @@ const loaders = async (unchainedAPI: UnchainedCore): Promise<UnchainedLoaders['l
345
376
  _id: { $in: fileIds },
346
377
  });
347
378
 
348
- return queries.map(({ fileId }) => {
349
- return files.find((file) => {
350
- if (file._id !== fileId) return false;
351
- return true;
352
- });
353
- });
379
+ const fileMap = {};
380
+ for (const file of files) {
381
+ fileMap[file._id] = file;
382
+ }
383
+
384
+ return queries.map((q) => fileMap[q.fileId]);
354
385
  }),
355
386
  };
356
387
  };
@@ -1,5 +1,6 @@
1
1
  import { log } from '@unchainedshop/logger';
2
2
  import { Context } from '../../../context.js';
3
+ import { WebAuthnDisabledError } from '../../../errors.js';
3
4
 
4
5
  export default async function addWebAuthnCredentials(
5
6
  root: never,
@@ -15,6 +16,8 @@ export default async function addWebAuthnCredentials(
15
16
  credentials,
16
17
  );
17
18
 
19
+ if (!webAuthnService) throw new WebAuthnDisabledError();
20
+
18
21
  return modules.users.updateUser(
19
22
  { _id: userId },
20
23
  {