@unchainedshop/core 3.1.13 → 4.0.0-rc.3

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 (205) hide show
  1. package/lib/directors/BaseDiscountAdapter.js +0 -1
  2. package/lib/directors/BaseDiscountAdapter.js.map +1 -1
  3. package/lib/directors/BaseDiscountDirector.d.ts +1 -1
  4. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
  5. package/lib/directors/BasePricingAdapter.d.ts +4 -4
  6. package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
  7. package/lib/directors/BasePricingDirector.d.ts +2 -2
  8. package/lib/directors/BasePricingDirector.d.ts.map +1 -1
  9. package/lib/directors/BasePricingDirector.js.map +1 -1
  10. package/lib/directors/BasePricingSheet.d.ts +10 -10
  11. package/lib/directors/BasePricingSheet.d.ts.map +1 -1
  12. package/lib/directors/BasePricingSheet.js +2 -2
  13. package/lib/directors/BasePricingSheet.js.map +1 -1
  14. package/lib/directors/DeliveryAdapter.d.ts +2 -2
  15. package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
  16. package/lib/directors/DeliveryDirector.d.ts.map +1 -1
  17. package/lib/directors/DeliveryDirector.js +1 -3
  18. package/lib/directors/DeliveryDirector.js.map +1 -1
  19. package/lib/directors/DeliveryPricingAdapter.d.ts +3 -3
  20. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
  21. package/lib/directors/DeliveryPricingAdapter.js +2 -2
  22. package/lib/directors/DeliveryPricingAdapter.js.map +1 -1
  23. package/lib/directors/DeliveryPricingDirector.d.ts +3 -3
  24. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
  25. package/lib/directors/DeliveryPricingDirector.js +6 -6
  26. package/lib/directors/DeliveryPricingDirector.js.map +1 -1
  27. package/lib/directors/DeliveryPricingSheet.js +2 -2
  28. package/lib/directors/DeliveryPricingSheet.js.map +1 -1
  29. package/lib/directors/EnrollmentAdapter.d.ts +3 -3
  30. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
  31. package/lib/directors/EnrollmentAdapter.js.map +1 -1
  32. package/lib/directors/FilterAdapter.d.ts +9 -12
  33. package/lib/directors/FilterAdapter.d.ts.map +1 -1
  34. package/lib/directors/FilterAdapter.js +0 -4
  35. package/lib/directors/FilterAdapter.js.map +1 -1
  36. package/lib/directors/FilterDirector.d.ts +9 -9
  37. package/lib/directors/FilterDirector.d.ts.map +1 -1
  38. package/lib/directors/FilterDirector.js.map +1 -1
  39. package/lib/directors/MessagingDirector.d.ts +11 -15
  40. package/lib/directors/MessagingDirector.d.ts.map +1 -1
  41. package/lib/directors/OrderPricingAdapter.d.ts +3 -3
  42. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
  43. package/lib/directors/OrderPricingAdapter.js +2 -2
  44. package/lib/directors/OrderPricingAdapter.js.map +1 -1
  45. package/lib/directors/OrderPricingDirector.d.ts +2 -2
  46. package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
  47. package/lib/directors/OrderPricingDirector.js +4 -4
  48. package/lib/directors/OrderPricingDirector.js.map +1 -1
  49. package/lib/directors/OrderPricingSheet.js +2 -2
  50. package/lib/directors/OrderPricingSheet.js.map +1 -1
  51. package/lib/directors/PaymentAdapter.d.ts +2 -2
  52. package/lib/directors/PaymentAdapter.d.ts.map +1 -1
  53. package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
  54. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
  55. package/lib/directors/PaymentPricingAdapter.js +2 -2
  56. package/lib/directors/PaymentPricingAdapter.js.map +1 -1
  57. package/lib/directors/PaymentPricingDirector.d.ts +3 -3
  58. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
  59. package/lib/directors/PaymentPricingDirector.js +6 -6
  60. package/lib/directors/PaymentPricingDirector.js.map +1 -1
  61. package/lib/directors/PaymentPricingSheet.js +1 -1
  62. package/lib/directors/PaymentPricingSheet.js.map +1 -1
  63. package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
  64. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
  65. package/lib/directors/ProductPricingAdapter.d.ts +3 -3
  66. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
  67. package/lib/directors/ProductPricingAdapter.js +2 -2
  68. package/lib/directors/ProductPricingAdapter.js.map +1 -1
  69. package/lib/directors/ProductPricingDirector.d.ts +5 -5
  70. package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
  71. package/lib/directors/ProductPricingDirector.js +6 -6
  72. package/lib/directors/ProductPricingDirector.js.map +1 -1
  73. package/lib/directors/ProductPricingSheet.js +2 -2
  74. package/lib/directors/ProductPricingSheet.js.map +1 -1
  75. package/lib/directors/QuotationAdapter.d.ts +2 -2
  76. package/lib/directors/QuotationAdapter.d.ts.map +1 -1
  77. package/lib/directors/WarehousingAdapter.d.ts +3 -3
  78. package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
  79. package/lib/directors/WarehousingDirector.d.ts +3 -3
  80. package/lib/directors/WarehousingDirector.d.ts.map +1 -1
  81. package/lib/directors/WorkerDirector.d.ts +2 -2
  82. package/lib/directors/WorkerDirector.d.ts.map +1 -1
  83. package/lib/directors/index.d.ts +4 -0
  84. package/lib/directors/index.d.ts.map +1 -1
  85. package/lib/directors/index.js +4 -0
  86. package/lib/directors/index.js.map +1 -1
  87. package/lib/services/calculateDiscountTotal.d.ts +1 -1
  88. package/lib/services/calculateDiscountTotal.js +5 -5
  89. package/lib/services/calculateDiscountTotal.js.map +1 -1
  90. package/lib/services/createEnrollmentFromCheckout.d.ts +3 -3
  91. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
  92. package/lib/services/createEnrollmentFromCheckout.js +1 -1
  93. package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
  94. package/lib/services/discountedEntities.d.ts +1 -1
  95. package/lib/services/discountedEntities.d.ts.map +1 -1
  96. package/lib/services/discountedEntities.js +4 -4
  97. package/lib/services/discountedEntities.js.map +1 -1
  98. package/lib/services/ercMetadata.d.ts +5 -3
  99. package/lib/services/ercMetadata.d.ts.map +1 -1
  100. package/lib/services/ercMetadata.js +2 -11
  101. package/lib/services/ercMetadata.js.map +1 -1
  102. package/lib/services/index.d.ts +1 -3
  103. package/lib/services/index.d.ts.map +1 -1
  104. package/lib/services/index.js.map +1 -1
  105. package/lib/services/loadFilters.d.ts +1 -1
  106. package/lib/services/loadFilters.d.ts.map +1 -1
  107. package/lib/services/loadFilters.js.map +1 -1
  108. package/lib/services/migrateBookmarks.d.ts +1 -1
  109. package/lib/services/migrateBookmarks.d.ts.map +1 -1
  110. package/lib/services/migrateOrderCart.d.ts +2 -2
  111. package/lib/services/migrateOrderCart.d.ts.map +1 -1
  112. package/lib/services/migrateOrderCart.js +3 -3
  113. package/lib/services/migrateOrderCart.js.map +1 -1
  114. package/lib/services/migrateUserData.js +2 -2
  115. package/lib/services/migrateUserData.js.map +1 -1
  116. package/lib/services/nextUserCart.js +2 -2
  117. package/lib/services/nextUserCart.js.map +1 -1
  118. package/lib/services/processOrder.d.ts.map +1 -1
  119. package/lib/services/processOrder.js +1 -3
  120. package/lib/services/processOrder.js.map +1 -1
  121. package/lib/services/removeFiles.d.ts +1 -1
  122. package/lib/services/removeFiles.d.ts.map +1 -1
  123. package/lib/services/removeFiles.js +1 -1
  124. package/lib/services/removeFiles.js.map +1 -1
  125. package/lib/services/searchProducts.d.ts.map +1 -1
  126. package/lib/services/searchProducts.js +1 -2
  127. package/lib/services/searchProducts.js.map +1 -1
  128. package/lib/services/simulateProductDispatching.d.ts +1 -3
  129. package/lib/services/simulateProductDispatching.d.ts.map +1 -1
  130. package/lib/services/simulateProductDispatching.js +2 -1
  131. package/lib/services/simulateProductDispatching.js.map +1 -1
  132. package/lib/services/simulateProductInventory.d.ts +1 -3
  133. package/lib/services/simulateProductInventory.d.ts.map +1 -1
  134. package/lib/services/simulateProductInventory.js +2 -1
  135. package/lib/services/simulateProductInventory.js.map +1 -1
  136. package/lib/services/simulateProductPricing.d.ts +3 -3
  137. package/lib/services/simulateProductPricing.d.ts.map +1 -1
  138. package/lib/services/supportedDeliveryProviders.js +1 -1
  139. package/lib/services/supportedDeliveryProviders.js.map +1 -1
  140. package/lib/services/supportedPaymentProviders.js +1 -1
  141. package/lib/services/supportedPaymentProviders.js.map +1 -1
  142. package/lib/services/supportedWarehousingProviders.js +1 -1
  143. package/lib/services/supportedWarehousingProviders.js.map +1 -1
  144. package/lib/services/updateCalculation.d.ts.map +1 -1
  145. package/lib/services/updateCalculation.js +4 -5
  146. package/lib/services/updateCalculation.js.map +1 -1
  147. package/lib/services/updateScheduling.js +1 -1
  148. package/lib/services/updateScheduling.js.map +1 -1
  149. package/package.json +21 -20
  150. package/src/directors/BaseDiscountAdapter.ts +1 -1
  151. package/src/directors/BaseDiscountDirector.ts +1 -1
  152. package/src/directors/BasePricingAdapter.ts +4 -4
  153. package/src/directors/BasePricingDirector.ts +4 -10
  154. package/src/directors/BasePricingSheet.ts +12 -12
  155. package/src/directors/BaseWorker.ts +117 -0
  156. package/src/directors/DeliveryAdapter.ts +2 -2
  157. package/src/directors/DeliveryDirector.ts +1 -3
  158. package/src/directors/DeliveryPricingAdapter.ts +5 -5
  159. package/src/directors/DeliveryPricingDirector.ts +9 -9
  160. package/src/directors/DeliveryPricingSheet.ts +2 -2
  161. package/src/directors/EnrollmentAdapter.ts +3 -6
  162. package/src/directors/EventListenerWorker.ts +101 -0
  163. package/src/directors/FailedRescheduler.ts +73 -0
  164. package/src/directors/FilterAdapter.ts +11 -11
  165. package/src/directors/FilterDirector.ts +16 -16
  166. package/src/directors/IntervalWorker.ts +75 -0
  167. package/src/directors/MessagingDirector.ts +10 -10
  168. package/src/directors/OrderPricingAdapter.ts +5 -5
  169. package/src/directors/OrderPricingDirector.ts +6 -6
  170. package/src/directors/OrderPricingSheet.ts +2 -2
  171. package/src/directors/PaymentAdapter.ts +2 -2
  172. package/src/directors/PaymentPricingAdapter.ts +4 -4
  173. package/src/directors/PaymentPricingDirector.ts +9 -9
  174. package/src/directors/PaymentPricingSheet.ts +1 -1
  175. package/src/directors/ProductDiscountConfiguration.ts +1 -1
  176. package/src/directors/ProductPricingAdapter.ts +5 -5
  177. package/src/directors/ProductPricingDirector.ts +11 -11
  178. package/src/directors/ProductPricingSheet.test.ts +22 -13
  179. package/src/directors/ProductPricingSheet.ts +2 -2
  180. package/src/directors/QuotationAdapter.ts +2 -2
  181. package/src/directors/WarehousingAdapter.ts +3 -3
  182. package/src/directors/WarehousingDirector.ts +3 -3
  183. package/src/directors/WorkerDirector.ts +2 -2
  184. package/src/directors/index.ts +4 -0
  185. package/src/services/calculateDiscountTotal.ts +5 -5
  186. package/src/services/createEnrollmentFromCheckout.ts +4 -4
  187. package/src/services/discountedEntities.ts +5 -5
  188. package/src/services/ercMetadata.ts +6 -14
  189. package/src/services/index.ts +1 -3
  190. package/src/services/loadFilters.ts +1 -1
  191. package/src/services/migrateBookmarks.ts +1 -1
  192. package/src/services/migrateOrderCart.ts +4 -4
  193. package/src/services/migrateUserData.ts +2 -2
  194. package/src/services/nextUserCart.ts +2 -2
  195. package/src/services/processOrder.ts +4 -3
  196. package/src/services/removeFiles.ts +2 -2
  197. package/src/services/searchProducts.ts +1 -3
  198. package/src/services/simulateProductDispatching.ts +3 -4
  199. package/src/services/simulateProductInventory.ts +3 -4
  200. package/src/services/simulateProductPricing.ts +3 -3
  201. package/src/services/supportedDeliveryProviders.ts +1 -1
  202. package/src/services/supportedPaymentProviders.ts +1 -1
  203. package/src/services/supportedWarehousingProviders.ts +1 -1
  204. package/src/services/updateCalculation.ts +4 -5
  205. package/src/services/updateScheduling.ts +2 -2
