@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
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
} from '@unchainedshop/core-products';
|
|
8
8
|
import { Context } from '../../../context.js';
|
|
9
9
|
import { Product } from './product-types.js';
|
|
10
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
11
|
-
import { ProductPricingDirector } from '@unchainedshop/core';
|
|
12
10
|
|
|
13
11
|
export const ConfigurableProduct = {
|
|
14
12
|
...Product,
|
|
@@ -105,7 +103,7 @@ export const ConfigurableProduct = {
|
|
|
105
103
|
},
|
|
106
104
|
requestContext: Context,
|
|
107
105
|
): Promise<ProductPriceRange> {
|
|
108
|
-
const { countryContext, modules } = requestContext;
|
|
106
|
+
const { countryContext, modules, services } = requestContext;
|
|
109
107
|
const currency = forcedCurrencyCode || requestContext.currencyContext;
|
|
110
108
|
|
|
111
109
|
const products = await modules.products.proxyProducts(product, vectors, {
|
|
@@ -123,26 +121,11 @@ export const ConfigurableProduct = {
|
|
|
123
121
|
quantity,
|
|
124
122
|
};
|
|
125
123
|
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
requestContext,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
if (!calculated || !calculated.length) return null;
|
|
132
|
-
|
|
133
|
-
const pricing = ProductPricingDirector.calculationSheet(pricingContext, calculated);
|
|
124
|
+
const pricing = await services.products.simulateProductPricing(pricingContext);
|
|
125
|
+
if (!pricing) return null;
|
|
134
126
|
const unitPrice = pricing.unitPrice({ useNetPrice });
|
|
135
127
|
|
|
136
128
|
return {
|
|
137
|
-
_id: await sha256(
|
|
138
|
-
[
|
|
139
|
-
proxyProduct._id,
|
|
140
|
-
countryContext,
|
|
141
|
-
quantity,
|
|
142
|
-
useNetPrice,
|
|
143
|
-
requestContext.userId || 'ANONYMOUS',
|
|
144
|
-
].join(''),
|
|
145
|
-
),
|
|
146
129
|
...unitPrice,
|
|
147
130
|
isNetPrice: useNetPrice,
|
|
148
131
|
isTaxable: pricing.taxSum() > 0,
|
|
@@ -159,36 +142,9 @@ export const ConfigurableProduct = {
|
|
|
159
142
|
prices: filteredPrices,
|
|
160
143
|
});
|
|
161
144
|
|
|
162
|
-
const minPriceHash = await sha256(
|
|
163
|
-
[
|
|
164
|
-
product._id,
|
|
165
|
-
minPrice?.isTaxable,
|
|
166
|
-
minPrice?.isNetPrice,
|
|
167
|
-
minPrice?.amount,
|
|
168
|
-
minPrice?.currencyCode,
|
|
169
|
-
].join(''),
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const maxPriceHash = await sha256(
|
|
173
|
-
[
|
|
174
|
-
product._id,
|
|
175
|
-
maxPrice?.isTaxable,
|
|
176
|
-
maxPrice?.isNetPrice,
|
|
177
|
-
maxPrice?.amount,
|
|
178
|
-
maxPrice?.currencyCode,
|
|
179
|
-
].join(''),
|
|
180
|
-
);
|
|
181
|
-
|
|
182
145
|
return {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
_id: minPriceHash,
|
|
186
|
-
...minPrice,
|
|
187
|
-
},
|
|
188
|
-
maxPrice: {
|
|
189
|
-
_id: maxPriceHash,
|
|
190
|
-
...maxPrice,
|
|
191
|
-
},
|
|
146
|
+
minPrice,
|
|
147
|
+
maxPrice,
|
|
192
148
|
};
|
|
193
149
|
},
|
|
194
150
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ProductDiscount as ProductDiscountType } from '@unchainedshop/core-products';
|
|
2
2
|
import { ProductDiscountDirector } from '@unchainedshop/core';
|
|
3
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
4
3
|
|
|
5
4
|
export const ProductDiscount = {
|
|
6
5
|
interface: async (productDiscount: ProductDiscountType) => {
|
|
@@ -15,11 +14,10 @@ export const ProductDiscount = {
|
|
|
15
14
|
};
|
|
16
15
|
},
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
const { total
|
|
17
|
+
total(productDiscount: ProductDiscountType) {
|
|
18
|
+
const { total } = productDiscount;
|
|
20
19
|
if (productDiscount.total) {
|
|
21
20
|
return {
|
|
22
|
-
_id: await sha256([`${_id}`, total.amount, total.currency].join('')),
|
|
23
21
|
amount: total.amount,
|
|
24
22
|
currency: total.currency,
|
|
25
23
|
};
|
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
} from '@unchainedshop/core-products';
|
|
6
6
|
import { Context } from '../../../context.js';
|
|
7
7
|
import { Product } from './product-types.js';
|
|
8
|
-
import { ProductPricingDirector } from '@unchainedshop/core';
|
|
9
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
10
8
|
|
|
11
9
|
export const PlanProduct = {
|
|
12
10
|
...Product,
|
|
@@ -40,7 +38,7 @@ export const PlanProduct = {
|
|
|
40
38
|
},
|
|
41
39
|
requestContext: Context,
|
|
42
40
|
): Promise<ProductPrice> {
|
|
43
|
-
const { countryContext, user } = requestContext;
|
|
41
|
+
const { countryContext, user, services } = requestContext;
|
|
44
42
|
const currency = forcedCurrencyCode || requestContext.currencyContext;
|
|
45
43
|
|
|
46
44
|
const pricingContext = {
|
|
@@ -52,17 +50,11 @@ export const PlanProduct = {
|
|
|
52
50
|
configuration,
|
|
53
51
|
};
|
|
54
52
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
if (!calculated || !calculated.length) return null;
|
|
58
|
-
|
|
59
|
-
const pricing = ProductPricingDirector.calculationSheet(pricingContext, calculated);
|
|
53
|
+
const pricing = await services.products.simulateProductPricing(pricingContext);
|
|
54
|
+
if (!pricing) return null;
|
|
60
55
|
const unitPrice = pricing.unitPrice({ useNetPrice });
|
|
61
56
|
|
|
62
57
|
return {
|
|
63
|
-
_id: await sha256(
|
|
64
|
-
[obj._id, countryContext, quantity, useNetPrice, user ? user._id : 'ANONYMOUS'].join(''),
|
|
65
|
-
),
|
|
66
58
|
...unitPrice,
|
|
67
59
|
isNetPrice: useNetPrice,
|
|
68
60
|
isTaxable: pricing.taxSum() > 0,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Product, ProductSupply } from '@unchainedshop/core-products';
|
|
2
|
-
import { WarehousingContext, WarehousingDirector } from '@unchainedshop/core';
|
|
3
2
|
import { Context } from '../../../context.js';
|
|
4
3
|
import { DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
5
4
|
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
@@ -15,54 +14,23 @@ export const SimpleProduct = {
|
|
|
15
14
|
requestContext: Context,
|
|
16
15
|
): Promise<
|
|
17
16
|
Array<{
|
|
18
|
-
_id: string;
|
|
19
17
|
deliveryProvider?: DeliveryProvider;
|
|
20
18
|
warehousingProvider?: WarehousingProvider;
|
|
21
19
|
shipping?: Date;
|
|
22
20
|
earliestDelivery?: Date;
|
|
23
21
|
}>
|
|
24
22
|
> {
|
|
25
|
-
const {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
const deliveryProviders = await modules.delivery.findProviders({
|
|
29
|
-
type: deliveryProviderType,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
|
|
33
|
-
const result = await oldResult;
|
|
34
|
-
|
|
35
|
-
const warehousingProviders = await services.orders.supportedWarehousingProviders({
|
|
36
|
-
product: obj,
|
|
37
|
-
deliveryProvider,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const mappedWarehousingProviders = await Promise.all(
|
|
41
|
-
warehousingProviders.map(async (warehousingProvider) => {
|
|
42
|
-
const warehousingContext: WarehousingContext = {
|
|
43
|
-
deliveryProvider,
|
|
44
|
-
product: obj,
|
|
45
|
-
quantity,
|
|
46
|
-
referenceDate,
|
|
47
|
-
};
|
|
23
|
+
const { referenceDate, quantity } = params;
|
|
24
|
+
const { services, modules } = requestContext;
|
|
48
25
|
|
|
49
|
-
|
|
50
|
-
warehousingProvider,
|
|
51
|
-
warehousingContext,
|
|
52
|
-
requestContext,
|
|
53
|
-
);
|
|
54
|
-
const dispatch = await director.estimatedDispatch();
|
|
26
|
+
const deliveryProviders = await modules.delivery.findProviders({});
|
|
55
27
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return result.concat(result, mappedWarehousingProviders);
|
|
65
|
-
}, Promise.resolve([]));
|
|
28
|
+
return services.products.simulateProductDispatching({
|
|
29
|
+
deliveryProviders,
|
|
30
|
+
product: obj,
|
|
31
|
+
quantity,
|
|
32
|
+
referenceDate,
|
|
33
|
+
});
|
|
66
34
|
},
|
|
67
35
|
|
|
68
36
|
async simulatedStocks(
|
|
@@ -74,7 +42,6 @@ export const SimpleProduct = {
|
|
|
74
42
|
requestContext: Context,
|
|
75
43
|
): Promise<
|
|
76
44
|
Array<{
|
|
77
|
-
_id: string;
|
|
78
45
|
deliveryProvider?: DeliveryProvider;
|
|
79
46
|
warehousingProvider?: WarehousingProvider;
|
|
80
47
|
quantity?: number;
|
|
@@ -87,39 +54,11 @@ export const SimpleProduct = {
|
|
|
87
54
|
type: deliveryProviderType,
|
|
88
55
|
});
|
|
89
56
|
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
deliveryProvider,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const mappedWarehousingProviders = await Promise.all(
|
|
99
|
-
warehousingProviders.map(async (warehousingProvider) => {
|
|
100
|
-
const warehousingContext: WarehousingContext = {
|
|
101
|
-
deliveryProvider,
|
|
102
|
-
product: obj,
|
|
103
|
-
referenceDate,
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const director = await WarehousingDirector.actions(
|
|
107
|
-
warehousingProvider,
|
|
108
|
-
warehousingContext,
|
|
109
|
-
requestContext,
|
|
110
|
-
);
|
|
111
|
-
const stock = await director.estimatedStock();
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
warehousingProvider,
|
|
115
|
-
...warehousingContext,
|
|
116
|
-
...stock,
|
|
117
|
-
};
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
return result.concat(result, mappedWarehousingProviders);
|
|
122
|
-
}, Promise.resolve([]));
|
|
57
|
+
return services.products.simulateProductInventory({
|
|
58
|
+
deliveryProviders,
|
|
59
|
+
product: obj,
|
|
60
|
+
referenceDate,
|
|
61
|
+
});
|
|
123
62
|
},
|
|
124
63
|
|
|
125
64
|
baseUnit({ warehousing }): string {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WarehousingContext, WarehousingDirector } from '@unchainedshop/core';
|
|
2
1
|
import {
|
|
3
2
|
Product,
|
|
4
3
|
ProductContractConfiguration,
|
|
@@ -40,7 +39,6 @@ export const TokenizedProduct = {
|
|
|
40
39
|
requestContext: Context,
|
|
41
40
|
): Promise<
|
|
42
41
|
Array<{
|
|
43
|
-
_id: string;
|
|
44
42
|
deliveryProvider?: DeliveryProvider;
|
|
45
43
|
warehousingProvider?: WarehousingProvider;
|
|
46
44
|
quantity?: number;
|
|
@@ -51,39 +49,11 @@ export const TokenizedProduct = {
|
|
|
51
49
|
|
|
52
50
|
const deliveryProviders = await modules.delivery.findProviders({});
|
|
53
51
|
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
deliveryProvider,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const mappedWarehousingProviders = await Promise.all(
|
|
63
|
-
warehousingProviders.map(async (warehousingProvider) => {
|
|
64
|
-
const warehousingContext: WarehousingContext = {
|
|
65
|
-
deliveryProvider,
|
|
66
|
-
product: obj,
|
|
67
|
-
referenceDate,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const director = await WarehousingDirector.actions(
|
|
71
|
-
warehousingProvider,
|
|
72
|
-
warehousingContext,
|
|
73
|
-
requestContext,
|
|
74
|
-
);
|
|
75
|
-
const stock = await director.estimatedStock();
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
warehousingProvider,
|
|
79
|
-
...warehousingContext,
|
|
80
|
-
...stock,
|
|
81
|
-
};
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
return result.concat(result, mappedWarehousingProviders);
|
|
86
|
-
}, Promise.resolve([]));
|
|
52
|
+
return services.products.simulateProductInventory({
|
|
53
|
+
deliveryProviders,
|
|
54
|
+
product: obj,
|
|
55
|
+
referenceDate,
|
|
56
|
+
});
|
|
87
57
|
},
|
|
88
58
|
|
|
89
59
|
async tokens(product: Product, params: never, requestContext: Context) {
|
|
@@ -6,22 +6,36 @@ import { Language } from '@unchainedshop/core-languages';
|
|
|
6
6
|
import { Order, OrderStatus } from '@unchainedshop/core-orders';
|
|
7
7
|
import { PaymentCredentials } from '@unchainedshop/core-payment';
|
|
8
8
|
import { Quotation } from '@unchainedshop/core-quotations';
|
|
9
|
-
import {
|
|
10
|
-
Email,
|
|
11
|
-
User as UserType,
|
|
12
|
-
UserProfile,
|
|
13
|
-
Web3Address,
|
|
14
|
-
WebAuthnCredentials,
|
|
15
|
-
PushSubscription,
|
|
16
|
-
} from '@unchainedshop/core-users';
|
|
9
|
+
import { Email, User as UserType, UserProfile } from '@unchainedshop/core-users';
|
|
17
10
|
import { TokenSurrogate } from '@unchainedshop/core-warehousing';
|
|
18
11
|
import { Roles, permissions } from '@unchainedshop/roles';
|
|
19
12
|
import { ProductReview } from '@unchainedshop/core-products';
|
|
13
|
+
import { Contact } from '@unchainedshop/mongodb';
|
|
14
|
+
import { Country } from '@unchainedshop/core-countries';
|
|
20
15
|
import { checkAction, checkTypeResolver } from '../../acl.js';
|
|
21
16
|
import { actions } from '../../roles/index.js';
|
|
22
17
|
import { Context } from '../../context.js';
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
|
|
19
|
+
export interface PushSubscription {
|
|
20
|
+
_id: string;
|
|
21
|
+
userAgent: string;
|
|
22
|
+
expirationTime: number;
|
|
23
|
+
endpoint: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Web3Address {
|
|
27
|
+
address: string;
|
|
28
|
+
nonce?: number;
|
|
29
|
+
verified: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface WebAuthnCredentials {
|
|
32
|
+
id: string;
|
|
33
|
+
publicKey: string;
|
|
34
|
+
created: Date;
|
|
35
|
+
aaguid: string;
|
|
36
|
+
counter: number;
|
|
37
|
+
mdsMetadata: any;
|
|
38
|
+
}
|
|
25
39
|
|
|
26
40
|
type HelperType<P, T> = (user: UserType, params: P, context: Context) => Promise<T>;
|
|
27
41
|
|
|
@@ -100,7 +114,9 @@ const {
|
|
|
100
114
|
} = actions as Record<string, string>;
|
|
101
115
|
|
|
102
116
|
const getPrimaryEmail = (user: UserType) => {
|
|
103
|
-
return (user.emails || []).
|
|
117
|
+
return (user.emails || []).toSorted(
|
|
118
|
+
(left, right) => Number(right.verified) - Number(left.verified),
|
|
119
|
+
)?.[0];
|
|
104
120
|
};
|
|
105
121
|
|
|
106
122
|
export const User: UserHelperTypes = {
|
|
@@ -160,7 +176,7 @@ export const User: UserHelperTypes = {
|
|
|
160
176
|
const { modules, countryContext } = context;
|
|
161
177
|
await checkAction(context, viewUserOrders, [user, params]);
|
|
162
178
|
return modules.orders.cart({
|
|
163
|
-
|
|
179
|
+
countryCode: countryContext,
|
|
164
180
|
orderNumber: params.orderNumber,
|
|
165
181
|
userId: user._id,
|
|
166
182
|
});
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import { Context } from '../../context.js';
|
|
2
|
-
import { WebAuthnCredentials as WebAuthnCredentialsTypes } from '@unchainedshop/core-users';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
mdsMetadata: HelperType<any, any>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const WebAuthnCredentials: WebAuthnCredentialsHelperTypes = {
|
|
17
|
-
async _id(obj) {
|
|
3
|
+
export const WebAuthnCredentials = {
|
|
4
|
+
async _id(obj: {
|
|
5
|
+
id: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
created: Date;
|
|
8
|
+
aaguid: string;
|
|
9
|
+
counter: number;
|
|
10
|
+
mdsMetadata: any;
|
|
11
|
+
}) {
|
|
18
12
|
return obj.id;
|
|
19
13
|
},
|
|
20
|
-
async created(obj
|
|
14
|
+
async created(obj: {
|
|
15
|
+
id: string;
|
|
16
|
+
publicKey: string;
|
|
17
|
+
created: Date;
|
|
18
|
+
aaguid: string;
|
|
19
|
+
counter: number;
|
|
20
|
+
mdsMetadata: any;
|
|
21
|
+
}) {
|
|
21
22
|
return obj.created || new Date(0);
|
|
22
23
|
},
|
|
23
|
-
async mdsMetadata(
|
|
24
|
+
async mdsMetadata(
|
|
25
|
+
obj: {
|
|
26
|
+
id: string;
|
|
27
|
+
publicKey: string;
|
|
28
|
+
created: Date;
|
|
29
|
+
aaguid: string;
|
|
30
|
+
counter: number;
|
|
31
|
+
mdsMetadata: any;
|
|
32
|
+
},
|
|
33
|
+
_: never,
|
|
34
|
+
{ modules }: Context,
|
|
35
|
+
) {
|
|
24
36
|
const metadata = await modules.users.webAuthn.findMDSMetadataForAAGUID(obj.aaguid);
|
|
25
37
|
return metadata;
|
|
26
38
|
},
|
package/src/schema/inputTypes.ts
CHANGED
package/src/schema/mutation.ts
CHANGED
|
@@ -75,7 +75,7 @@ export default [
|
|
|
75
75
|
"""
|
|
76
76
|
Create WebAuthn PublicKeyCredentialCreationOptions to use for Registering a new WebAuthn Device
|
|
77
77
|
"""
|
|
78
|
-
createWebAuthnCredentialCreationOptions(username: String!, extensionOptions: JSON): JSON
|
|
78
|
+
createWebAuthnCredentialCreationOptions(username: String!, extensionOptions: JSON): JSON
|
|
79
79
|
|
|
80
80
|
"""
|
|
81
81
|
Register WebAuthn Credentials for current user
|
|
@@ -90,7 +90,7 @@ export default [
|
|
|
90
90
|
"""
|
|
91
91
|
Create WebAuthn PublicKeyCredentialRequestrOptions to use for WebAuthn Login Flow
|
|
92
92
|
"""
|
|
93
|
-
createWebAuthnCredentialRequestOptions(username: String, extensionOptions: JSON): JSON
|
|
93
|
+
createWebAuthnCredentialRequestOptions(username: String, extensionOptions: JSON): JSON
|
|
94
94
|
|
|
95
95
|
"""
|
|
96
96
|
Creates an alternative cart. If you use this feature, you should use explicit orderId's when using the
|
|
@@ -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
|
}
|
package/tests/api-index.test.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Import the function to be tested.
|
|
2
|
-
import { admin } from '../
|
|
3
|
-
import { actions } from '../
|
|
4
|
-
import { checkAction, ensureActionExists, ensureIsFunction } from '../
|
|
5
|
-
import { NoPermissionError, PermissionSystemError } from '../
|
|
2
|
+
import { admin } from '../src/roles/admin.js';
|
|
3
|
+
import { actions } from '../src/roles/index.js';
|
|
4
|
+
import { checkAction, ensureActionExists, ensureIsFunction } from '../src/acl.js';
|
|
5
|
+
import { NoPermissionError, PermissionSystemError } from '../src/errors.js';
|
|
6
6
|
import { Roles } from '@unchainedshop/roles';
|
|
7
7
|
|
|
8
8
|
describe('API', () => {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Strategy from 'passport-strategy';
|
|
2
|
-
export default class AccessTokenStrategy extends Strategy {
|
|
3
|
-
name: string;
|
|
4
|
-
pass: any;
|
|
5
|
-
_verify: any;
|
|
6
|
-
success: any;
|
|
7
|
-
constructor(verify: any);
|
|
8
|
-
authenticate(req: any): void;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=access-token-strategy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"access-token-strategy.d.ts","sourceRoot":"","sources":["../../../src/express/passport/access-token-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,QAAQ;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,GAAG,CAAC;IAEV,OAAO,EAAE,GAAG,CAAC;IAEb,OAAO,EAAE,GAAG,CAAC;gBAED,MAAM,KAAA;IAalB,YAAY,CAAC,GAAG,KAAA;CAcjB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import Strategy from 'passport-strategy';
|
|
2
|
-
export default class AccessTokenStrategy extends Strategy {
|
|
3
|
-
name;
|
|
4
|
-
pass;
|
|
5
|
-
_verify;
|
|
6
|
-
success;
|
|
7
|
-
constructor(verify) {
|
|
8
|
-
super();
|
|
9
|
-
if (!verify) {
|
|
10
|
-
throw new TypeError('AccessTokenStrategy requires a verify callback');
|
|
11
|
-
}
|
|
12
|
-
// eslint-disable-next-line
|
|
13
|
-
this._verify = verify;
|
|
14
|
-
// Set the default name of our strategy
|
|
15
|
-
this.name = 'access-token';
|
|
16
|
-
}
|
|
17
|
-
authenticate(req) {
|
|
18
|
-
if (req.headers.authorization) {
|
|
19
|
-
const [type, token] = req.headers.authorization.split(' ');
|
|
20
|
-
if (type === 'Bearer') {
|
|
21
|
-
// eslint-disable-next-line
|
|
22
|
-
this._verify(token, (err, user) => {
|
|
23
|
-
if (!user || err)
|
|
24
|
-
return this.pass();
|
|
25
|
-
this.success(user);
|
|
26
|
-
});
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
this.pass();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=access-token-strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"access-token-strategy.js","sourceRoot":"","sources":["../../../src/express/passport/access-token-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,QAAQ;IACvD,IAAI,CAAS;IAEb,IAAI,CAAM;IAEV,OAAO,CAAM;IAEb,OAAO,CAAM;IAEb,YAAY,MAAM;QAChB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;QACxE,CAAC;QACD,2BAA2B;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,uCAAuC;QACvC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;IAED,YAAY,CAAC,GAAG;QACd,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3D,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,2BAA2B;gBAC3B,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;oBAChC,IAAI,CAAC,IAAI,IAAI,GAAG;wBAAE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;oBACrC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/express/passport/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,QAAA,MAAM,aAAa,iBAAkB,aAAa,QAqCjD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Passport } from 'passport';
|
|
2
|
-
import AccessTokenStrategy from './access-token-strategy.js';
|
|
3
|
-
const setupPassport = (unchainedAPI) => {
|
|
4
|
-
const passport = new Passport();
|
|
5
|
-
passport.serializeUser(function serialize(user, done) {
|
|
6
|
-
done(null, user._id);
|
|
7
|
-
});
|
|
8
|
-
passport.deserializeUser(function deserialize(_id, done) {
|
|
9
|
-
unchainedAPI.modules.users.findUserById(_id).then((user) => {
|
|
10
|
-
done(null, user);
|
|
11
|
-
}, (error) => {
|
|
12
|
-
done(error, null);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
passport.use(new AccessTokenStrategy(function verify(userToken, done) {
|
|
16
|
-
const [username] = userToken.split(':');
|
|
17
|
-
unchainedAPI.modules.users.findUserByToken(userToken).then((user) => {
|
|
18
|
-
if (user?.username === username) {
|
|
19
|
-
done(null, user);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
done(null, null);
|
|
23
|
-
}, (error) => {
|
|
24
|
-
done(error, null);
|
|
25
|
-
});
|
|
26
|
-
}));
|
|
27
|
-
return passport;
|
|
28
|
-
};
|
|
29
|
-
export default setupPassport;
|
|
30
|
-
//# sourceMappingURL=setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/express/passport/setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAE7D,MAAM,aAAa,GAAG,CAAC,YAA2B,EAAE,EAAE;IACpD,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAEhC,QAAQ,CAAC,aAAa,CAAC,SAAS,SAAS,CAAC,IAAI,EAAE,IAAI;QAClD,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,CAAC,SAAS,WAAW,CAAC,GAAG,EAAE,IAAI;QACrD,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAC/C,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACpB,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,CACV,IAAI,mBAAmB,CAAC,SAAS,MAAM,CAAC,SAAS,EAAE,IAAI;QACrD,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,CACxD,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,IAAI,EAAE,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACjB,OAAO;YACT,CAAC;YACD,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACpB,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteUserProductReviews.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/products/deleteUserProductReviews.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,wBAAwB,CACpD,IAAI,EAAE,KAAK,EACX,MAAM,EAAE;IACN,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,oBAY5C"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { InvalidIdError, UserNotFoundError } from '../../../errors.js';
|
|
3
|
-
export default async function deleteUserProductReviews(root, params, { modules, userId: currentUserId }) {
|
|
4
|
-
const normalizedUserId = params?.userId || currentUserId;
|
|
5
|
-
log(`mutation deleteUserProductReviews ${normalizedUserId}`, {
|
|
6
|
-
userId: currentUserId,
|
|
7
|
-
});
|
|
8
|
-
if (!normalizedUserId)
|
|
9
|
-
throw new InvalidIdError({ userId: normalizedUserId });
|
|
10
|
-
if (!(await modules.users.userExists({ userId: normalizedUserId })))
|
|
11
|
-
throw new UserNotFoundError({ userId: normalizedUserId });
|
|
12
|
-
await modules.products.reviews.deleteMany({ authorId: normalizedUserId });
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=deleteUserProductReviews.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteUserProductReviews.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/products/deleteUserProductReviews.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,IAAW,EACX,MAEC,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAW;IAE3C,MAAM,gBAAgB,GAAG,MAAM,EAAE,MAAM,IAAI,aAAa,CAAC;IACzD,GAAG,CAAC,qCAAqC,gBAAgB,EAAE,EAAE;QAC3D,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IACH,IAAI,CAAC,gBAAgB;QAAE,MAAM,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC9E,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACjE,MAAM,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC5D,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAE1E,OAAO,IAAI,CAAC;AACd,CAAC"}
|