@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.
- package/lib/api-index.d.ts +1 -1
- package/lib/api-index.d.ts.map +1 -1
- package/lib/api-index.js +1 -1
- package/lib/api-index.js.map +1 -1
- package/lib/context.d.ts +0 -1
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js +4 -19
- package/lib/context.js.map +1 -1
- package/lib/errors.d.ts +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -0
- package/lib/errors.js.map +1 -1
- package/lib/express/createBulkImportMiddleware.d.ts +1 -2
- package/lib/express/createBulkImportMiddleware.d.ts.map +1 -1
- package/lib/express/createBulkImportMiddleware.js.map +1 -1
- package/lib/express/createERCMetadataMiddleware.js +1 -1
- package/lib/express/createERCMetadataMiddleware.js.map +1 -1
- package/lib/express/index.d.ts.map +1 -1
- package/lib/express/index.js.map +1 -1
- package/lib/fastify/index.d.ts.map +1 -1
- package/lib/fastify/index.js.map +1 -1
- package/lib/loaders/index.d.ts.map +1 -1
- package/lib/loaders/index.js +120 -87
- package/lib/loaders/index.js.map +1 -1
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js +3 -0
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js.map +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts +4 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts +4 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js +2 -2
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js +4 -1
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js +12 -43
- package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js +3 -1
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js.map +1 -1
- package/lib/resolvers/mutations/countries/updateCountry.d.ts +1 -3
- package/lib/resolvers/mutations/countries/updateCountry.d.ts.map +1 -1
- package/lib/resolvers/mutations/countries/updateCountry.js +1 -5
- package/lib/resolvers/mutations/countries/updateCountry.js.map +1 -1
- package/lib/resolvers/mutations/orders/addCartDiscount.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addCartDiscount.js +8 -3
- package/lib/resolvers/mutations/orders/addCartDiscount.js.map +1 -1
- package/lib/resolvers/mutations/orders/addCartProduct.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addCartProduct.js +8 -3
- package/lib/resolvers/mutations/orders/addCartProduct.js.map +1 -1
- package/lib/resolvers/mutations/orders/addCartQuotation.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addCartQuotation.js +8 -3
- package/lib/resolvers/mutations/orders/addCartQuotation.js.map +1 -1
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.js +8 -3
- package/lib/resolvers/mutations/orders/addMultipleCartProducts.js.map +1 -1
- package/lib/resolvers/mutations/orders/checkoutCart.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/checkoutCart.js +10 -5
- package/lib/resolvers/mutations/orders/checkoutCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/emptyCart.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/emptyCart.js +8 -3
- package/lib/resolvers/mutations/orders/emptyCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js +1 -1
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js.map +1 -1
- package/lib/resolvers/mutations/orders/updateCart.d.ts.map +1 -1
- package/lib/resolvers/mutations/orders/updateCart.js +8 -3
- package/lib/resolvers/mutations/orders/updateCart.js.map +1 -1
- package/lib/resolvers/queries/users/validateResetPasswordToken.js +2 -2
- package/lib/resolvers/queries/users/validateResetPasswordToken.js.map +1 -1
- package/lib/resolvers/type/delivery-provider-types.d.ts +0 -1
- package/lib/resolvers/type/delivery-provider-types.d.ts.map +1 -1
- package/lib/resolvers/type/delivery-provider-types.js +0 -2
- package/lib/resolvers/type/delivery-provider-types.js.map +1 -1
- package/lib/resolvers/type/filter/loaded-filter-types.d.ts.map +1 -1
- package/lib/resolvers/type/filter/loaded-filter-types.js +1 -2
- package/lib/resolvers/type/filter/loaded-filter-types.js.map +1 -1
- package/lib/resolvers/type/index.d.ts +37 -46
- package/lib/resolvers/type/index.d.ts.map +1 -1
- package/lib/resolvers/type/index.js +0 -4
- package/lib/resolvers/type/index.js.map +1 -1
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +2 -3
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-delivery-discount-types.js +1 -3
- package/lib/resolvers/type/order/order-delivery-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts +2 -3
- package/lib/resolvers/type/order/order-global-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.js +1 -3
- package/lib/resolvers/type/order/order-global-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts +2 -3
- package/lib/resolvers/type/order/order-item-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.js +1 -3
- package/lib/resolvers/type/order/order-item-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-item-types.js +2 -11
- package/lib/resolvers/type/order/order-item-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts +2 -3
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.js +1 -7
- package/lib/resolvers/type/order/order-payment-discount-types.js.map +1 -1
- package/lib/resolvers/type/order/order-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-types.d.ts.map +1 -1
- package/lib/resolvers/type/order/order-types.js +2 -7
- package/lib/resolvers/type/order/order-types.js.map +1 -1
- package/lib/resolvers/type/payment/payment-provider-types.d.ts +0 -1
- package/lib/resolvers/type/payment/payment-provider-types.d.ts.map +1 -1
- package/lib/resolvers/type/payment/payment-provider-types.js +0 -2
- package/lib/resolvers/type/payment/payment-provider-types.js.map +1 -1
- package/lib/resolvers/type/price-types.d.ts +0 -1
- package/lib/resolvers/type/price-types.d.ts.map +1 -1
- package/lib/resolvers/type/price-types.js.map +1 -1
- package/lib/resolvers/type/product/product-configurable-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-configurable-types.js +5 -36
- package/lib/resolvers/type/product/product-configurable-types.js.map +1 -1
- package/lib/resolvers/type/product/product-discount.d.ts +2 -3
- package/lib/resolvers/type/product/product-discount.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-discount.js +2 -4
- package/lib/resolvers/type/product/product-discount.js.map +1 -1
- package/lib/resolvers/type/product/product-plan-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-plan-types.js +3 -7
- package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
- package/lib/resolvers/type/product/product-simple-types.d.ts +0 -2
- package/lib/resolvers/type/product/product-simple-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-simple-types.js +13 -50
- package/lib/resolvers/type/product/product-simple-types.js.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts +0 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.js +5 -23
- package/lib/resolvers/type/product/product-tokenized-types.js.map +1 -1
- package/lib/resolvers/type/user-types.d.ts +21 -2
- package/lib/resolvers/type/user-types.d.ts.map +1 -1
- package/lib/resolvers/type/user-types.js +2 -2
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +26 -9
- package/lib/resolvers/type/webauthn-credentials-types.d.ts.map +1 -1
- package/lib/resolvers/type/webauthn-credentials-types.js.map +1 -1
- package/lib/schema/inputTypes.d.ts.map +1 -1
- package/lib/schema/inputTypes.js +0 -1
- package/lib/schema/inputTypes.js.map +1 -1
- package/lib/schema/mutation.js +2 -2
- package/lib/schema/types/dispatch.d.ts.map +1 -1
- package/lib/schema/types/dispatch.js +0 -1
- package/lib/schema/types/dispatch.js.map +1 -1
- package/lib/schema/types/price.d.ts.map +1 -1
- package/lib/schema/types/price.js +0 -2
- package/lib/schema/types/price.js.map +1 -1
- package/lib/schema/types/stock.d.ts.map +1 -1
- package/lib/schema/types/stock.js +0 -1
- package/lib/schema/types/stock.js.map +1 -1
- package/package.json +54 -17
- package/src/api-index.ts +1 -1
- package/src/context.ts +4 -20
- package/src/errors.ts +2 -0
- package/src/express/createBulkImportMiddleware.ts +1 -2
- package/src/express/createERCMetadataMiddleware.ts +1 -1
- package/src/express/index.ts +1 -2
- package/src/fastify/index.ts +2 -3
- package/src/loaders/index.ts +136 -105
- package/src/resolvers/mutations/accounts/addWebAuthnCredentials.ts +3 -0
- package/src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts +2 -2
- package/src/resolvers/mutations/accounts/loginWithWebAuthn.ts +4 -1
- package/src/resolvers/mutations/accounts/resetPassword.ts +13 -46
- package/src/resolvers/mutations/accounts/verifyWeb3Address.ts +4 -1
- package/src/resolvers/mutations/countries/updateCountry.ts +2 -7
- package/src/resolvers/mutations/orders/addCartDiscount.ts +7 -2
- package/src/resolvers/mutations/orders/addCartProduct.ts +8 -2
- package/src/resolvers/mutations/orders/addCartQuotation.ts +7 -2
- package/src/resolvers/mutations/orders/addMultipleCartProducts.ts +7 -2
- package/src/resolvers/mutations/orders/checkoutCart.ts +9 -5
- package/src/resolvers/mutations/orders/emptyCart.ts +7 -3
- package/src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts +1 -1
- package/src/resolvers/mutations/orders/updateCart.ts +7 -3
- package/src/resolvers/queries/users/validateResetPasswordToken.ts +2 -2
- package/src/resolvers/type/delivery-provider-types.ts +0 -3
- package/src/resolvers/type/filter/loaded-filter-types.ts +1 -2
- package/src/resolvers/type/index.ts +0 -4
- package/src/resolvers/type/order/order-delivery-discount-types.ts +1 -3
- package/src/resolvers/type/order/order-global-discount-types.ts +2 -3
- package/src/resolvers/type/order/order-item-discount-types.ts +1 -3
- package/src/resolvers/type/order/order-item-types.ts +3 -11
- package/src/resolvers/type/order/order-payment-discount-types.ts +2 -9
- package/src/resolvers/type/order/order-types.ts +3 -7
- package/src/resolvers/type/payment/payment-provider-types.ts +0 -2
- package/src/resolvers/type/price-types.ts +0 -1
- package/src/resolvers/type/product/product-configurable-types.ts +5 -49
- package/src/resolvers/type/product/product-discount.ts +2 -4
- package/src/resolvers/type/product/product-plan-types.ts +3 -11
- package/src/resolvers/type/product/product-simple-types.ts +14 -75
- package/src/resolvers/type/product/product-tokenized-types.ts +5 -35
- package/src/resolvers/type/user-types.ts +28 -12
- package/src/resolvers/type/webauthn-credentials-types.ts +29 -17
- package/src/schema/inputTypes.ts +0 -1
- package/src/schema/mutation.ts +2 -2
- package/src/schema/types/dispatch.ts +0 -1
- package/src/schema/types/price.ts +0 -2
- package/src/schema/types/stock.ts +0 -1
- package/tests/api-index.test.ts +4 -4
- package/lib/express/passport/access-token-strategy.d.ts +0 -10
- package/lib/express/passport/access-token-strategy.d.ts.map +0 -1
- package/lib/express/passport/access-token-strategy.js +0 -33
- package/lib/express/passport/access-token-strategy.js.map +0 -1
- package/lib/express/passport/setup.d.ts +0 -4
- package/lib/express/passport/setup.d.ts.map +0 -1
- package/lib/express/passport/setup.js +0 -30
- package/lib/express/passport/setup.js.map +0 -1
- package/lib/resolvers/mutations/products/deleteUserProductReviews.d.ts +0 -5
- package/lib/resolvers/mutations/products/deleteUserProductReviews.d.ts.map +0 -1
- package/lib/resolvers/mutations/products/deleteUserProductReviews.js +0 -15
- package/lib/resolvers/mutations/products/deleteUserProductReviews.js.map +0 -1
- package/lib/resolvers/mutations/users/deleteUser.d.ts +0 -6
- package/lib/resolvers/mutations/users/deleteUser.d.ts.map +0 -1
- package/lib/resolvers/mutations/users/deleteUser.js +0 -15
- package/lib/resolvers/mutations/users/deleteUser.js.map +0 -1
- package/lib/resolvers/mutations/users/deleteUserProductReviews.d.ts +0 -5
- package/lib/resolvers/mutations/users/deleteUserProductReviews.d.ts.map +0 -1
- package/lib/resolvers/mutations/users/deleteUserProductReviews.js +0 -15
- package/lib/resolvers/mutations/users/deleteUserProductReviews.js.map +0 -1
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts +0 -7
- package/lib/resolvers/mutations/utils/getOrderCart.d.ts.map +0 -1
- package/lib/resolvers/mutations/utils/getOrderCart.js +0 -17
- package/lib/resolvers/mutations/utils/getOrderCart.js.map +0 -1
- package/lib/resolvers/type/dispatch-types.d.ts +0 -15
- package/lib/resolvers/type/dispatch-types.d.ts.map +0 -1
- package/lib/resolvers/type/dispatch-types.js +0 -13
- package/lib/resolvers/type/dispatch-types.js.map +0 -1
- package/lib/resolvers/type/stock-types.d.ts +0 -14
- package/lib/resolvers/type/stock-types.d.ts.map +0 -1
- package/lib/resolvers/type/stock-types.js +0 -12
- package/lib/resolvers/type/stock-types.js.map +0 -1
- package/src/resolvers/mutations/utils/getOrderCart.ts +0 -20
- package/src/resolvers/type/dispatch-types.ts +0 -27
- 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,
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/schema/types/dispatch.ts"],"names":[],"mappings":";AAAA,wBASE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/schema/types/dispatch.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,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,
|
|
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
|
|
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,
|
|
1
|
+
{"version":3,"file":"stock.d.ts","sourceRoot":"","sources":["../../../src/schema/types/stock.ts"],"names":[],"mappings":";AAAA,wBAQE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stock.js","sourceRoot":"","sources":["../../../src/schema/types/stock.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,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-
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
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
|
-
"@
|
|
44
|
-
"@unchainedshop/
|
|
45
|
-
"@unchainedshop/
|
|
46
|
-
"@unchainedshop/
|
|
47
|
-
"@unchainedshop/
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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:
|
|
21
|
+
req: Request & { query?: any; unchainedContext: Context },
|
|
23
22
|
res,
|
|
24
23
|
) {
|
|
25
24
|
try {
|
package/src/express/index.ts
CHANGED
|
@@ -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:
|
|
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) ||
|
package/src/fastify/index.ts
CHANGED
|
@@ -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:
|
|
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) ||
|
package/src/loaders/index.ts
CHANGED
|
@@ -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(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
|
|
187
|
-
|
|
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
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
|
302
|
-
|
|
303
|
-
(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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
|
{
|