@lookiero/checkout 0.2.10 → 0.2.12

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 (81) hide show
  1. package/README.md +3 -1
  2. package/dist/domain/checkout/command/startCheckout.d.ts +2 -1
  3. package/dist/domain/checkout/model/checkout.d.ts +2 -1
  4. package/dist/domain/checkout/model/checkout.js +1 -1
  5. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -1
  6. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +1 -1
  7. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +2 -1
  8. package/dist/domain/checkoutBooking/model/checkoutBooking.js +7 -5
  9. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +2 -1
  10. package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +1 -1
  11. package/dist/domain/checkoutItem/command/keepCheckoutItem.d.ts +13 -0
  12. package/dist/domain/checkoutItem/command/keepCheckoutItem.js +4 -0
  13. package/dist/domain/checkoutItem/model/checkoutItem.d.ts +15 -0
  14. package/dist/domain/checkoutItem/model/checkoutItem.js +20 -0
  15. package/dist/domain/checkoutItem/model/checkoutItemKept.d.ts +13 -0
  16. package/dist/domain/checkoutItem/model/checkoutItemKept.js +4 -0
  17. package/dist/domain/checkoutItem/model/checkoutItems.d.ts +7 -0
  18. package/dist/domain/checkoutItem/model/checkoutItems.js +1 -0
  19. package/dist/domain/uiSetting/command/updateUiSetting.d.ts +2 -1
  20. package/dist/domain/uiSetting/model/uiSetting.d.ts +2 -1
  21. package/dist/domain/uiSetting/model/uiSetting.js +1 -1
  22. package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +2 -1
  23. package/dist/domain/uiSetting/model/uiSettings.d.ts +1 -1
  24. package/dist/infrastructure/delivery/baseBootstrap.d.ts +18 -4
  25. package/dist/infrastructure/delivery/baseBootstrap.js +13 -6
  26. package/dist/infrastructure/delivery/bootstrap.js +8 -2
  27. package/dist/infrastructure/delivery/bootstrap.mock.js +21 -39
  28. package/dist/infrastructure/delivery/http/fetchHttpClient.js +4 -2
  29. package/dist/infrastructure/delivery/http/httpClient.d.ts +2 -0
  30. package/dist/infrastructure/delivery/mock/checkoutDataSource.d.ts +17 -0
  31. package/dist/infrastructure/delivery/mock/checkoutDataSource.js +18 -0
  32. package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.d.ts +14 -0
  33. package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.js +21 -0
  34. package/dist/infrastructure/delivery/mock/dataSourceCheckouts.d.ts +11 -0
  35. package/dist/infrastructure/delivery/mock/dataSourceCheckouts.js +27 -0
  36. package/dist/infrastructure/domain/checkout/model/httpCheckoutsStart.js +1 -2
  37. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.d.ts +16 -0
  38. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.js +17 -0
  39. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsKeep.d.ts +5 -0
  40. package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsKeep.js +13 -0
  41. package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.d.ts +13 -0
  42. package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.js +12 -0
  43. package/dist/infrastructure/projection/bookedSizeReplaceableProductVariants/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +9 -13
  44. package/dist/infrastructure/projection/checkout/checkout.d.ts +3 -38
  45. package/dist/infrastructure/projection/checkout/checkout.mock.d.ts +2 -1
  46. package/dist/infrastructure/projection/checkout/checkout.mock.js +1 -33
  47. package/dist/infrastructure/projection/checkout/httpCheckoutByIdView.js +2 -1
  48. package/dist/infrastructure/projection/checkout/httpFirstAvailableCheckoutByCustomerIdView.js +2 -1
  49. package/dist/infrastructure/projection/checkout/httpFiveItemsDiscountByCustomerIdView.js +2 -1
  50. package/dist/infrastructure/projection/checkout/httpIsCheckoutEnabledByCustomerIdView.js +2 -1
  51. package/dist/infrastructure/projection/checkoutItem/checkoutItem.d.ts +44 -0
  52. package/dist/infrastructure/projection/checkoutItem/checkoutItem.js +39 -0
  53. package/dist/infrastructure/projection/checkoutItem/checkoutItem.mock.d.ts +18 -0
  54. package/dist/infrastructure/projection/checkoutItem/checkoutItem.mock.js +37 -0
  55. package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.d.ts +12 -0
  56. package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +12 -0
  57. package/dist/infrastructure/ui/components/atoms/price/Price.d.ts +1 -1
  58. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +1 -1
  59. package/dist/infrastructure/ui/views/item/Item.js +1 -3
  60. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -1
  61. package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.js +1 -1
  62. package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.d.ts +1 -1
  63. package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.d.ts +1 -1
  64. package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts +1 -1
  65. package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -2
  66. package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.js +2 -2
  67. package/dist/projection/checkout/checkout.d.ts +2 -68
  68. package/dist/projection/checkout/checkout.js +1 -29
  69. package/dist/projection/checkout/viewCheckoutById.d.ts +2 -2
  70. package/dist/projection/checkout/viewCheckoutById.js +2 -2
  71. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.d.ts +2 -2
  72. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.js +2 -2
  73. package/dist/projection/checkout/viewFiveItemsDiscountByCustomerId.d.ts +2 -2
  74. package/dist/projection/checkout/viewFiveItemsDiscountByCustomerId.js +2 -2
  75. package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.d.ts +2 -2
  76. package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.js +2 -2
  77. package/dist/projection/checkoutItem/checkoutItem.d.ts +62 -0
  78. package/dist/projection/checkoutItem/checkoutItem.js +21 -0
  79. package/dist/projection/checkoutItem/viewCheckoutItemById.d.ts +25 -0
  80. package/dist/projection/checkoutItem/viewCheckoutItemById.js +8 -0
  81. package/package.json +9 -8
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## 💡 Prerequisites
7
7
 