@@ -12,16 +12,16 @@ export async function createEnrollmentFromCheckoutService(
12
12
  items,
13
13
  context,
14
14
  }: {
15
- items: Array<{
15
+ items: {
16
16
  orderPosition: OrderPosition;
17
17
  product: Product;
18
- }>;
18
+ }[];
19
19
  context: {
20
20
  paymentContext?: any;
21
21
  deliveryContext?: any;
22
22
  };
23
23
  },
24
- ): Promise<Array<Enrollment>> {
24
+ ): Promise<Enrollment[]> {
25
25
  const orderId = order._id;
26
26
 
27
27
  const payment = await this.orders.payments.findOrderPayment({
@@ -35,7 +35,7 @@ export async function createEnrollmentFromCheckoutService(
35
35
  billingAddress: order.billingAddress,
36
36
  contact: order.contact,
37
37
  countryCode: order.countryCode,
38
- currencyCode: order.currency,
38
+ currencyCode: order.currencyCode,
39
39
  delivery: {
40
40
  deliveryProviderId: delivery.deliveryProviderId,
41
41
  context: delivery.context,
@@ -12,7 +12,7 @@ export async function discountedEntitiesService(
12
12
  this: Modules,
13
13
  order: Order,
14
14
  orderDiscount: OrderDiscount,
15
- ): Promise<Array<OrderPricingDiscount>> {
15
+ ): Promise<OrderPricingDiscount[]> {
16
16
  // Delivery discounts
17
17
  const orderDelivery = await this.orders.deliveries.findDelivery({
18
18
  orderDeliveryId: order.deliveryId,
@@ -20,7 +20,7 @@ export async function discountedEntitiesService(
20
20
 
21
21
  const deliveryPricingSheet = DeliveryPricingSheet({
22
22
  calculation: orderDelivery.calculation || [],
23
- currency: order.currency,
23
+ currencyCode: order.currencyCode,
24
24
  });
25
25
  const orderDeliveryDiscounts = deliveryPricingSheet
26
26
  .discountPrices(orderDiscount._id)
@@ -35,7 +35,7 @@ export async function discountedEntitiesService(
35
35
  });
36
36
  const paymentPricingSheet = PaymentPricingSheet({
37
37
  calculation: orderPayment.calculation || [],
38
- currency: order.currency,
38
+ currencyCode: order.currencyCode,
39
39
  });
40
40
  const orderPaymentDiscounts = paymentPricingSheet
41
41
  .discountPrices(orderDiscount._id)
@@ -51,7 +51,7 @@ export async function discountedEntitiesService(
51
51
  const orderPositionDiscounts = orderPositions.flatMap((orderPosition) =>
52
52
  ProductPricingSheet({
53
53
  calculation: orderPosition.calculation,
54
- currency: order.currency,
54
+ currencyCode: order.currencyCode,
55
55
  quantity: orderPosition.quantity,
56
56
  })
57
57
  .discountPrices(orderDiscount._id)
@@ -64,7 +64,7 @@ export async function discountedEntitiesService(
64
64
  // order discounts
65
65
  const orderDiscounts = OrderPricingSheet({
66
66
  calculation: order.calculation || [],
67
- currency: order.currency,
67
+ currencyCode: order.currencyCode,
68
68
  })
69
69
  .discountPrices(orderDiscount._id)
70
70
  .map((discount) => ({ order, ...discount }));
@@ -1,23 +1,15 @@
1
- import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
1
+ import { TokenSurrogate, WarehousingProviderType } from '@unchainedshop/core-warehousing';
2
+ import { Product } from '@unchainedshop/core-products';
2
3
  import { WarehousingDirector } from '../directors/WarehousingDirector.js';
3
4
  import { Modules } from '../modules.js';
4
5
 
5
6
  export async function ercMetadataService(
6
7
  this: Modules,
7
- { productId, chainTokenId, locale }: { productId: string; chainTokenId: string; locale: Intl.Locale },
8
+ { product, token, locale }: { product: Product; token: TokenSurrogate; locale: Intl.Locale },
8
9
  ) {
9
- const product = await this.products.findProduct({
10
- productId,
11
- });
12
-
13
- const [token] = await this.warehousing.findTokens({
14
- chainTokenId,
15
- contractAddress: product?.tokenization?.contractAddress,
16
- });
17
-
18
- const virtualProviders = await this.warehousing.findProviders({
19
- type: WarehousingProviderType.VIRTUAL,
20
- });
10
+ const virtualProviders = (await this.warehousing.allProviders()).filter(
11
+ ({ type }) => type === WarehousingProviderType.VIRTUAL,
12
+ );
21
13
 
22
14
  return await WarehousingDirector.tokenMetadata(
23
15
  virtualProviders,
@@ -62,9 +62,7 @@ function bindMethodsToModules(modules: Modules) {
62
62
  };
63
63
  }
64
64
 
65
- export interface ServiceInterface {
66
- (this: Modules, ...args: any[]): Promise<any> | any;
67
- }
65
+ export type ServiceInterface = (this: Modules, ...args: any[]) => Promise<any> | any;
68
66
 
69
67
  export type Bound<T extends ServiceInterface> = OmitThisParameter<T>;
70
68
 
@@ -5,7 +5,7 @@ import { FilterDirector } from '../directors/FilterDirector.js';
5
5
  export async function loadFiltersService(
6
6
  this: Modules,
7
7
  searchQuery: SearchQuery,
8
- { productIds, forceLiveCollection }: { productIds: Array<string>; forceLiveCollection: boolean },
8
+ { productIds, forceLiveCollection }: { productIds: string[]; forceLiveCollection: boolean },
9
9
  ) {
10
10
  const filterActions = await FilterDirector.actions({ searchQuery }, { modules: this });
11
11
  const filterSelector = await filterActions.transformFilterSelector(defaultFilterSelector(searchQuery));
@@ -14,7 +14,7 @@ export async function migrateBookmarksService(
14
14
  fromUserId: string;
15
15
  toUserId: string;
16
16
  shouldMerge: boolean;
17
- countryContext: string;
17
+ countryCode: string;
18
18
  },
19
19
  ) {
20
20
  const fromBookmarks = await this.bookmarks.findBookmarks({ userId: fromUserId });
@@ -7,20 +7,20 @@ export async function migrateOrderCartsService(
7
7
  fromUserId,
8
8
  toUserId,
9
9
  shouldMerge,
10
- countryContext,
10
+ countryCode,
11
11
  }: {
12
12
  fromUserId: string;
13
13
  toUserId: string;
14
14
  shouldMerge: boolean;
15
- countryContext: string;
15
+ countryCode: string;
16
16
  },
17
17
  ) {
18
18
  const fromCart = await this.orders.cart({
19
- countryCode: countryContext,
19
+ countryCode,
20
20
  userId: fromUserId,
21
21
  });
22
22
  const toCart = await this.orders.cart({
23
- countryCode: countryContext,
23
+ countryCode,
24
24
  userId: toUserId,
25
25
  });
26
26
 
@@ -10,13 +10,13 @@ export async function migrateUserDataService(userIdBeforeLogin: string, userId:
10
10
  fromUserId: userIdBeforeLogin,
11
11
  toUserId: userId,
12
12
  shouldMerge: userSettings.mergeUserCartsOnLogin,
13
- countryContext: userBeforeLogin?.lastLogin?.countryCode || user?.lastLogin?.countryCode,
13
+ countryCode: userBeforeLogin?.lastLogin?.countryCode || user?.lastLogin?.countryCode,
14
14
  });
15
15
 
16
16
  await migrateBookmarksService.bind(this)({
17
17
  fromUserId: userIdBeforeLogin,
18
18
  toUserId: userId,
19
19
  shouldMerge: userSettings.mergeUserCartsOnLogin,
20
- countryContext: userBeforeLogin?.lastLogin?.countryCode || user?.lastLogin?.countryCode,
20
+ countryCode: userBeforeLogin?.lastLogin?.countryCode || user?.lastLogin?.countryCode,
21
21
  });
22
22
  }
@@ -30,12 +30,12 @@ export async function nextUserCartService(
30
30
 
31
31
  const countryObject = await this.countries.findCountry({ isoCode: countryCode });
32
32
  const currencies = await this.currencies.findCurrencies({ includeInactive: false });
33
- const currency = resolveBestCurrency(countryObject.defaultCurrencyCode, currencies);
33
+ const currencyCode = resolveBestCurrency(countryObject.defaultCurrencyCode, currencies);
34
34
 
35
35
  const order = await this.orders.create({
36
36
  userId: user._id,
37
37
  orderNumber,
38
- currency,
38
+ currencyCode,
39
39
  countryCode,
40
40
  billingAddress: user.lastBillingAddress || user.profile?.address,
41
41
  contact:
@@ -175,9 +175,10 @@ export async function processOrderService(
175
175
  );
176
176
  if (tokenizedItems.length > 0) {
177
177
  // Give virtual warehouse a chance to instantiate new virtual objects
178
- const virtualProviders = await this.warehousing.findProviders({
179
- type: WarehousingProviderType.VIRTUAL,
180
- });
178
+ const virtualProviders = (await this.warehousing.allProviders()).filter(
179
+ ({ type }) => type === WarehousingProviderType.VIRTUAL,
180
+ );
181
+
181
182
  // It's very important to do this in a series and not in Promise.all
182
183
  // TODO: Actually, only createTokens should decide on the unique chainTokenId
183
184
  // and the tokens should be created with a distributed Lock to not assign the same id multiple times!
@@ -1,7 +1,7 @@
1
1
  import { getFileAdapter } from '@unchainedshop/core-files';
2
2
  import { Modules } from '../modules.js';
3
3
 
4
- export async function removeFilesService(this: Modules, { fileIds }: { fileIds: Array<string> }) {
4
+ export async function removeFilesService(this: Modules, { fileIds }: { fileIds: string[] }) {
5
5
  if (fileIds && typeof fileIds !== 'string' && !Array.isArray(fileIds))
6
6
  throw Error('Media id/s to be removed not provided as a string or array');
7
7
 
@@ -14,7 +14,7 @@ export async function removeFilesService(this: Modules, { fileIds }: { fileIds:
14
14
  try {
15
15
  await fileUploadAdapter.removeFiles(fileObjects, { modules: this });
16
16
  } catch (e) {
17
- console.warn(e); // eslint-disable-line
17
+ console.warn(e);
18
18
  }
19
19
 
20
20
  const fileIdsToDelete = fileObjects.map((f) => f._id).filter(Boolean);
@@ -47,9 +47,7 @@ export async function searchProductsService(
47
47
  };
48
48
  }
49
49
 
50
- const productIds = await searchQuery.productIds;
51
- const totalProductIds =
52
- (await filterActions.searchProducts({ productIds }, searchConfiguration)) || [];
50
+ const totalProductIds = (await filterActions.searchProducts(searchQuery, searchConfiguration)) || [];
53
51
 
54
52
  const filteredProductIds = await FilterDirector.productFacetedSearch(
55
53
  totalProductIds,
@@ -1,4 +1,3 @@
1
- import { DeliveryProvider } from '@unchainedshop/core-delivery';
2
1
  import { Modules } from '../modules.js';
3
2
  import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
4
3
  import { Product } from '@unchainedshop/core-products';
@@ -9,19 +8,19 @@ import { WarehousingProvider } from '@unchainedshop/core-warehousing';
9
8
  export async function simulateProductDispatchingService(
10
9
  this: Modules,
11
10
  {
12
- deliveryProviders,
13
11
  product,
14
12
  quantity,
15
13
  referenceDate,
16
14
  }: {
17
15
  product: Product;
18
- deliveryProviders: DeliveryProvider[];
19
16
  quantity?: number;
20
17
  referenceDate?: Date;
21
18
  },
22
19
  ) {
20
+ const deliveryProviders = await this.delivery.allProviders();
21
+
23
22
  return deliveryProviders.reduce<
24
- Promise<Array<WarehousingContext & EstimatedDispatch & { warehousingProvider: WarehousingProvider }>>
23
+ Promise<(WarehousingContext & EstimatedDispatch & { warehousingProvider: WarehousingProvider })[]>
25
24
  >(async (oldResult, deliveryProvider) => {
26
25
  const result = await oldResult;
27
26
 
@@ -1,4 +1,3 @@
1
- import { DeliveryProvider } from '@unchainedshop/core-delivery';
2
1
  import { Modules } from '../modules.js';
3
2
  import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
4
3
  import { Product } from '@unchainedshop/core-products';
@@ -9,17 +8,17 @@ import { WarehousingProvider } from '@unchainedshop/core-warehousing';
9
8
  export async function simulateProductInventoryService(
10
9
  this: Modules,
11
10
  {
12
- deliveryProviders,
13
11
  product,
14
12
  referenceDate,
15
13
  }: {
16
14
  product: Product;
17
- deliveryProviders: DeliveryProvider[];
18
15
  referenceDate?: Date;
19
16
  },
20
17
  ) {
18
+ const deliveryProviders = await this.delivery.allProviders();
19
+
21
20
  return deliveryProviders.reduce<
22
- Promise<Array<WarehousingContext & EstimatedStock & { warehousingProvider: WarehousingProvider }>>
21
+ Promise<(WarehousingContext & EstimatedStock & { warehousingProvider: WarehousingProvider })[]>
23
22
  >(async (oldResult, deliveryProvider) => {
24
23
  const result = await oldResult;
25
24
 
@@ -8,10 +8,10 @@ export async function simulateProductPricingService(
8
8
  pricingContext: {
9
9
  product: Product;
10
10
  user: User;
11
- country: string;
12
- currency: string;
11
+ countryCode: string;
12
+ currencyCode: string;
13
13
  quantity: number;
14
- configuration?: Array<ProductConfiguration>;
14
+ configuration?: ProductConfiguration[];
15
15
  },
16
16
  ) {
17
17
  const calculated = await ProductPricingDirector.rebuildCalculation(pricingContext, { modules: this });
@@ -3,7 +3,7 @@ import { Modules } from '../modules.js';
3
3
  import { DeliveryContext, DeliveryDirector } from '../directors/index.js';
4
4
 
5
5
  export async function supportedDeliveryProvidersService(this: Modules, params: DeliveryContext) {
6
- const allProviders = await this.delivery.findProviders({});
6
+ const allProviders = await this.delivery.allProviders();
7
7
 
8
8
  const providers = (
9
9
  await Promise.all(
@@ -4,7 +4,7 @@ import { PaymentContext } from '../directors/PaymentAdapter.js';
4
4
  import { Modules } from '../modules.js';
5
5
 
6
6
  export async function supportedPaymentProvidersService(this: Modules, params: PaymentContext) {
7
- const allProviders = await this.payment.paymentProviders.findProviders({});
7
+ const allProviders = await this.payment.paymentProviders.allProviders();
8
8
 
9
9
  const providers = (
10
10
  await Promise.all(
@@ -3,7 +3,7 @@ import { WarehousingContext, WarehousingDirector } from '../directors/index.js';
3
3
  import { Modules } from '../modules.js';
4
4
 
5
5
  export async function supportedWarehousingProvidersService(this: Modules, params: WarehousingContext) {
6
- const allProviders = await this.warehousing.findProviders({});
6
+ const allProviders = await this.warehousing.allProviders();
7
7
 
8
8
  const providers = (
9
9
  await Promise.all(
@@ -73,10 +73,9 @@ export async function updateCalculationService(this: Modules, orderId: string) {
73
73
  orderPositions.map(async (orderPosition) => {
74
74
  const positionCalculation = await ProductPricingDirector.rebuildCalculation(
75
75
  {
76
- currency: order.currency,
76
+ currencyCode: order.currencyCode,
77
77
  quantity: orderPosition.quantity,
78
78
  item: orderPosition,
79
- configuration: orderPosition.configuration,
80
79
  },
81
80
  { modules: this },
82
81
  );
@@ -90,7 +89,7 @@ export async function updateCalculationService(this: Modules, orderId: string) {
90
89
  if (orderDelivery) {
91
90
  const deliveryCalculation = await DeliveryPricingDirector.rebuildCalculation(
92
91
  {
93
- currency: order.currency,
92
+ currencyCode: order.currencyCode,
94
93
  item: orderDelivery,
95
94
  },
96
95
  { modules: this },
@@ -106,7 +105,7 @@ export async function updateCalculationService(this: Modules, orderId: string) {
106
105
  if (orderPayment) {
107
106
  const paymentCalculation = await PaymentPricingDirector.rebuildCalculation(
108
107
  {
109
- currency: order.currency,
108
+ currencyCode: order.currencyCode,
110
109
  item: orderPayment,
111
110
  },
112
111
  { modules: this },
@@ -121,7 +120,7 @@ export async function updateCalculationService(this: Modules, orderId: string) {
121
120
  });
122
121
 
123
122
  const calculation = await OrderPricingDirector.rebuildCalculation(
124
- { currency: order.currency, order, orderPositions, orderDelivery, orderPayment },
123
+ { currencyCode: order.currencyCode, order, orderPositions, orderDelivery, orderPayment },
125
124
  { modules: this },
126
125
  );
127
126
 
@@ -41,7 +41,7 @@ export async function updateSchedulingService(
41
41
  delivery: deliveryProvider,
42
42
  order,
43
43
  userId,
44
- country: countryCode,
44
+ countryCode,
45
45
  referenceDate: order.ordered,
46
46
  quantity: orderPosition.quantity,
47
47
  };
@@ -60,5 +60,5 @@ export async function updateSchedulingService(
60
60
 
61
61
  return this.orders.positions.updateScheduling(orderPosition._id, scheduling);
62
62
  }),
63
- )) as Array<OrderPosition>;
63
+ )) as OrderPosition[];
64
64
  }