@unchainedshop/api 3.0.0-rc6 → 3.0.0-rc8
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/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/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/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 +11 -45
- 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.map +1 -1
- package/lib/resolvers/type/user-types.js +2 -2
- package/lib/resolvers/type/user-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/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 +10 -7
- package/src/api-index.ts +1 -1
- package/src/context.ts +4 -20
- 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/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/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 +4 -2
- package/src/schema/inputTypes.ts +0 -1
- 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/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/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
|
@@ -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) {
|
|
@@ -114,7 +114,9 @@ const {
|
|
|
114
114
|
} = actions as Record<string, string>;
|
|
115
115
|
|
|
116
116
|
const getPrimaryEmail = (user: UserType) => {
|
|
117
|
-
return (user.emails || []).
|
|
117
|
+
return (user.emails || []).toSorted(
|
|
118
|
+
(left, right) => Number(right.verified) - Number(left.verified),
|
|
119
|
+
)?.[0];
|
|
118
120
|
};
|
|
119
121
|
|
|
120
122
|
export const User: UserHelperTypes = {
|
|
@@ -174,7 +176,7 @@ export const User: UserHelperTypes = {
|
|
|
174
176
|
const { modules, countryContext } = context;
|
|
175
177
|
await checkAction(context, viewUserOrders, [user, params]);
|
|
176
178
|
return modules.orders.cart({
|
|
177
|
-
|
|
179
|
+
countryCode: countryContext,
|
|
178
180
|
orderNumber: params.orderNumber,
|
|
179
181
|
userId: user._id,
|
|
180
182
|
});
|
package/src/schema/inputTypes.ts
CHANGED
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getOrderCart.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/utils/getOrderCart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGjD,eAAO,MAAM,YAAY,WAAkB;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,WAAW,OAAO,iBAe5F,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { OrderNotFoundError } from '../../../errors.js';
|
|
2
|
-
export const getOrderCart = async (params, context) => {
|
|
3
|
-
const { modules, services } = context;
|
|
4
|
-
const { orderId, user } = params;
|
|
5
|
-
if (orderId) {
|
|
6
|
-
const order = await modules.orders.findOrder({ orderId });
|
|
7
|
-
if (!order)
|
|
8
|
-
throw new OrderNotFoundError({ orderId });
|
|
9
|
-
return order;
|
|
10
|
-
}
|
|
11
|
-
return services.orders.nextUserCart({
|
|
12
|
-
user,
|
|
13
|
-
countryCode: context.countryContext,
|
|
14
|
-
forceCartCreation: true,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=getOrderCart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getOrderCart.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/utils/getOrderCart.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,MAAwC,EAAE,OAAgB,EAAE,EAAE;IAC/F,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAEjC,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,kBAAkB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC;QAClC,IAAI;QACJ,WAAW,EAAE,OAAO,CAAC,cAAc;QACnC,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Context } from '../../../context.js';
|
|
2
|
-
import { User } from '@unchainedshop/core-users';
|
|
3
|
-
import { OrderNotFoundError } from '../../../errors.js';
|
|
4
|
-
|
|
5
|
-
export const getOrderCart = async (params: { orderId?: string; user: User }, context: Context) => {
|
|
6
|
-
const { modules, services } = context;
|
|
7
|
-
const { orderId, user } = params;
|
|
8
|
-
|
|
9
|
-
if (orderId) {
|
|
10
|
-
const order = await modules.orders.findOrder({ orderId });
|
|
11
|
-
if (!order) throw new OrderNotFoundError({ orderId });
|
|
12
|
-
return order;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return services.orders.nextUserCart({
|
|
16
|
-
user,
|
|
17
|
-
countryCode: context.countryContext,
|
|
18
|
-
forceCartCreation: true,
|
|
19
|
-
});
|
|
20
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
4
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
5
|
-
|
|
6
|
-
export const Dispatch = {
|
|
7
|
-
_id: async (params: {
|
|
8
|
-
product: Product;
|
|
9
|
-
deliveryProvider: DeliveryProvider;
|
|
10
|
-
warehousingProvider: WarehousingProvider;
|
|
11
|
-
referenceDate: Date;
|
|
12
|
-
quantity: number;
|
|
13
|
-
country: string;
|
|
14
|
-
userId?: string;
|
|
15
|
-
}) =>
|
|
16
|
-
await sha256(
|
|
17
|
-
[
|
|
18
|
-
params.product._id,
|
|
19
|
-
params.deliveryProvider._id,
|
|
20
|
-
params.warehousingProvider._id,
|
|
21
|
-
params.referenceDate,
|
|
22
|
-
params.quantity,
|
|
23
|
-
params.country,
|
|
24
|
-
params.userId || 'ANONYMOUS',
|
|
25
|
-
].join(''),
|
|
26
|
-
),
|
|
27
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
4
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
5
|
-
|
|
6
|
-
export const Stock = {
|
|
7
|
-
_id: async (params: {
|
|
8
|
-
product: Product;
|
|
9
|
-
deliveryProvider: DeliveryProvider;
|
|
10
|
-
warehousingProvider: WarehousingProvider;
|
|
11
|
-
referenceDate: Date;
|
|
12
|
-
country: string;
|
|
13
|
-
userId?: string;
|
|
14
|
-
}) =>
|
|
15
|
-
await sha256(
|
|
16
|
-
[
|
|
17
|
-
params.product._id,
|
|
18
|
-
params.deliveryProvider._id,
|
|
19
|
-
params.warehousingProvider._id,
|
|
20
|
-
params.referenceDate,
|
|
21
|
-
params.country,
|
|
22
|
-
params.userId || 'ANONYMOUS',
|
|
23
|
-
].join(''),
|
|
24
|
-
),
|
|
25
|
-
};
|