8
- - Node.js >= 14.19.3
8
+ - Node.js ^14.20.0 | ^18.9.0
9
9
  - NPM >= 8
10
10
 
11
11
  ## 🚀 Getting Started
@@ -13,6 +13,8 @@
13
13
  This application is build over **Expo** so, the easiest way to install this library is through NPM.
14
14
 
15
15
  ```shell
16
+ $ nvm use
17
+ $ nvm install --latest-npm
16
18
  $ npm install --legacy-peer-deps
17
19
  ```
18
20
 
@@ -9,4 +9,5 @@ interface StartCheckoutFunction {
9
9
  (payload: StartCheckoutPayload): StartCheckout;
10
10
  }
11
11
  declare const startCheckout: StartCheckoutFunction;
12
- export { START_CHECKOUT, StartCheckout, startCheckout };
12
+ export type { StartCheckout };
13
+ export { START_CHECKOUT, startCheckout };
@@ -14,4 +14,5 @@ interface Checkout extends AggregateRoot {
14
14
  readonly expiresOn: Date;
15
15
  }
16
16
  declare const startCheckoutHandler: CommandHandlerFunction<StartCheckout, Checkout>;
17
- export { Checkout, CheckoutStatus, startCheckoutHandler };
17
+ export type { Checkout };
18
+ export { CheckoutStatus, startCheckoutHandler };
@@ -14,7 +14,7 @@ const startCheckoutHandler = () => async ({ aggregateRoot, command }) => {
14
14
  return {
15
15
  ...aggregateRoot,
16
16
  status: CheckoutStatus.STARTED,
17
- domainEvents: checkoutStarted({ aggregateId }),
17
+ domainEvents: [checkoutStarted({ aggregateId })],
18
18
  };
19
19
  };
20
20
  export { CheckoutStatus, startCheckoutHandler };
@@ -11,4 +11,5 @@ interface BookSizeReplaceableProductVariantsForCheckoutItemFunction {
11
11
  (payload: BookSizeReplaceableProductVariantsForCheckoutItemPayload): BookSizeReplaceableProductVariantsForCheckoutItem;
12
12
  }
13
13
  declare const bookSizeReplaceableProductVariantsForCheckoutItem: BookSizeReplaceableProductVariantsForCheckoutItemFunction;
