@unchainedshop/api 3.0.0-rc7 → 3.0.0-rc9
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/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 +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.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/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/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/index.d.ts +11 -42
- 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 +2 -31
- 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 +0 -2
- package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
- package/lib/resolvers/type/product/product-simple-types.d.ts.map +1 -1
- package/lib/resolvers/type/product/product-simple-types.js.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts.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 +6 -6
- package/src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts +1 -1
- package/src/resolvers/mutations/accounts/resetPassword.ts +13 -46
- package/src/resolvers/mutations/countries/updateCountry.ts +2 -7
- package/src/resolvers/queries/users/validateResetPasswordToken.ts +2 -2
- package/src/resolvers/type/delivery-provider-types.ts +0 -3
- 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 +2 -39
- package/src/resolvers/type/product/product-discount.ts +2 -4
- package/src/resolvers/type/product/product-plan-types.ts +0 -4
- package/src/resolvers/type/product/product-simple-types.ts +0 -1
- 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/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/type/dispatch-types.ts +0 -27
- package/src/resolvers/type/stock-types.ts +0 -25
|
@@ -5,7 +5,7 @@ import { Context } from '../../../context.js';
|
|
|
5
5
|
|
|
6
6
|
export default async function updateCountry(
|
|
7
7
|
root: never,
|
|
8
|
-
{ country, countryId }: { country: Country
|
|
8
|
+
{ country, countryId }: { country: Country; countryId: string },
|
|
9
9
|
{ userId, modules }: Context,
|
|
10
10
|
) {
|
|
11
11
|
log(`mutation updateCountry ${countryId}`, { userId });
|
|
@@ -15,12 +15,7 @@ export default async function updateCountry(
|
|
|
15
15
|
if (!(await modules.countries.countryExists({ countryId })))
|
|
16
16
|
throw new CountryNotFoundError({ countryId });
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
currencyId: country.defaultCurrencyId,
|
|
20
|
-
});
|
|
21
|
-
const defaultCurrencyCode = country?.defaultCurrencyCode || currencyObject?.isoCode;
|
|
22
|
-
|
|
23
|
-
await modules.countries.update(countryId, { ...country, defaultCurrencyCode });
|
|
18
|
+
await modules.countries.update(countryId, country);
|
|
24
19
|
|
|
25
20
|
return modules.countries.findCountry({ countryId });
|
|
26
21
|
}
|
|
@@ -10,7 +10,7 @@ export default async function validateResetPasswordToken(
|
|
|
10
10
|
|
|
11
11
|
log('query validateResetPasswordToken', { userId, token: params.token });
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const resetToken = await modules.users.findResetToken(params.token);
|
|
14
14
|
|
|
15
|
-
return !!
|
|
15
|
+
return !!resetToken;
|
|
16
16
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Context } from '../../context.js';
|
|
2
2
|
import { DeliveryProvider as DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
3
3
|
import { DeliveryDirector, DeliveryError, DeliveryPricingDirector } from '@unchainedshop/core';
|
|
4
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
5
4
|
|
|
6
5
|
export type HelperType<P, T> = (provider: DeliveryProviderType, params: P, context: Context) => T;
|
|
7
6
|
|
|
@@ -24,7 +23,6 @@ export interface DeliveryProviderHelperTypes {
|
|
|
24
23
|
context: any;
|
|
25
24
|
},
|
|
26
25
|
Promise<{
|
|
27
|
-
_id: string;
|
|
28
26
|
amount: number;
|
|
29
27
|
currencyCode: string;
|
|
30
28
|
countryCode: string;
|
|
@@ -84,7 +82,6 @@ export const DeliveryProvider: DeliveryProviderHelperTypes = {
|
|
|
84
82
|
};
|
|
85
83
|
|
|
86
84
|
return {
|
|
87
|
-
_id: await sha256([deliveryProvider._id, country, useNetPrice, order ? order._id : ''].join('')),
|
|
88
85
|
amount: orderPrice.amount,
|
|
89
86
|
currencyCode: orderPrice.currency,
|
|
90
87
|
countryCode: country,
|
|
@@ -12,7 +12,6 @@ import { Country } from './country-types.js';
|
|
|
12
12
|
import { Currency } from './currency-types.js';
|
|
13
13
|
import { DeliveryProvider } from './delivery-provider-types.js';
|
|
14
14
|
import { Dimensions } from './dimensions-types.js';
|
|
15
|
-
import { Dispatch } from './dispatch-types.js';
|
|
16
15
|
import { Enrollment } from './enrollment/enrollment-types.js';
|
|
17
16
|
import { EnrollmentDelivery } from './enrollment/enrollment-delivery-types.js';
|
|
18
17
|
import { EnrollmentPayment } from './enrollment/enrollment-payment-types.js';
|
|
@@ -57,7 +56,6 @@ import { Quotation } from './quotation-types.js';
|
|
|
57
56
|
import { Shop } from './shop-types.js';
|
|
58
57
|
import { SimpleProduct } from './product/product-simple-types.js';
|
|
59
58
|
import { TokenizedProduct } from './product/product-tokenized-types.js';
|
|
60
|
-
import { Stock } from './stock-types.js';
|
|
61
59
|
import { User } from './user-types.js';
|
|
62
60
|
import { WebAuthnCredentials } from './webauthn-credentials-types.js';
|
|
63
61
|
import { WarehousingProvider } from './warehousing-provider-types.js';
|
|
@@ -84,7 +82,6 @@ const types = {
|
|
|
84
82
|
Currency,
|
|
85
83
|
DeliveryProvider,
|
|
86
84
|
Dimensions,
|
|
87
|
-
Dispatch,
|
|
88
85
|
Enrollment,
|
|
89
86
|
EnrollmentDelivery,
|
|
90
87
|
EnrollmentPayment,
|
|
@@ -131,7 +128,6 @@ const types = {
|
|
|
131
128
|
SimpleProduct,
|
|
132
129
|
TokenizedProduct,
|
|
133
130
|
Token,
|
|
134
|
-
Stock,
|
|
135
131
|
User,
|
|
136
132
|
WebAuthnCredentials,
|
|
137
133
|
WarehousingProvider,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Context } from '../../../context.js';
|
|
2
2
|
import { OrderDeliveryDiscount as OrderDeliveryDiscountType } from '@unchainedshop/core-orders';
|
|
3
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
4
3
|
|
|
5
4
|
export const OrderDeliveryDiscount = {
|
|
6
5
|
_id(obj: OrderDeliveryDiscountType) {
|
|
@@ -13,9 +12,8 @@ export const OrderDeliveryDiscount = {
|
|
|
13
12
|
});
|
|
14
13
|
},
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
total(obj: OrderDeliveryDiscountType) {
|
|
17
16
|
return {
|
|
18
|
-
_id: await sha256([`${obj.item._id}:${obj.discountId}`, obj.amount, obj.currency].join('')),
|
|
19
17
|
amount: obj.amount,
|
|
20
18
|
currency: obj.currency,
|
|
21
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Order } from '@unchainedshop/core-orders';
|
|
2
2
|
import { Context } from '../../../context.js';
|
|
3
|
-
import { Price
|
|
3
|
+
import { Price } from '@unchainedshop/utils';
|
|
4
4
|
|
|
5
5
|
export const OrderGlobalDiscount = {
|
|
6
6
|
_id(
|
|
@@ -25,14 +25,13 @@ export const OrderGlobalDiscount = {
|
|
|
25
25
|
});
|
|
26
26
|
},
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
total(
|
|
29
29
|
obj: Price & {
|
|
30
30
|
order: Order;
|
|
31
31
|
discountId: string;
|
|
32
32
|
},
|
|
33
33
|
) {
|
|
34
34
|
return {
|
|
35
|
-
_id: await sha256([`${obj.order._id}:${obj.discountId}`, obj.amount, obj.currency].join('')),
|
|
36
35
|
amount: obj.amount,
|
|
37
36
|
currency: obj.currency,
|
|
38
37
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
2
1
|
import { Context } from '../../../context.js';
|
|
3
2
|
import { OrderPositionDiscount } from '@unchainedshop/core-orders';
|
|
4
3
|
|
|
@@ -13,9 +12,8 @@ export const OrderItemDiscount = {
|
|
|
13
12
|
});
|
|
14
13
|
},
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
total(obj: OrderPositionDiscount) {
|
|
17
16
|
return {
|
|
18
|
-
_id: await sha256([`${obj.item._id}:${obj.discountId}`, obj.amount, obj.currency].join('')),
|
|
19
17
|
amount: obj.amount,
|
|
20
18
|
currency: obj.currency,
|
|
21
19
|
};
|
|
@@ -5,7 +5,7 @@ import { OrderPosition, OrderPositionDiscount } from '@unchainedshop/core-orders
|
|
|
5
5
|
import { Product } from '@unchainedshop/core-products';
|
|
6
6
|
import { Quotation } from '@unchainedshop/core-quotations';
|
|
7
7
|
import { TokenSurrogate, WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
8
|
-
import { Price
|
|
8
|
+
import { Price } from '@unchainedshop/utils';
|
|
9
9
|
import { ProductPricingSheet } from '@unchainedshop/core';
|
|
10
10
|
|
|
11
11
|
const getPricingSheet = async (orderPosition: OrderPosition, context: Context) => {
|
|
@@ -120,11 +120,7 @@ export const OrderItem = {
|
|
|
120
120
|
const pricing = await getPricingSheet(orderPosition, context);
|
|
121
121
|
|
|
122
122
|
if (pricing.isValid()) {
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
_id: await sha256([orderPosition._id, JSON.stringify(params), JSON.stringify(price)].join('')),
|
|
126
|
-
...price,
|
|
127
|
-
};
|
|
123
|
+
return pricing.total(params);
|
|
128
124
|
}
|
|
129
125
|
return null;
|
|
130
126
|
},
|
|
@@ -137,11 +133,7 @@ export const OrderItem = {
|
|
|
137
133
|
const pricing = await getPricingSheet(orderPosition, context);
|
|
138
134
|
|
|
139
135
|
if (pricing.isValid()) {
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
_id: await sha256([`${orderPosition._id}-unit`, price.amount, pricing.currency].join('')),
|
|
143
|
-
...price,
|
|
144
|
-
};
|
|
136
|
+
return pricing.unitPrice(params);
|
|
145
137
|
}
|
|
146
138
|
return null;
|
|
147
139
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '../../../context.js';
|
|
2
2
|
import { OrderPayment } from '@unchainedshop/core-orders';
|
|
3
|
-
import { Price
|
|
3
|
+
import { Price } from '@unchainedshop/utils';
|
|
4
4
|
|
|
5
5
|
export const OrderPaymentDiscount = {
|
|
6
6
|
_id: (orderDelivery: Price & { discountId: string; item: OrderPayment }) =>
|
|
@@ -15,15 +15,8 @@ export const OrderPaymentDiscount = {
|
|
|
15
15
|
discountId: orderDelivery.discountId,
|
|
16
16
|
}),
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
total(orderDelivery: Price & { discountId: string; item: OrderPayment }) {
|
|
19
19
|
return {
|
|
20
|
-
_id: await sha256(
|
|
21
|
-
[
|
|
22
|
-
`${orderDelivery.item._id}-${orderDelivery.discountId}`,
|
|
23
|
-
orderDelivery.amount,
|
|
24
|
-
orderDelivery.currency,
|
|
25
|
-
].join(''),
|
|
26
|
-
),
|
|
27
20
|
amount: orderDelivery.amount,
|
|
28
21
|
currency: orderDelivery.currency,
|
|
29
22
|
};
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
OrderDelivery,
|
|
12
12
|
} from '@unchainedshop/core-orders';
|
|
13
13
|
import { User } from '@unchainedshop/core-users';
|
|
14
|
-
import { Price
|
|
14
|
+
import { Price } from '@unchainedshop/utils';
|
|
15
15
|
import { OrderPricingSheet } from '@unchainedshop/core';
|
|
16
16
|
|
|
17
17
|
export const Order = {
|
|
@@ -74,18 +74,14 @@ export const Order = {
|
|
|
74
74
|
return order.status;
|
|
75
75
|
},
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
total(order: OrderType, params: { category: string; useNetPrice: boolean }): Price {
|
|
78
78
|
const pricing = OrderPricingSheet({
|
|
79
79
|
calculation: order.calculation,
|
|
80
80
|
currency: order.currency,
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
if (pricing.isValid()) {
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
_id: await sha256([order._id, JSON.stringify(params), JSON.stringify(price)].join('')),
|
|
87
|
-
...price,
|
|
88
|
-
};
|
|
84
|
+
return pricing.total(params);
|
|
89
85
|
}
|
|
90
86
|
return null;
|
|
91
87
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Context } from '../../../context.js';
|
|
2
2
|
import { PaymentProvider as PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
3
|
import { PaymentDirector, PaymentPricingDirector } from '@unchainedshop/core';
|
|
4
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
5
4
|
|
|
6
5
|
export const PaymentProvider = {
|
|
7
6
|
interface(provider: PaymentProviderType) {
|
|
@@ -53,7 +52,6 @@ export const PaymentProvider = {
|
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
return {
|
|
56
|
-
_id: await sha256([paymentProvider._id, country, useNetPrice, order ? order._id : ''].join('')),
|
|
57
55
|
amount: orderPrice.amount,
|
|
58
56
|
currencyCode: orderPrice.currency,
|
|
59
57
|
countryCode: country,
|
|
@@ -7,7 +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
10
|
|
|
12
11
|
export const ConfigurableProduct = {
|
|
13
12
|
...Product,
|
|
@@ -127,15 +126,6 @@ export const ConfigurableProduct = {
|
|
|
127
126
|
const unitPrice = pricing.unitPrice({ useNetPrice });
|
|
128
127
|
|
|
129
128
|
return {
|
|
130
|
-
_id: await sha256(
|
|
131
|
-
[
|
|
132
|
-
proxyProduct._id,
|
|
133
|
-
countryContext,
|
|
134
|
-
quantity,
|
|
135
|
-
useNetPrice,
|
|
136
|
-
requestContext.userId || 'ANONYMOUS',
|
|
137
|
-
].join(''),
|
|
138
|
-
),
|
|
139
129
|
...unitPrice,
|
|
140
130
|
isNetPrice: useNetPrice,
|
|
141
131
|
isTaxable: pricing.taxSum() > 0,
|
|
@@ -152,36 +142,9 @@ export const ConfigurableProduct = {
|
|
|
152
142
|
prices: filteredPrices,
|
|
153
143
|
});
|
|
154
144
|
|
|
155
|
-
const minPriceHash = await sha256(
|
|
156
|
-
[
|
|
157
|
-
product._id,
|
|
158
|
-
minPrice?.isTaxable,
|
|
159
|
-
minPrice?.isNetPrice,
|
|
160
|
-
minPrice?.amount,
|
|
161
|
-
minPrice?.currencyCode,
|
|
162
|
-
].join(''),
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
const maxPriceHash = await sha256(
|
|
166
|
-
[
|
|
167
|
-
product._id,
|
|
168
|
-
maxPrice?.isTaxable,
|
|
169
|
-
maxPrice?.isNetPrice,
|
|
170
|
-
maxPrice?.amount,
|
|
171
|
-
maxPrice?.currencyCode,
|
|
172
|
-
].join(''),
|
|
173
|
-
);
|
|
174
|
-
|
|
175
145
|
return {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
_id: minPriceHash,
|
|
179
|
-
...minPrice,
|
|
180
|
-
},
|
|
181
|
-
maxPrice: {
|
|
182
|
-
_id: maxPriceHash,
|
|
183
|
-
...maxPrice,
|
|
184
|
-
},
|
|
146
|
+
minPrice,
|
|
147
|
+
maxPrice,
|
|
185
148
|
};
|
|
186
149
|
},
|
|
187
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,7 +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 { sha256 } from '@unchainedshop/utils';
|
|
9
8
|
|
|
10
9
|
export const PlanProduct = {
|
|
11
10
|
...Product,
|
|
@@ -56,9 +55,6 @@ export const PlanProduct = {
|
|
|
56
55
|
const unitPrice = pricing.unitPrice({ useNetPrice });
|
|
57
56
|
|
|
58
57
|
return {
|
|
59
|
-
_id: await sha256(
|
|
60
|
-
[obj._id, countryContext, quantity, useNetPrice, user ? user._id : 'ANONYMOUS'].join(''),
|
|
61
|
-
),
|
|
62
58
|
...unitPrice,
|
|
63
59
|
isNetPrice: useNetPrice,
|
|
64
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';
|
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
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
4
|
-
export declare const Dispatch: {
|
|
5
|
-
_id: (params: {
|
|
6
|
-
product: Product;
|
|
7
|
-
deliveryProvider: DeliveryProvider;
|
|
8
|
-
warehousingProvider: WarehousingProvider;
|
|
9
|
-
referenceDate: Date;
|
|
10
|
-
quantity: number;
|
|
11
|
-
country: string;
|
|
12
|
-
userId?: string;
|
|
13
|
-
}) => Promise<string>;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=dispatch-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/dispatch-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,eAAO,MAAM,QAAQ;kBACC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,aAAa,EAAE,IAAI,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAYF,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
2
|
-
export const Dispatch = {
|
|
3
|
-
_id: async (params) => await sha256([
|
|
4
|
-
params.product._id,
|
|
5
|
-
params.deliveryProvider._id,
|
|
6
|
-
params.warehousingProvider._id,
|
|
7
|
-
params.referenceDate,
|
|
8
|
-
params.quantity,
|
|
9
|
-
params.country,
|
|
10
|
-
params.userId || 'ANONYMOUS',
|
|
11
|
-
].join('')),
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=dispatch-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/dispatch-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,GAAG,EAAE,KAAK,EAAE,MAQX,EAAE,EAAE,CACH,MAAM,MAAM,CACV;QACE,MAAM,CAAC,OAAO,CAAC,GAAG;QAClB,MAAM,CAAC,gBAAgB,CAAC,GAAG;QAC3B,MAAM,CAAC,mBAAmB,CAAC,GAAG;QAC9B,MAAM,CAAC,aAAa;QACpB,MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,MAAM,IAAI,WAAW;KAC7B,CAAC,IAAI,CAAC,EAAE,CAAC,CACX;CACJ,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
4
|
-
export declare const Stock: {
|
|
5
|
-
_id: (params: {
|
|
6
|
-
product: Product;
|
|
7
|
-
deliveryProvider: DeliveryProvider;
|
|
8
|
-
warehousingProvider: WarehousingProvider;
|
|
9
|
-
referenceDate: Date;
|
|
10
|
-
country: string;
|
|
11
|
-
userId?: string;
|
|
12
|
-
}) => Promise<string>;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=stock-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stock-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/stock-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,eAAO,MAAM,KAAK;kBACI;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,aAAa,EAAE,IAAI,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAWF,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
2
|
-
export const Stock = {
|
|
3
|
-
_id: async (params) => await sha256([
|
|
4
|
-
params.product._id,
|
|
5
|
-
params.deliveryProvider._id,
|
|
6
|
-
params.warehousingProvider._id,
|
|
7
|
-
params.referenceDate,
|
|
8
|
-
params.country,
|
|
9
|
-
params.userId || 'ANONYMOUS',
|
|
10
|
-
].join('')),
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=stock-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stock-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/stock-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,KAAK,EAAE,MAOX,EAAE,EAAE,CACH,MAAM,MAAM,CACV;QACE,MAAM,CAAC,OAAO,CAAC,GAAG;QAClB,MAAM,CAAC,gBAAgB,CAAC,GAAG;QAC3B,MAAM,CAAC,mBAAmB,CAAC,GAAG;QAC9B,MAAM,CAAC,aAAa;QACpB,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,MAAM,IAAI,WAAW;KAC7B,CAAC,IAAI,CAAC,EAAE,CAAC,CACX;CACJ,CAAC"}
|
|
@@ -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
|
-
};
|