@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.
Files changed (158) hide show
  1. package/lib/api-index.d.ts +1 -1
  2. package/lib/api-index.d.ts.map +1 -1
  3. package/lib/api-index.js +1 -1
  4. package/lib/api-index.js.map +1 -1
  5. package/lib/context.d.ts +0 -1
  6. package/lib/context.d.ts.map +1 -1
  7. package/lib/context.js +4 -19
  8. package/lib/context.js.map +1 -1
  9. package/lib/express/createBulkImportMiddleware.d.ts +1 -2
  10. package/lib/express/createBulkImportMiddleware.d.ts.map +1 -1
  11. package/lib/express/createBulkImportMiddleware.js.map +1 -1
  12. package/lib/express/createERCMetadataMiddleware.js +1 -1
  13. package/lib/express/createERCMetadataMiddleware.js.map +1 -1
  14. package/lib/express/index.d.ts.map +1 -1
  15. package/lib/express/index.js.map +1 -1
  16. package/lib/fastify/index.d.ts.map +1 -1
  17. package/lib/fastify/index.js.map +1 -1
  18. package/lib/resolvers/mutations/orders/addCartDiscount.d.ts.map +1 -1
  19. package/lib/resolvers/mutations/orders/addCartDiscount.js +8 -3
  20. package/lib/resolvers/mutations/orders/addCartDiscount.js.map +1 -1
  21. package/lib/resolvers/mutations/orders/addCartProduct.d.ts.map +1 -1
  22. package/lib/resolvers/mutations/orders/addCartProduct.js +8 -3
  23. package/lib/resolvers/mutations/orders/addCartProduct.js.map +1 -1
  24. package/lib/resolvers/mutations/orders/addCartQuotation.d.ts.map +1 -1
  25. package/lib/resolvers/mutations/orders/addCartQuotation.js +8 -3
  26. package/lib/resolvers/mutations/orders/addCartQuotation.js.map +1 -1
  27. package/lib/resolvers/mutations/orders/addMultipleCartProducts.d.ts.map +1 -1
  28. package/lib/resolvers/mutations/orders/addMultipleCartProducts.js +8 -3
  29. package/lib/resolvers/mutations/orders/addMultipleCartProducts.js.map +1 -1
  30. package/lib/resolvers/mutations/orders/checkoutCart.d.ts.map +1 -1
  31. package/lib/resolvers/mutations/orders/checkoutCart.js +10 -5
  32. package/lib/resolvers/mutations/orders/checkoutCart.js.map +1 -1
  33. package/lib/resolvers/mutations/orders/emptyCart.d.ts.map +1 -1
  34. package/lib/resolvers/mutations/orders/emptyCart.js +8 -3
  35. package/lib/resolvers/mutations/orders/emptyCart.js.map +1 -1
  36. package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js +1 -1
  37. package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js.map +1 -1
  38. package/lib/resolvers/mutations/orders/updateCart.d.ts.map +1 -1
  39. package/lib/resolvers/mutations/orders/updateCart.js +8 -3
  40. package/lib/resolvers/mutations/orders/updateCart.js.map +1 -1
  41. package/lib/resolvers/type/delivery-provider-types.d.ts +0 -1
  42. package/lib/resolvers/type/delivery-provider-types.d.ts.map +1 -1
  43. package/lib/resolvers/type/delivery-provider-types.js +0 -2
  44. package/lib/resolvers/type/delivery-provider-types.js.map +1 -1
  45. package/lib/resolvers/type/filter/loaded-filter-types.d.ts.map +1 -1
  46. package/lib/resolvers/type/filter/loaded-filter-types.js +1 -2
  47. package/lib/resolvers/type/filter/loaded-filter-types.js.map +1 -1
  48. package/lib/resolvers/type/index.d.ts +11 -45
  49. package/lib/resolvers/type/index.d.ts.map +1 -1
  50. package/lib/resolvers/type/index.js +0 -4
  51. package/lib/resolvers/type/index.js.map +1 -1
  52. package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +2 -3
  53. package/lib/resolvers/type/order/order-delivery-discount-types.d.ts.map +1 -1
  54. package/lib/resolvers/type/order/order-delivery-discount-types.js +1 -3
  55. package/lib/resolvers/type/order/order-delivery-discount-types.js.map +1 -1
  56. package/lib/resolvers/type/order/order-global-discount-types.d.ts +2 -3
  57. package/lib/resolvers/type/order/order-global-discount-types.d.ts.map +1 -1
  58. package/lib/resolvers/type/order/order-global-discount-types.js +1 -3
  59. package/lib/resolvers/type/order/order-global-discount-types.js.map +1 -1
  60. package/lib/resolvers/type/order/order-item-discount-types.d.ts +2 -3
  61. package/lib/resolvers/type/order/order-item-discount-types.d.ts.map +1 -1
  62. package/lib/resolvers/type/order/order-item-discount-types.js +1 -3
  63. package/lib/resolvers/type/order/order-item-discount-types.js.map +1 -1
  64. package/lib/resolvers/type/order/order-item-types.d.ts.map +1 -1
  65. package/lib/resolvers/type/order/order-item-types.js +2 -11
  66. package/lib/resolvers/type/order/order-item-types.js.map +1 -1
  67. package/lib/resolvers/type/order/order-payment-discount-types.d.ts +2 -3
  68. package/lib/resolvers/type/order/order-payment-discount-types.d.ts.map +1 -1
  69. package/lib/resolvers/type/order/order-payment-discount-types.js +1 -7
  70. package/lib/resolvers/type/order/order-payment-discount-types.js.map +1 -1
  71. package/lib/resolvers/type/order/order-types.d.ts +1 -1
  72. package/lib/resolvers/type/order/order-types.d.ts.map +1 -1
  73. package/lib/resolvers/type/order/order-types.js +2 -7
  74. package/lib/resolvers/type/order/order-types.js.map +1 -1
  75. package/lib/resolvers/type/payment/payment-provider-types.d.ts +0 -1
  76. package/lib/resolvers/type/payment/payment-provider-types.d.ts.map +1 -1
  77. package/lib/resolvers/type/payment/payment-provider-types.js +0 -2
  78. package/lib/resolvers/type/payment/payment-provider-types.js.map +1 -1
  79. package/lib/resolvers/type/price-types.d.ts +0 -1
  80. package/lib/resolvers/type/price-types.d.ts.map +1 -1
  81. package/lib/resolvers/type/price-types.js.map +1 -1
  82. package/lib/resolvers/type/product/product-configurable-types.d.ts.map +1 -1
  83. package/lib/resolvers/type/product/product-configurable-types.js +5 -36
  84. package/lib/resolvers/type/product/product-configurable-types.js.map +1 -1
  85. package/lib/resolvers/type/product/product-discount.d.ts +2 -3
  86. package/lib/resolvers/type/product/product-discount.d.ts.map +1 -1
  87. package/lib/resolvers/type/product/product-discount.js +2 -4
  88. package/lib/resolvers/type/product/product-discount.js.map +1 -1
  89. package/lib/resolvers/type/product/product-plan-types.d.ts.map +1 -1
  90. package/lib/resolvers/type/product/product-plan-types.js +3 -7
  91. package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
  92. package/lib/resolvers/type/product/product-simple-types.d.ts +0 -2
  93. package/lib/resolvers/type/product/product-simple-types.d.ts.map +1 -1
  94. package/lib/resolvers/type/product/product-simple-types.js +13 -50
  95. package/lib/resolvers/type/product/product-simple-types.js.map +1 -1
  96. package/lib/resolvers/type/product/product-tokenized-types.d.ts +0 -1
  97. package/lib/resolvers/type/product/product-tokenized-types.d.ts.map +1 -1
  98. package/lib/resolvers/type/product/product-tokenized-types.js +5 -23
  99. package/lib/resolvers/type/product/product-tokenized-types.js.map +1 -1
  100. package/lib/resolvers/type/user-types.d.ts.map +1 -1
  101. package/lib/resolvers/type/user-types.js +2 -2
  102. package/lib/resolvers/type/user-types.js.map +1 -1
  103. package/lib/schema/inputTypes.d.ts.map +1 -1
  104. package/lib/schema/inputTypes.js +0 -1
  105. package/lib/schema/inputTypes.js.map +1 -1
  106. package/lib/schema/types/dispatch.d.ts.map +1 -1
  107. package/lib/schema/types/dispatch.js +0 -1
  108. package/lib/schema/types/dispatch.js.map +1 -1
  109. package/lib/schema/types/price.d.ts.map +1 -1
  110. package/lib/schema/types/price.js +0 -2
  111. package/lib/schema/types/price.js.map +1 -1
  112. package/lib/schema/types/stock.d.ts.map +1 -1
  113. package/lib/schema/types/stock.js +0 -1
  114. package/lib/schema/types/stock.js.map +1 -1
  115. package/package.json +10 -7
  116. package/src/api-index.ts +1 -1
  117. package/src/context.ts +4 -20
  118. package/src/express/createBulkImportMiddleware.ts +1 -2
  119. package/src/express/createERCMetadataMiddleware.ts +1 -1
  120. package/src/express/index.ts +1 -2
  121. package/src/fastify/index.ts +2 -3
  122. package/src/resolvers/mutations/orders/addCartDiscount.ts +7 -2
  123. package/src/resolvers/mutations/orders/addCartProduct.ts +8 -2
  124. package/src/resolvers/mutations/orders/addCartQuotation.ts +7 -2
  125. package/src/resolvers/mutations/orders/addMultipleCartProducts.ts +7 -2
  126. package/src/resolvers/mutations/orders/checkoutCart.ts +9 -5
  127. package/src/resolvers/mutations/orders/emptyCart.ts +7 -3
  128. package/src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts +1 -1
  129. package/src/resolvers/mutations/orders/updateCart.ts +7 -3
  130. package/src/resolvers/type/delivery-provider-types.ts +0 -3
  131. package/src/resolvers/type/filter/loaded-filter-types.ts +1 -2
  132. package/src/resolvers/type/index.ts +0 -4
  133. package/src/resolvers/type/order/order-delivery-discount-types.ts +1 -3
  134. package/src/resolvers/type/order/order-global-discount-types.ts +2 -3
  135. package/src/resolvers/type/order/order-item-discount-types.ts +1 -3
  136. package/src/resolvers/type/order/order-item-types.ts +3 -11
  137. package/src/resolvers/type/order/order-payment-discount-types.ts +2 -9
  138. package/src/resolvers/type/order/order-types.ts +3 -7
  139. package/src/resolvers/type/payment/payment-provider-types.ts +0 -2
  140. package/src/resolvers/type/price-types.ts +0 -1
  141. package/src/resolvers/type/product/product-configurable-types.ts +5 -49
  142. package/src/resolvers/type/product/product-discount.ts +2 -4
  143. package/src/resolvers/type/product/product-plan-types.ts +3 -11
  144. package/src/resolvers/type/product/product-simple-types.ts +14 -75
  145. package/src/resolvers/type/product/product-tokenized-types.ts +5 -35
  146. package/src/resolvers/type/user-types.ts +4 -2
  147. package/src/schema/inputTypes.ts +0 -1
  148. package/src/schema/types/dispatch.ts +0 -1
  149. package/src/schema/types/price.ts +0 -2
  150. package/src/schema/types/stock.ts +0 -1
  151. package/tests/api-index.test.ts +4 -4
  152. package/lib/resolvers/mutations/utils/getOrderCart.d.ts +0 -7
  153. package/lib/resolvers/mutations/utils/getOrderCart.d.ts.map +0 -1
  154. package/lib/resolvers/mutations/utils/getOrderCart.js +0 -17
  155. package/lib/resolvers/mutations/utils/getOrderCart.js.map +0 -1
  156. package/src/resolvers/mutations/utils/getOrderCart.ts +0 -20
  157. package/src/resolvers/type/dispatch-types.ts +0 -27
  158. 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 calculated = await ProductPricingDirector.rebuildCalculation(pricingContext, requestContext);
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 { deliveryProviderType, referenceDate, quantity } = params;
26
- const { modules, services } = requestContext;
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
- const director = await WarehousingDirector.actions(
50
- warehousingProvider,
51
- warehousingContext,
52
- requestContext,
53
- );
54
- const dispatch = await director.estimatedDispatch();
26
+ const deliveryProviders = await modules.delivery.findProviders({});
55
27
 