14
- export { BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, BookSizeReplaceableProductVariantsForCheckoutItem, bookSizeReplaceableProductVariantsForCheckoutItem, };
14
+ export type { BookSizeReplaceableProductVariantsForCheckoutItem };
15
+ export { BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, bookSizeReplaceableProductVariantsForCheckoutItem };
@@ -4,4 +4,4 @@ const bookSizeReplaceableProductVariantsForCheckoutItem = ({ aggregateId, ...pay
4
4
  ...command({ aggregateId, name: BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
5
5
  ...payload,
6
6
  });
7
- export { BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, bookSizeReplaceableProductVariantsForCheckoutItem, };
7
+ export { BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, bookSizeReplaceableProductVariantsForCheckoutItem };
@@ -5,4 +5,5 @@ interface CheckoutBooking extends AggregateRoot {
5
5
  readonly checkoutItemId: string;
6
6
  }
7
7
  declare const bookSizeReplaceableProductVariantsForCheckoutItemHandler: CommandHandlerFunction<BookSizeReplaceableProductVariantsForCheckoutItem, CheckoutBooking>;
8
- export { CheckoutBooking, bookSizeReplaceableProductVariantsForCheckoutItemHandler };
8
+ export type { CheckoutBooking };
9
+ export { bookSizeReplaceableProductVariantsForCheckoutItemHandler };
@@ -5,11 +5,13 @@ const bookSizeReplaceableProductVariantsForCheckoutItemHandler = () => async ({
5
5
  ...aggregateRoot,
6
6
  checkoutId,
7
7
  checkoutItemId,
8
- domainEvents: checkoutBookingBooked({
9
- aggregateId,
10
- checkoutId,
11
- checkoutItemId,
12
- }),
8
+ domainEvents: [
9
+ checkoutBookingBooked({
10
+ aggregateId,
11
+ checkoutId,
12
+ checkoutItemId,
13
+ }),
14
+ ],
13
15
  };
14
16
  };
15
17
  export { bookSizeReplaceableProductVariantsForCheckoutItemHandler };
@@ -11,4 +11,5 @@ interface CheckoutBookingBookedFunction {
11
11
  (payload: CheckoutBookingBookedPayload): CheckoutBookingBooked;
12
12
  }
13
13
  declare const checkoutBookingBooked: CheckoutBookingBookedFunction;
14
- export { CHECKOUT_BOOKING_BOOKED, CheckoutBookingBooked, checkoutBookingBooked };
14
+ export type { CheckoutBookingBooked };
15
+ export { CHECKOUT_BOOKING_BOOKED, checkoutBookingBooked };
@@ -4,4 +4,4 @@ interface CheckoutBookingsGetFunction<CheckoutBookingsGetFunctionArgs extends Re
4
4
  }
5
5
  interface CheckoutBookingsSaveFunction<CheckoutBookingsSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<CheckoutBooking, CheckoutBookingsSaveFunctionArgs> {
6
6
  }
7
- export { CheckoutBookingsGetFunction, CheckoutBookingsSaveFunction };
7
+ export type { CheckoutBookingsGetFunction, CheckoutBookingsSaveFunction };
@@ -0,0 +1,13 @@
1
+ import { Command } from "@lookiero/messaging";
2
+ declare const KEEP_CHECKOUT_ITEM = "keep_checkout_item";
3
+ interface KeepCheckoutItemPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface KeepCheckoutItem extends Command<typeof KEEP_CHECKOUT_ITEM>, KeepCheckoutItemPayload {
7
+ }
8
+ interface KeepCheckoutItemFunction {
9
+ (payload: KeepCheckoutItemPayload): KeepCheckoutItem;
10
+ }
11
+ declare const keepCheckoutItem: KeepCheckoutItemFunction;
12
+ export type { KeepCheckoutItem };
13
+ export { KEEP_CHECKOUT_ITEM, keepCheckoutItem };
@@ -0,0 +1,4 @@
1
+ import { command } from "@lookiero/messaging";
2
+ const KEEP_CHECKOUT_ITEM = "keep_checkout_item";
3
+ const keepCheckoutItem = ({ aggregateId }) => command({ aggregateId, name: KEEP_CHECKOUT_ITEM });
4
+ export { KEEP_CHECKOUT_ITEM, keepCheckoutItem };
@@ -0,0 +1,15 @@
1
+ import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
+ import { KeepCheckoutItem } from "../command/keepCheckoutItem";
3
+ declare enum CheckoutItemStatus {
4
+ INITIAL = "INITIAL",
5
+ KEPT = "KEPT",
6
+ RETURNED = "RETURNED",
7
+ REPLACED = "REPLACED",
8
+ EXPIRED = "EXPIRED"
9
+ }
10
+ interface CheckoutItem extends AggregateRoot {
11
+ readonly status: CheckoutItemStatus;
12
+ }
13
+ declare const keepCheckoutItemHandler: CommandHandlerFunction<KeepCheckoutItem, CheckoutItem>;
14
+ export type { CheckoutItem };
15
+ export { CheckoutItemStatus, keepCheckoutItemHandler };
@@ -0,0 +1,20 @@
1
+ import invariant from "tiny-invariant";
2
+ import { checkoutItemKept } from "./checkoutItemKept";
3
+ var CheckoutItemStatus;
4
+ (function (CheckoutItemStatus) {
5
+ CheckoutItemStatus["INITIAL"] = "INITIAL";
6
+ CheckoutItemStatus["KEPT"] = "KEPT";
7
+ CheckoutItemStatus["RETURNED"] = "RETURNED";
8
+ CheckoutItemStatus["REPLACED"] = "REPLACED";
9
+ CheckoutItemStatus["EXPIRED"] = "EXPIRED";
10
+ })(CheckoutItemStatus || (CheckoutItemStatus = {}));
11
+ const keepCheckoutItemHandler = () => async ({ aggregateRoot, command }) => {
12
+ const { aggregateId } = command;
13
+ invariant(aggregateRoot.status !== CheckoutItemStatus.KEPT, "CheckoutItem is already kept");
14
+ return {
15
+ ...aggregateRoot,
16
+ status: CheckoutItemStatus.KEPT,
17
+ domainEvents: [checkoutItemKept({ aggregateId })],
18
+ };
19
+ };
20
+ export { CheckoutItemStatus, keepCheckoutItemHandler };
@@ -0,0 +1,13 @@
1
+ import { DomainEvent } from "@lookiero/messaging";
2
+ declare const CHECKOUT_ITEM_KEPT = "checkout_item_kept";
3
+ interface CheckoutItemKeptPayload {
4
+ readonly aggregateId: string;
5
+ }
6
+ interface CheckoutItemKept extends DomainEvent<typeof CHECKOUT_ITEM_KEPT>, CheckoutItemKeptPayload {
7
+ }
8
+ interface CheckoutItemKeptFunction {
9
+ (payload: CheckoutItemKeptPayload): CheckoutItemKept;
10
+ }
11
+ declare const checkoutItemKept: CheckoutItemKeptFunction;
12
+ export type { CheckoutItemKept };
13
+ export { CHECKOUT_ITEM_KEPT, checkoutItemKept };
@@ -0,0 +1,4 @@
1
+ import { domainEvent } from "@lookiero/messaging";
2
+ const CHECKOUT_ITEM_KEPT = "checkout_item_kept";
3
+ const checkoutItemKept = ({ aggregateId }) => domainEvent({ aggregateId, name: CHECKOUT_ITEM_KEPT });
4
+ export { CHECKOUT_ITEM_KEPT, checkoutItemKept };
@@ -0,0 +1,7 @@
1
+ import { RepositoryGetFunction, RepositoryGetFunctionArgs, RepositorySaveFunction, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutItem } from "./checkoutItem";
3
+ interface CheckoutItemsGetFunction<CheckoutItemsGetFunctionArgs extends RepositoryGetFunctionArgs> extends RepositoryGetFunction<CheckoutItem, CheckoutItemsGetFunctionArgs> {
4
+ }
5
+ interface CheckoutItemsSaveFunction<CheckoutItemsSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<CheckoutItem, CheckoutItemsSaveFunctionArgs> {
6
+ }
7
+ export type { CheckoutItemsGetFunction, CheckoutItemsSaveFunction };
@@ -0,0 +1 @@
1
+ export {};
@@ -11,4 +11,5 @@ interface UpdateUiSettingFunction {
11
11
  (payload: UpdateUiSettingPayload): UpdateUiSetting;
12
12
  }
13
13
  declare const updateUiSetting: UpdateUiSettingFunction;
14
- export { UPDATE_UI_SETTING, UpdateUiSetting, updateUiSetting };
14
+ export type { UpdateUiSetting };
15
+ export { UPDATE_UI_SETTING, updateUiSetting };
@@ -5,4 +5,5 @@ interface UiSetting extends AggregateRoot {
5
5
  readonly value: unknown;
6
6
  }
7
7
  declare const updateUiSettingHandler: CommandHandlerFunction<UpdateUiSetting, UiSetting>;
8
- export { UiSetting, updateUiSettingHandler };
8
+ export type { UiSetting };
9
+ export { updateUiSettingHandler };
@@ -5,7 +5,7 @@ const updateUiSettingHandler = () => async ({ aggregateRoot, command }) => {
5
5
  ...aggregateRoot,
6
6
  key,
7
7
  value,
8
- domainEvents: uiSettingUpdated({ aggregateId, key }),
8
+ domainEvents: [uiSettingUpdated({ aggregateId, key })],
9
9
  };
10
10
  };
