@lookiero/checkout 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain/checkout/command/startCheckout.d.ts +2 -1
- package/dist/domain/checkout/model/checkout.d.ts +2 -1
- package/dist/domain/checkout/model/checkouts.d.ts +1 -1
- package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -1
- package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +1 -1
- package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +2 -1
- package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +2 -1
- package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +1 -1
- package/dist/domain/checkoutItem/command/keepCheckoutItem.d.ts +13 -0
- package/dist/domain/checkoutItem/command/keepCheckoutItem.js +4 -0
- package/dist/domain/checkoutItem/model/checkoutItem.d.ts +15 -0
- package/dist/domain/checkoutItem/model/checkoutItem.js +20 -0
- package/dist/domain/checkoutItem/model/checkoutItemKept.d.ts +13 -0
- package/dist/domain/checkoutItem/model/checkoutItemKept.js +4 -0
- package/dist/domain/checkoutItem/model/checkoutItems.d.ts +7 -0
- package/dist/domain/checkoutItem/model/checkoutItems.js +1 -0
- package/dist/domain/uiSetting/command/updateUiSetting.d.ts +2 -1
- package/dist/domain/uiSetting/model/uiSetting.d.ts +2 -1
- package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +2 -1
- package/dist/domain/uiSetting/model/uiSettings.d.ts +1 -1
- package/dist/infrastructure/delivery/baseBootstrap.d.ts +11 -2
- package/dist/infrastructure/delivery/baseBootstrap.js +11 -4
- package/dist/infrastructure/delivery/bootstrap.js +6 -0
- package/dist/infrastructure/delivery/bootstrap.mock.js +20 -38
- package/dist/infrastructure/delivery/http/httpClient.d.ts +1 -1
- package/dist/infrastructure/delivery/mock/checkoutDataSource.d.ts +17 -0
- package/dist/infrastructure/delivery/mock/checkoutDataSource.js +18 -0
- package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.d.ts +14 -0
- package/dist/infrastructure/delivery/mock/dataSourceCheckoutItems.js +21 -0
- package/dist/infrastructure/delivery/mock/dataSourceCheckouts.d.ts +11 -0
- package/dist/infrastructure/delivery/mock/dataSourceCheckouts.js +27 -0
- package/dist/infrastructure/domain/checkout/model/httpCheckoutsStart.js +1 -2
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.d.ts +16 -0
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItems.js +17 -0
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsKeep.d.ts +5 -0
- package/dist/infrastructure/domain/checkoutItem/model/httpCheckoutItemsKeep.js +13 -0
- package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.d.ts +13 -0
- package/dist/infrastructure/domain/checkoutItem/react/useKeepCheckoutItem.js +12 -0
- package/dist/infrastructure/persistence/storage.d.ts +1 -1
- package/dist/infrastructure/persistence/uiSettingData.d.ts +1 -1
- package/dist/infrastructure/projection/bookedSizeReplaceableProductVariants/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +2 -1
- package/dist/infrastructure/projection/bookedSizeReplaceableProductVariants/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +1 -1
- package/dist/infrastructure/projection/checkout/checkout.d.ts +3 -38
- package/dist/infrastructure/projection/checkout/checkout.mock.d.ts +2 -1
- package/dist/infrastructure/projection/checkout/checkout.mock.js +1 -33
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.d.ts +44 -0
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.js +39 -0
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.mock.d.ts +18 -0
- package/dist/infrastructure/projection/checkoutItem/checkoutItem.mock.js +37 -0
- package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.d.ts +12 -0
- package/dist/infrastructure/projection/checkoutItem/httpCheckoutItemByIdView.js +12 -0
- package/dist/infrastructure/ui/Root.d.ts +2 -1
- package/dist/infrastructure/ui/components/atoms/price/Price.d.ts +1 -1
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +1 -1
- package/dist/infrastructure/ui/views/item/Item.js +1 -3
- package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.d.ts +1 -1
- package/dist/infrastructure/ui/views/item/components/banner/CustomerDecissionBanner.js +1 -1
- package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.d.ts +1 -1
- package/dist/infrastructure/ui/views/item/components/productVariantDescription/ProductVariantDescription.d.ts +1 -1
- package/dist/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.d.ts +1 -1
- package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -1
- package/dist/projection/checkout/checkout.d.ts +2 -68
- package/dist/projection/checkout/checkout.js +1 -29
- package/dist/projection/checkout/viewFiveItemsDiscountByCustomerId.d.ts +2 -1
- package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +2 -1
- package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.d.ts +2 -1
- package/dist/projection/checkoutItem/checkoutItem.d.ts +62 -0
- package/dist/projection/checkoutItem/checkoutItem.js +21 -0
- package/dist/projection/checkoutItem/viewCheckoutItemById.d.ts +25 -0
- package/dist/projection/checkoutItem/viewCheckoutItemById.js +8 -0
- package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +2 -1
- package/dist/projection/uiSetting/viewUiSettingByKey.js +1 -1
- package/package.json +9 -10
|
@@ -9,4 +9,5 @@ interface StartCheckoutFunction {
|
|
|
9
9
|
(payload: StartCheckoutPayload): StartCheckout;
|
|
10
10
|
}
|
|
11
11
|
declare const startCheckout: StartCheckoutFunction;
|
|
12
|
-
export {
|
|
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
|
|
17
|
+
export type { Checkout };
|
|
18
|
+
export { CheckoutStatus, startCheckoutHandler };
|
|
@@ -4,4 +4,4 @@ interface CheckoutsGetFunction<CheckoutsGetFunctionArgs extends RepositoryGetFun
|
|
|
4
4
|
}
|
|
5
5
|
interface CheckoutsSaveFunction<CheckoutsSaveFunctionArgs extends RepositorySaveFunctionArgs> extends RepositorySaveFunction<Checkout, CheckoutsSaveFunctionArgs> {
|
|
6
6
|
}
|
|
7
|
-
export { CheckoutsGetFunction, CheckoutsSaveFunction };
|
|
7
|
+
export type { CheckoutsGetFunction, CheckoutsSaveFunction };
|
package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ interface BookSizeReplaceableProductVariantsForCheckoutItemFunction {
|
|
|
11
11
|
(payload: BookSizeReplaceableProductVariantsForCheckoutItemPayload): BookSizeReplaceableProductVariantsForCheckoutItem;
|
|
12
12
|
}
|
|
13
13
|
declare const bookSizeReplaceableProductVariantsForCheckoutItem: BookSizeReplaceableProductVariantsForCheckoutItemFunction;
|
|
14
|
-
export {
|
|
14
|
+
export type { BookSizeReplaceableProductVariantsForCheckoutItem };
|
|
15
|
+
export { BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, bookSizeReplaceableProductVariantsForCheckoutItem };
|
package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js
CHANGED
|
@@ -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
|
|
8
|
+
export type { CheckoutBooking };
|
|
9
|
+
export { bookSizeReplaceableProductVariantsForCheckoutItemHandler };
|
|
@@ -11,4 +11,5 @@ interface CheckoutBookingBookedFunction {
|
|
|
11
11
|
(payload: CheckoutBookingBookedPayload): CheckoutBookingBooked;
|
|
12
12
|
}
|
|
13
13
|
declare const checkoutBookingBooked: CheckoutBookingBookedFunction;
|
|
14
|
-
export {
|
|
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,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,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 {
|
|
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
|
|
8
|
+
export type { UiSetting };
|
|
9
|
+
export { updateUiSettingHandler };
|
|
@@ -10,4 +10,5 @@ interface UiSettingUpdatedFunction {
|
|
|
10
10
|
(payload: UiSettingUpdatedPayload): UiSettingUpdated;
|
|
11
11
|
}
|
|
12
12
|
declare const uiSettingUpdated: UiSettingUpdatedFunction;
|
|
13
|
-
export {
|
|
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,22 +2,26 @@ 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";
|
|
13
16
|
declare type NeverWhenEmptyRecord<K extends [Record<string, unknown>]> = K extends [Record<string, never>] ? [never?] : K;
|
|
14
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>;
|
|
15
|
-
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> {
|
|
16
19
|
readonly checkoutByIdView: CheckoutByIdView;
|
|
17
20
|
readonly firstAvailableCheckoutByCustomerIdView: FirstAvailableCheckoutByCustomerIdView;
|
|
18
21
|
readonly isCheckoutEnabledByCustomerIdView: IsCheckoutEnabledByCustomerIdView;
|
|
19
22
|
readonly fiveItemsDiscountByCustomerIdView: FiveItemsDiscountByCustomerIdView;
|
|
20
23
|
readonly uiSettingByKeyView: UiSettingByKeyView;
|
|
24
|
+
readonly checkoutItemByIdView: CheckoutItemByIdView;
|
|
21
25
|
readonly getUiSetting: UiSettingGetFunction<UiSettingGetFunctionArgs>;
|
|
22
26
|
readonly saveUiSetting: UiSettingSaveFunction<UiSettingSaveFunctionArgs>;
|
|
23
27
|
readonly uiSettingsDependencies: NeverWhenEmptyRecord<[
|
|
@@ -28,9 +32,14 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
|
|
|
28
32
|
readonly checkoutsDependencies: NeverWhenEmptyRecord<[
|
|
29
33
|
RepositoryDependencies<Checkout, CheckoutGetFunctionArgs, CheckoutSaveFunctionArgs>
|
|
30
34
|
]>;
|
|
35
|
+
readonly getCheckoutItem: CheckoutItemsGetFunction<CheckoutItemGetFunctionArgs>;
|
|
36
|
+
readonly saveCheckoutItem: CheckoutItemsSaveFunction<CheckoutItemSaveFunctionArgs>;
|
|
37
|
+
readonly checkoutItemsDependencies: NeverWhenEmptyRecord<[
|
|
38
|
+
RepositoryDependencies<CheckoutItem, CheckoutItemGetFunctionArgs, CheckoutItemSaveFunctionArgs>
|
|
39
|
+
]>;
|
|
31
40
|
}
|
|
32
41
|
interface BaseBootstrapFunction {
|
|
33
|
-
<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;
|
|
34
43
|
}
|
|
35
44
|
declare const baseBootstrap: BaseBootstrapFunction;
|
|
36
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
|
})
|
|
@@ -21,13 +27,14 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
|
|
|
21
27
|
view: isCheckoutEnabledByCustomerIdView,
|
|
22
28
|
})
|
|
23
29
|
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler)
|
|
24
|
-
.
|
|
25
|
-
|
|
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
38
|
.command(UPDATE_UI_SETTING, updateUiSettingHandler)(getUiSetting, saveUiSetting, ...uiSettingsDependencies)
|
|
31
|
-
.command(START_CHECKOUT, startCheckoutHandler)(getCheckout, saveCheckout, ...checkoutsDependencies)
|
|
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
25
|
uiSettingsDependencies: [{ read, write }],
|
|
23
26
|
getCheckout,
|
|
24
27
|
saveCheckout,
|
|
25
28
|
checkoutsDependencies: [{ httpPost }],
|
|
29
|
+
getCheckoutItem,
|
|
30
|
+
saveCheckoutItem,
|
|
31
|
+
checkoutItemsDependencies: [{ httpPost }],
|
|
26
32
|
});
|
|
27
33
|
};
|
|
28
34
|
export { bootstrap };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
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 };
|
|
@@ -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
|
|
5
|
-
const checkoutStarted = checkoutEvents.find(isCheckoutStarted);
|
|
4
|
+
const checkoutStarted = domainEvents.find(isCheckoutStarted);
|
|
6
5
|
if (!checkoutStarted) {
|
|
7
6
|
return;
|
|
8
7
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RepositoryGetFunctionArgs, RepositorySaveFunctionArgs } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutItemsGetFunction, CheckoutItemsSaveFunction } from "../../../../domain/checkoutItem/model/checkoutItems";
|
|
3
|
+
import { HttpPostFunction } from "../../../delivery/http/httpClient";
|
|
4
|
+
interface HttpCheckoutItemsGetFunctionArgs extends RepositoryGetFunctionArgs {
|
|
5
|
+
}
|
|
6
|
+
interface HttpCheckoutItemsGetFunction extends CheckoutItemsGetFunction<HttpCheckoutItemsGetFunctionArgs> {
|
|
7
|
+
}
|
|
8
|
+
declare const getCheckoutItem: HttpCheckoutItemsGetFunction;
|
|
9
|
+
interface HttpCheckoutItemsSaveFunctionArgs extends RepositorySaveFunctionArgs {
|
|
10
|
+
readonly httpPost: HttpPostFunction;
|
|
11
|
+
}
|
|
12
|
+
interface HttpCheckoutItemsSaveFunction extends CheckoutItemsSaveFunction<HttpCheckoutItemsSaveFunctionArgs> {
|
|
13
|
+
}
|
|
14
|
+
declare const saveCheckoutItem: HttpCheckoutItemsSaveFunction;
|
|
15
|
+
export type { HttpCheckoutItemsSaveFunction };
|
|
16
|
+
export { getCheckoutItem, saveCheckoutItem };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import invariant from "tiny-invariant";
|
|
2
|
+
import { viewCheckoutItemById, } from "../../../../projection/checkoutItem/viewCheckoutItemById";
|
|
3
|
+
import { httpCheckoutItemsKeep } from "./httpCheckoutItemsKeep";
|
|
4
|
+
const toDomain = (checkoutItem) => {
|
|
5
|
+
invariant(checkoutItem, "No checkoutItem found!");
|
|
6
|
+
return {
|
|
7
|
+
id: checkoutItem.id,
|
|
8
|
+
status: checkoutItem.status,
|
|
9
|
+
aggregateId: checkoutItem.id,
|
|
10
|
+
domainEvents: [],
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const getCheckoutItem = ({ queryBus }) => async (aggregateId) => toDomain(await queryBus(viewCheckoutItemById({ checkoutItemId: aggregateId })));
|
|
14
|
+
const saveCheckoutItem = ({ httpPost }) => async (aggregateRoot) => {
|
|
15
|
+
await httpCheckoutItemsKeep({ httpPost })(aggregateRoot);
|
|
16
|
+
};
|
|
17
|
+
export { getCheckoutItem, saveCheckoutItem };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CHECKOUT_ITEM_KEPT } from "../../../../domain/checkoutItem/model/checkoutItemKept";
|
|
2
|
+
const isCheckoutItemKept = (event) => event.name === CHECKOUT_ITEM_KEPT;
|
|
3
|
+
const httpCheckoutItemsKeep = ({ httpPost }) => async ({ aggregateId, domainEvents }) => {
|
|
4
|
+
const checkoutItemKept = domainEvents.find(isCheckoutItemKept);
|
|
5
|
+
if (!checkoutItemKept) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
httpPost({
|
|
9
|
+
endpoint: "/keep-checkout-item",
|
|
10
|
+
body: { checkout_item_id: aggregateId },
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { httpCheckoutItemsKeep };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
interface KeepCheckoutItemFunction {
|
|
3
|
+
(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
interface UseKeepCheckoutItemFunctionArgs {
|
|
6
|
+
readonly checkoutItemId: string;
|
|
7
|
+
}
|
|
8
|
+
declare type UseKeepCheckoutItemResult = [keep: KeepCheckoutItemFunction, status: CommandStatus];
|
|
9
|
+
interface UseKeepCheckoutItemFunction {
|
|
10
|
+
(args: UseKeepCheckoutItemFunctionArgs): UseKeepCheckoutItemResult;
|
|
11
|
+
}
|
|
12
|
+
declare const useKeepCheckoutItem: UseKeepCheckoutItemFunction;
|
|
13
|
+
export { useKeepCheckoutItem };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCommand } from "@lookiero/messaging-react";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { keepCheckoutItem } from "../../../../domain/checkoutItem/command/keepCheckoutItem";
|
|
4
|
+
import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
|
|
5
|
+
const useKeepCheckoutItem = ({ checkoutItemId }) => {
|
|
6
|
+
const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
|
|
7
|
+
const keep = useCallback(async () => await commandBus(keepCheckoutItem({
|
|
8
|
+
aggregateId: checkoutItemId,
|
|
9
|
+
})), [checkoutItemId, commandBus]);
|
|
10
|
+
return [keep, status];
|
|
11
|
+
};
|
|
12
|
+
export { useKeepCheckoutItem };
|