56
- return {
57
- warehousingProvider,
58
- ...warehousingContext,
59
- ...dispatch,
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 deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
91
- const result = await oldResult;
92
-
93
- const warehousingProviders = await services.orders.supportedWarehousingProviders({
94
- product: obj,
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 deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
55
- const result = await oldResult;
56
-
57
- const warehousingProviders = await services.orders.supportedWarehousingProviders({
58
- product: obj,
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 || []).sort((left, right) => Number(right.verified) - Number(left.verified))?.[0];
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
- countryContext: countryContext || user.lastLogin?.countryCode,
179
+ countryCode: countryContext,
178
180
  orderNumber: params.orderNumber,
179
181
  userId: user._id,
180
182
  });
@@ -45,7 +45,6 @@ export default [
45
45
  isoCode: String!
46
46
  isActive: Boolean
47
47
  defaultCurrencyCode: String
48
- defaultCurrencyId: String @deprecated(reason: "Use defaultCurrencyCode instead")
49
48
  }
50
49
 
51
50
  input CreateCurrencyInput {
@@ -1,7 +1,6 @@
1
1
  export default [
2
2
  /* GraphQL */ `
3
3
  type Dispatch {
4
- _id: ID!
5
4
  deliveryProvider: DeliveryProvider
6
5
  warehousingProvider: WarehousingProvider
7
6
  shipping: DateTime
@@ -1,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,7 +1,6 @@
1
1
  export default [
2
2
  /* GraphQL */ `
3
3
  type Stock {
4
- _id: ID!
5
4
  deliveryProvider: DeliveryProvider
6
5
  warehousingProvider: WarehousingProvider
7
6
  quantity: Int
@@ -1,8 +1,8 @@
1
1
  // Import the function to be tested.
2
- import { admin } from '../lib/roles/admin.js';
3
- import { actions } from '../lib/roles/index.js';
4
- import { checkAction, ensureActionExists, ensureIsFunction } from '../lib/acl.js';
5
- import { NoPermissionError, PermissionSystemError } from '../lib/errors.js';
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,7 +0,0 @@
1
- import { Context } from '../../../context.js';
2
- import { User } from '@unchainedshop/core-users';
3
- export declare const getOrderCart: (params: {
4
- orderId?: string;
5
- user: User;
6
- }, context: Context) => Promise<any>;
7
- //# sourceMappingURL=getOrderCart.d.ts.map
@@ -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
- };