11
11
  export { updateUiSettingHandler };
@@ -10,4 +10,5 @@ interface UiSettingUpdatedFunction {
10
10
  (payload: UiSettingUpdatedPayload): UiSettingUpdated;
11
11
  }
12
12
  declare const uiSettingUpdated: UiSettingUpdatedFunction;
13
- export { UI_SETTING_UPDATED, UiSettingUpdated, uiSettingUpdated };
13
+ export type { UiSettingUpdated };
14
+ export { UI_SETTING_UPDATED, uiSettingUpdated };
@@ -4,4 +4,4 @@ interface UiSettingGetFunction<UiSettingGetFunctionArgs extends RepositoryGetFun
4
4
  }
5
5
  interface UiSettingSaveFunction<UiSettingSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<UiSetting, UiSettingSaveFunctionArgs> {
6
6
  }
7
- export { UiSettingGetFunction, UiSettingSaveFunction };
7
+ export type { UiSettingGetFunction, UiSettingSaveFunction };
@@ -2,30 +2,44 @@ import { AggregateRoot, RepositoryGetFunction, RepositoryGetFunctionArgs, Reposi
2
2
  import { BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
3
3
  import { Checkout } from "../../domain/checkout/model/checkout";
4
4
  import { CheckoutsGetFunction, CheckoutsSaveFunction } from "../../domain/checkout/model/checkouts";
5
+ import { CheckoutItem } from "../../domain/checkoutItem/model/checkoutItem";
6
+ import { CheckoutItemsGetFunction, CheckoutItemsSaveFunction } from "../../domain/checkoutItem/model/checkoutItems";
5
7
  import { UiSetting } from "../../domain/uiSetting/model/uiSetting";
6
8
  import { UiSettingGetFunction, UiSettingSaveFunction } from "../../domain/uiSetting/model/uiSettings";
7
9
  import { CheckoutByIdView } from "../../projection/checkout/viewCheckoutById";
8
10
  import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
9
11
  import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
10
12
  import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
13
+ import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
11
14
  import { UiSettingByKeyView } from "../../projection/uiSetting/viewUiSettingByKey";
12
15
  declare const MESSAGING_CONTEXT_ID = "Checkout";
16
+ declare type NeverWhenEmptyRecord<K extends [Record<string, unknown>]> = K extends [Record<string, never>] ? [never?] : K;
13
17
  declare type RepositoryDependencies<A extends AggregateRoot, GetFunctionArgs extends RepositoryGetFunctionArgs, SaveFunctionArgs extends RepositorySaveFunctionArgs> = Omit<Parameters<RepositoryGetFunction<A, GetFunctionArgs>>[0] & Parameters<RepositorySaveFunction<A, SaveFunctionArgs>>[0], keyof RepositoryGetFunctionArgs>;
14
- interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryGetFunctionArgs, UiSettingSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs> {
18
+ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryGetFunctionArgs, UiSettingSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutItemGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutItemSaveFunctionArgs extends RepositorySaveFunctionArgs> {
15
19
  readonly checkoutByIdView: CheckoutByIdView;
16
20
  readonly firstAvailableCheckoutByCustomerIdView: FirstAvailableCheckoutByCustomerIdView;
17
21
  readonly isCheckoutEnabledByCustomerIdView: IsCheckoutEnabledByCustomerIdView;
18
22
  readonly fiveItemsDiscountByCustomerIdView: FiveItemsDiscountByCustomerIdView;
19
23
  readonly uiSettingByKeyView: UiSettingByKeyView;
24
+ readonly checkoutItemByIdView: CheckoutItemByIdView;
20
25
  readonly getUiSetting: UiSettingGetFunction<UiSettingGetFunctionArgs>;
21
26
  readonly saveUiSetting: UiSettingSaveFunction<UiSettingSaveFunctionArgs>;
22
- readonly uiSettingsDependencies: RepositoryDependencies<UiSetting, UiSettingGetFunctionArgs, UiSettingSaveFunctionArgs>;
27
+ readonly uiSettingsDependencies: NeverWhenEmptyRecord<[
28
+ RepositoryDependencies<UiSetting, UiSettingGetFunctionArgs, UiSettingSaveFunctionArgs>
29
+ ]>;
23
30
  readonly getCheckout: CheckoutsGetFunction<CheckoutGetFunctionArgs>;
24
31
  readonly saveCheckout: CheckoutsSaveFunction<CheckoutSaveFunctionArgs>;
25
- readonly checkoutsDependencies: RepositoryDependencies<Checkout, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs>;
32
+ readonly checkoutsDependencies: NeverWhenEmptyRecord<[
33
+ RepositoryDependencies<Checkout, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs>
34
+ ]>;
35
+ readonly getCheckoutItem: CheckoutItemsGetFunction<CheckoutItemGetFunctionArgs>;
36
+ readonly saveCheckoutItem: CheckoutItemsSaveFunction<CheckoutItemSaveFunctionArgs>;
37
+ readonly checkoutItemsDependencies: NeverWhenEmptyRecord<[
38
+ RepositoryDependencies<CheckoutItem, CheckoutItemGetFunctionArgs, CheckoutItemSaveFunctionArgs>
39
+ ]>;
26
40
  }
27
41
  interface BaseBootstrapFunction {
28
- <UiSettingGetArgs extends RepositoryGetFunctionArgs, UiSettingSaveArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs>(args: BaseBootstrapFunctionArgs<UiSettingGetArgs, UiSettingSaveArgs, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs>): BuildBootstrapFunctionReturn;
42
+ <UiSettingGetArgs extends RepositoryGetFunctionArgs, UiSettingSaveArgs extends RepositorySaveFunctionArgs, CheckoutGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutSaveFunctionArgs extends RepositorySaveFunctionArgs, CheckoutItemGetFunctionArgs extends RepositoryGetFunctionArgs, CheckoutItemSaveFunctionArgs extends RepositorySaveFunctionArgs>(args: BaseBootstrapFunctionArgs<UiSettingGetArgs, UiSettingSaveArgs, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs, CheckoutItemGetFunctionArgs, CheckoutItemSaveFunctionArgs>): BuildBootstrapFunctionReturn;
29
43
  }
30
44
  declare const baseBootstrap: BaseBootstrapFunction;
31
45
  export { baseBootstrap, MESSAGING_CONTEXT_ID };
@@ -1,6 +1,8 @@
1
1
  import { bootstrap as messagingBootstrap } from "@lookiero/messaging-react";
2
2
  import { START_CHECKOUT } from "../../domain/checkout/command/startCheckout";
3
3
  import { startCheckoutHandler } from "../../domain/checkout/model/checkout";
4
+ import { KEEP_CHECKOUT_ITEM } from "../../domain/checkoutItem/command/keepCheckoutItem";
5
+ import { keepCheckoutItemHandler } from "../../domain/checkoutItem/model/checkoutItem";
4
6
  import { UPDATE_UI_SETTING } from "../../domain/uiSetting/command/updateUiSetting";
5
7
  import { updateUiSettingHandler } from "../../domain/uiSetting/model/uiSetting";
6
8
  import { viewCheckoutByIdHandler, VIEW_CHECKOUT_BY_ID, } from "../../projection/checkout/viewCheckoutById";
@@ -8,9 +10,13 @@ import { viewFirstAvailableCheckoutByCustomerIdHandler, VIEW_FIRST_AVAILABLE_CHE
8
10
  import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
9
11
  import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
10
12
  import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
13
+ import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
11
14
  import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
12
15
  const MESSAGING_CONTEXT_ID = "Checkout";
13
- const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
16
+ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
17
+ .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
18
+ view: fiveItemsDiscountByCustomerIdView,
19
+ })
14
20
  .query(VIEW_CHECKOUT_BY_ID, viewCheckoutByIdHandler, {
15
21
  view: checkoutByIdView,
16
22
  })
@@ -20,14 +26,15 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
20
26
  .query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
21
27
  view: isCheckoutEnabledByCustomerIdView,
22
28
  })
23
- .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
24
- .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
25
- view: fiveItemsDiscountByCustomerIdView,
29
+ .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
30
+ .command(START_CHECKOUT, startCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
31
+ .query(VIEW_CHECKOUT_ITEM_BY_ID, viewCheckoutItemByIdHandler, {
32
+ view: checkoutItemByIdView,
26
33
  })
34
+ .command(KEEP_CHECKOUT_ITEM, keepCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
27
35
  .query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, {
28
36
  view: uiSettingByKeyView,
29
37
  })
30
- .command(UPDATE_UI_SETTING, updateUiSettingHandler, {})(getUiSetting, saveUiSetting, uiSettingsDependencies)
31
- .command(START_CHECKOUT, startCheckoutHandler, {})(getCheckout, saveCheckout, checkoutsDependencies)
38
+ .command(UPDATE_UI_SETTING, updateUiSettingHandler)(getUiSetting, saveUiSetting, ...uiSettingsDependencies)
32
39
  .build();
33
40
  export { baseBootstrap, MESSAGING_CONTEXT_ID };
@@ -1,10 +1,12 @@
1
1
  import { getCheckout, saveCheckout } from "../domain/checkout/model/httpCheckouts";
2
+ import { getCheckoutItem, saveCheckoutItem } from "../domain/checkoutItem/model/httpCheckoutItems";
2
3
  import { getUiSetting, saveUiSetting } from "../domain/uiSetting/model/storageUiSettings";
3
4
  import { read, write } from "../persistence/asyncStorageStorage";
4
5
  import { httpCheckoutByIdView } from "../projection/checkout/httpCheckoutByIdView";
5
6
  import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checkout/httpFirstAvailableCheckoutByCustomerIdView";
6
7
  import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
7
8
  import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
9
+ import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
8
10
  import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
9
11
  import { baseBootstrap } from "./baseBootstrap";
10
12
  import { fetchHttpGet, fetchHttpPost } from "./http/fetchHttpClient";
@@ -17,12 +19,16 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
17
19
  isCheckoutEnabledByCustomerIdView: httpIsCheckoutEnabledByCustomerIdView({ httpGet }),
18
20
  fiveItemsDiscountByCustomerIdView: httpFiveItemsDiscountByCustomerIdView({ httpGet }),
19
21
  uiSettingByKeyView: storageUiSettingByKeyView({ read }),
22
+ checkoutItemByIdView: httpCheckoutItemByIdView({ httpPost }),
20
23
  getUiSetting,
21
24
  saveUiSetting,
22
- uiSettingsDependencies: { read, write },
25
+ uiSettingsDependencies: [{ read, write }],
23
26
  getCheckout,
24
27
  saveCheckout,
25
- checkoutsDependencies: { httpPost },
28
+ checkoutsDependencies: [{ httpPost }],
29
+ getCheckoutItem,
30
+ saveCheckoutItem,
31
+ checkoutItemsDependencies: [{ httpPost }],
26
32
  });
27
33
  };
28
34
  export { bootstrap };
@@ -1,13 +1,16 @@
1
- import invariant from "tiny-invariant";
2
- import { CheckoutItemStatus } from "../../projection/checkout/checkout";
3
- import { viewCheckoutById, } from "../../projection/checkout/viewCheckoutById";
1
+ import { CheckoutItemStatus } from "../../domain/checkoutItem/model/checkoutItem";
4
2
  import { getUiSetting, saveUiSetting } from "../domain/uiSetting/model/storageUiSettings";
5
3
  import { read, write } from "../persistence/asyncStorageStorage";
6
4
  import { startedCheckoutWithStatusProjection } from "../projection/checkout/checkout.mock";
7
5
  import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
8
6
  import { baseBootstrap } from "./baseBootstrap";
9
- const checkoutDataSource = () => {
10
- let data = startedCheckoutWithStatusProjection({
7
+ import { checkoutDataSource } from "./mock/checkoutDataSource";
8
+ import { getCheckoutItem, saveCheckoutItem } from "./mock/dataSourceCheckoutItems";
9
+ import { getCheckout, saveCheckout } from "./mock/dataSourceCheckouts";
10
+ const IS_CHECKOUT_ENABLED = true;
11
+ const FIVE_ITEMS_DISCOUNT = 25;
12
+ const dataSource = checkoutDataSource({
13
+ data: startedCheckoutWithStatusProjection({
11
14
  status: [
12
15
  CheckoutItemStatus.INITIAL,
13
16
  CheckoutItemStatus.INITIAL,
@@ -15,49 +18,28 @@ const checkoutDataSource = () => {
15
18
  CheckoutItemStatus.INITIAL,
16
19
  CheckoutItemStatus.INITIAL,
17
20
  ],
18
- });
19
- const get = () => data;
20
- const save = (checkout) => {
21
- data = { ...data, ...checkout };
22
- };
23
- return {
24
- get,
25
- save,
26
- };
27
- };
28
- const isCheckoutEnabled = true;
29
- const checkoutByIdView = async () => checkoutDataSource().get();
30
- const firstAvailableCheckoutByCustomerIdView = async () => checkoutDataSource().get();
31
- const isCheckoutEnabledByCustomerIdView = async () => isCheckoutEnabled;
32
- const fiveItemsDiscountByCustomerIdView = async () => 25;
33
- const toCheckoutDomain = (checkout) => {
34
- invariant(checkout, "No checkout found!");
35
- return {
36
- id: checkout.id,
37
- status: checkout.status,
38
- customerId: checkout.customerId,
39
- boxId: checkout.boxId,
40
- bookingId: checkout.bookingId,
41
- expiresOn: checkout.expiresOn,
42
- aggregateId: checkout.id,
43
- domainEvents: [],
44
- };
45
- };
46
- const getCheckout = ({ queryBus }) => async (aggregateId) => toCheckoutDomain(await queryBus(viewCheckoutById({ checkoutId: aggregateId })));
47
- const saveCheckout = () => async (aggregateRoot) => {
48
- checkoutDataSource().save(aggregateRoot);
49
- };
21
+ }),
22
+ });
23
+ const checkoutByIdView = async () => dataSource.getCheckout();
24
+ const firstAvailableCheckoutByCustomerIdView = async () => dataSource.getCheckout();
25
+ const isCheckoutEnabledByCustomerIdView = async () => IS_CHECKOUT_ENABLED;
26
+ const fiveItemsDiscountByCustomerIdView = async () => FIVE_ITEMS_DISCOUNT;
27
+ const checkoutItemByIdView = async ({ checkoutItemId }) => dataSource.getCheckoutItem(checkoutItemId);
50
28
  const bootstrap = () => baseBootstrap({
51
29
  checkoutByIdView,
52
30
  firstAvailableCheckoutByCustomerIdView,
53
31
  isCheckoutEnabledByCustomerIdView,
54
32
  fiveItemsDiscountByCustomerIdView,
55
33
  uiSettingByKeyView: storageUiSettingByKeyView({ read }),
34
+ checkoutItemByIdView,
56
35
  getUiSetting,
57
36
  saveUiSetting,
58
- uiSettingsDependencies: { read, write },
37
+ uiSettingsDependencies: [{ read, write }],
59
38
  getCheckout,
60
39
  saveCheckout,
61
- checkoutsDependencies: {},
40
+ checkoutsDependencies: [{ dataSource }],
41
+ getCheckoutItem,
42
+ saveCheckoutItem,
43
+ checkoutItemsDependencies: [{ dataSource }],
62
44
  });
63
45
  export { bootstrap };
@@ -1,17 +1,19 @@
1
- const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body }) => fetch(`${apiUrl}${endpoint}`, {
1
+ const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal }) => fetch(`${apiUrl}${endpoint}`, {
2
2
  method: "POST",
3
3
  headers: {
4
4
  ["Content-Type"]: "application/json",
5
5
  authorization: `Bearer ${await getAuthToken()}`,
6
6
  },
7
7
  body: JSON.stringify(body),
8
+ signal,
8
9
  });
9
- const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint }) => fetch(`${apiUrl}${endpoint}`, {
10
+ const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal }) => fetch(`${apiUrl}${endpoint}`, {
10
11
  method: "GET",
11
12
  credentials: "include",
12
13
  headers: {
13
14
  authorization: `Bearer ${await getAuthToken()}`,
14
15
  },
15
16
  referrer: "",
17
+ signal,
16
18
  });
17
19
  export { fetchHttpGet, fetchHttpPost };
@@ -1,5 +1,6 @@
1
1
  interface HttpGetFunctionArgs {
2
2
  readonly endpoint: string;
3
+ readonly signal?: AbortSignal;
3
4
  }
4
5
  interface HttpGetFunction {
5
6
  (args: HttpGetFunctionArgs): Promise<Response>;
@@ -7,6 +8,7 @@ interface HttpGetFunction {
7
8
  interface HttpPostFunctionArgs {
8
9
  readonly endpoint: string;
9
10
  readonly body: Record<string, unknown>;
11
+ readonly signal?: AbortSignal;
10
12
  }
11
13
  interface HttpPostFunction {
12
14
  (args: HttpPostFunctionArgs): Promise<Response>;
@@ -0,0 +1,17 @@
1
+ import { CheckoutProjection } from "../../../projection/checkout/checkout";
2
+ import { CheckoutItemProjection } from "../../../projection/checkoutItem/checkoutItem";
3
+ interface CheckoutDataSourceFunctionArgs {
4
+ readonly data: CheckoutProjection;
5
+ }
6
+ interface CheckoutDataSource {
7
+ readonly getCheckout: () => CheckoutProjection;
8
+ readonly saveCheckout: (checkout: CheckoutProjection) => void;
9
+ readonly getCheckoutItem: (id: string) => CheckoutItemProjection | undefined;
10
+ readonly saveCheckoutItem: (checkoutItem: CheckoutItemProjection) => void;
11
+ }
12
+ interface CheckoutDataSourceFunction {
13
+ (args: CheckoutDataSourceFunctionArgs): CheckoutDataSource;
14
+ }
15
+ declare const checkoutDataSource: CheckoutDataSourceFunction;
16
+ export type { CheckoutDataSource };
17
+ export { checkoutDataSource };
@@ -0,0 +1,18 @@
1
+ const checkoutDataSource = ({ data: initialData }) => {
2
+ let data = initialData;
3
+ const getCheckout = () => data;
4
+ const saveCheckout = (checkout) => {
5
+ data = checkout;
6
+ };
7
+ const getCheckoutItem = (id) => data.items.find((item) => item.id === id);
8
+ const saveCheckoutItem = (checkoutItem) => {
9
+ data = { ...data, items: data.items.map((item) => (item.id === checkoutItem.id ? checkoutItem : item)) };
10
+ };
11
+ return {
12
+ getCheckout,
13
+ saveCheckout,
14
+ getCheckoutItem,
15
+ saveCheckoutItem,
16
+ };
17
+ };
18
+ export { checkoutDataSource };
@@ -0,0 +1,14 @@
1
+ import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutItem } from "../../../domain/checkoutItem/model/checkoutItem";
3
+ import { CheckoutItemsGetFunction, CheckoutItemsSaveFunction } from "../../../domain/checkoutItem/model/checkoutItems";
4
+ import { CheckoutItemProjection } from "../../../projection/checkoutItem/checkoutItem";
5
+ import { CheckoutDataSource } from "./checkoutDataSource";
6
+ declare const toCheckoutItemProjection: (checkoutItem: CheckoutItem) => CheckoutItemProjection;
7
+ declare const getCheckoutItem: CheckoutItemsGetFunction<RepositoryGetFunctionArgs>;
8
+ interface DataSourceCheckoutItemsSaveFunctionArgs extends RepositorySaveFunctionArgs {
9
+ readonly dataSource: CheckoutDataSource;
10
+ }
11
+ interface DataSourceCheckoutItemsSaveFunction extends CheckoutItemsSaveFunction<DataSourceCheckoutItemsSaveFunctionArgs> {
12
+ }
13
+ declare const saveCheckoutItem: DataSourceCheckoutItemsSaveFunction;
14
+ export { getCheckoutItem, saveCheckoutItem, toCheckoutItemProjection };
@@ -0,0 +1,21 @@
1
+ import invariant from "tiny-invariant";
2
+ import { viewCheckoutItemById, } from "../../../projection/checkoutItem/viewCheckoutItemById";
3
+ const toCheckoutItemProjection = (checkoutItem) => ({
4
+ id: checkoutItem.aggregateId,
5
+ status: checkoutItem.status,
6
+ productVariant: {},
7
+ });
8
+ const toCheckoutItemDomain = (checkoutItem) => {
9
+ invariant(checkoutItem, "No checkoutItem found!");
10
+ return {
11
+ id: checkoutItem.id,
12
+ status: checkoutItem.status,
13
+ aggregateId: checkoutItem.id,
14
+ domainEvents: [],
15
+ };
16
+ };
17
+ const getCheckoutItem = ({ queryBus }) => async (aggregateId) => toCheckoutItemDomain(await queryBus(viewCheckoutItemById({ checkoutItemId: aggregateId })));
18
+ const saveCheckoutItem = ({ dataSource }) => async (aggregateRoot) => {
19
+ dataSource.saveCheckoutItem(toCheckoutItemProjection(aggregateRoot));
20
+ };
21
+ export { getCheckoutItem, saveCheckoutItem, toCheckoutItemProjection };
@@ -0,0 +1,11 @@
1
+ import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
2
+ import { CheckoutsGetFunction, CheckoutsSaveFunction } from "../../../domain/checkout/model/checkouts";
3
+ import { CheckoutDataSource } from "./checkoutDataSource";
4
+ declare const getCheckout: CheckoutsGetFunction<RepositoryGetFunctionArgs>;
5
+ interface DataSourceCheckoutsSaveFunctionArgs extends RepositorySaveFunctionArgs {
6
+ readonly dataSource: CheckoutDataSource;
7
+ }
8
+ interface DataSourceCheckoutsSaveFunction extends CheckoutsSaveFunction<DataSourceCheckoutsSaveFunctionArgs> {
9
+ }
10
+ declare const saveCheckout: DataSourceCheckoutsSaveFunction;
11
+ export { getCheckout, saveCheckout };
@@ -0,0 +1,27 @@
1
+ import invariant from "tiny-invariant";
2
+ import { viewCheckoutById, } from "../../../projection/checkout/viewCheckoutById";
3
+ const toCheckoutDomain = (checkout) => {
4
+ invariant(checkout, "No checkout found!");
5
+ return {
6
+ id: checkout.id,
7
+ status: checkout.status,
8
+ customerId: checkout.customerId,
9
+ boxId: checkout.boxId,
10
+ bookingId: checkout.bookingId,
11
+ expiresOn: checkout.expiresOn,
12
+ aggregateId: checkout.id,
13
+ domainEvents: [],
14
+ };
15
+ };
16
+ const toCheckoutProjection = (checkout) => ({
17
+ id: checkout.aggregateId,
18
+ status: checkout.status,
19
+ customerId: checkout.customerId,
20
+ boxId: checkout.boxId,
21
+ bookingId: checkout.bookingId,
22
+ expiresOn: checkout.expiresOn,
23
+ items: [],
24
+ });
25
+ const getCheckout = ({ queryBus }) => async (aggregateId) => toCheckoutDomain(await queryBus(viewCheckoutById({ checkoutId: aggregateId })));
26
+ const saveCheckout = ({ dataSource }) => async (aggregateRoot) => dataSource.saveCheckout(toCheckoutProjection(aggregateRoot));
27
+ export { getCheckout, saveCheckout };
@@ -1,8 +1,7 @@
1
1
  import { CHECKOUT_STARTED } from "../../../../domain/checkout/model/checkoutStarted";
2
2
  const isCheckoutStarted = (event) => event.name === CHECKOUT_STARTED;
3
3
  const httpCheckoutsStart = ({ httpPost }) => async ({ aggregateId, domainEvents }) => {
4
- const checkoutEvents = Array.isArray(domainEvents) ? domainEvents : [domainEvents];
5
- const checkoutStarted = checkoutEvents.find(isCheckoutStarted);
4
+ const checkoutStarted = domainEvents.find(isCheckoutStarted);
6
5
  if (!checkoutStarted) {
7
6
  return;
8
7
  }