@lookiero/checkout 0.2.50 → 0.2.52

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 (23) hide show
  1. package/dist/domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem.d.ts +0 -1
  2. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +0 -1
  3. package/dist/infrastructure/delivery/baseBootstrap.d.ts +2 -0
  4. package/dist/infrastructure/delivery/baseBootstrap.js +5 -1
  5. package/dist/infrastructure/delivery/bootstrap.js +4 -0
  6. package/dist/infrastructure/delivery/mock/dataSourceCheckoutBookings.js +0 -1
  7. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +0 -1
  8. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookingsBook.js +2 -3
  9. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.d.ts +0 -1
  10. package/dist/infrastructure/domain/checkoutBooking/react/useBookCheckouBookingForCheckoutItem.js +2 -3
  11. package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.d.ts +12 -0
  12. package/dist/infrastructure/projection/pricing/httpPricingByCheckoutIdView.js +9 -0
  13. package/dist/infrastructure/projection/pricing/pricing.mock.d.ts +3 -0
  14. package/dist/{projection → infrastructure/projection}/pricing/pricing.mock.js +1 -1
  15. package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.d.ts +10 -0
  16. package/dist/infrastructure/projection/pricing/react/useViewPricingByCheckoutId.js +9 -0
  17. package/dist/infrastructure/ui/views/item/Item.js +0 -1
  18. package/dist/infrastructure/ui/views/summary/Summary.js +1 -1
  19. package/dist/projection/checkoutBooking/checkoutBooking.d.ts +0 -1
  20. package/dist/projection/pricing/viewPricingByCheckoutId.d.ts +25 -0
  21. package/dist/projection/pricing/viewPricingByCheckoutId.js +8 -0
  22. package/package.json +1 -1
  23. package/dist/projection/pricing/pricing.mock.d.ts +0 -3
@@ -2,7 +2,6 @@ import { Command } from "@lookiero/messaging";
2
2
  declare const BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM = "book_checkout_booking_for_checkout_item";
3
3
  interface BookCheckoutBookingForCheckoutItemPayload {
4
4
  readonly aggregateId: string;
5
- readonly checkoutId: string;
6
5
  readonly checkoutItemId: string;
7
6
  }
8
7
  interface BookCheckoutBookingForCheckoutItem extends Command<typeof BOOK_CHECKOUT_BOOKING_FOR_CHECKOUT_ITEM>, BookCheckoutBookingForCheckoutItemPayload {
@@ -1,7 +1,6 @@
1
1
  import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
2
  import { BookCheckoutBookingForCheckoutItem } from "../command/bookCheckoutBookingForCheckoutItem";
3
3
  interface CheckoutBooking extends AggregateRoot {
4
- readonly checkoutId: string;
5
4
  readonly checkoutItemIds: string[];
6
5
  }
7
6
  declare const bookCheckoutBookingForCheckoutItemHandler: CommandHandlerFunction<BookCheckoutBookingForCheckoutItem, CheckoutBooking>;
@@ -14,6 +14,7 @@ import { FirstAvailableCheckoutByCustomerIdView } from "../../projection/checkou
14
14
  import { FiveItemsDiscountByCustomerIdView } from "../../projection/checkout/viewFiveItemsDiscountByCustomerId";
15
15
  import { IsCheckoutEnabledByCustomerIdView } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
16
16
  import { CheckoutItemByIdView } from "../../projection/checkoutItem/viewCheckoutItemById";
17
+ import { PricingByCheckoutIdView } from "../../projection/pricing/viewPricingByCheckoutId";
17
18
  import { ReturnQuestionsByCheckoutItemIdView } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
18
19
  import { UiSettingByKeyView } from "../../projection/uiSetting/viewUiSettingByKey";
19
20
  declare const MESSAGING_CONTEXT_ID = "Checkout";
@@ -28,6 +29,7 @@ interface BaseBootstrapFunctionArgs<UiSettingGetFunctionArgs extends RepositoryG
28
29
  readonly checkoutItemByIdView: CheckoutItemByIdView;
29
30
  readonly returnQuestionsByCheckoutItemIdView: ReturnQuestionsByCheckoutItemIdView;
30
31
  readonly bookedSizeChangeProductsVariantsForCheckoutItemView: BookedSizeChangeProductsVariantsForCheckoutItemView;
32
+ readonly pricingByCheckoutIdView: PricingByCheckoutIdView;
31
33
  readonly getUiSetting: UiSettingGetFunction<UiSettingGetFunctionArgs>;
32
34
  readonly saveUiSetting: UiSettingSaveFunction<UiSettingSaveFunctionArgs>;
33
35
  readonly uiSettingsDependencies: NeverWhenEmptyRecord<[
@@ -16,10 +16,11 @@ import { viewFiveItemsDiscountByCustomerIdHandler, VIEW_FIVE_ITEMS_DISCOUNT_BY_C
16
16
  import { viewIsCheckoutAccessibleByCustomerIdHandler, VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
17
17
  import { viewIsCheckoutEnabledByCustomerIdHandler, VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
18
18
  import { viewCheckoutItemByIdHandler, VIEW_CHECKOUT_ITEM_BY_ID, } from "../../projection/checkoutItem/viewCheckoutItemById";
19
+ import { viewPricingByCheckoutIdHandler, VIEW_PRICING_BY_CHECKOUT_ID, } from "../../projection/pricing/viewPricingByCheckoutId";
19
20
  import { listReturnQuestionsByCheckoutItemIdHandler, LIST_RETURN_QUESTIONS_BY_CHECKOUT_ITEM_ID, } from "../../projection/returnQuestion/listReturnQuestionsByCheckoutItemId";
20
21
  import { viewUiSettingByKeyHandler, VIEW_UI_SETTING_BY_KEY, } from "../../projection/uiSetting/viewUiSettingByKey";
21
22
  const MESSAGING_CONTEXT_ID = "Checkout";
22
- const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
23
+ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdView, isCheckoutEnabledByCustomerIdView, fiveItemsDiscountByCustomerIdView, uiSettingByKeyView, checkoutItemByIdView, returnQuestionsByCheckoutItemIdView, bookedSizeChangeProductsVariantsForCheckoutItemView, pricingByCheckoutIdView, getUiSetting, saveUiSetting, uiSettingsDependencies, getCheckout, saveCheckout, checkoutsDependencies, getCheckoutItem, saveCheckoutItem, checkoutItemsDependencies, getCheckoutBooking, saveCheckoutBooking, checkoutBookingsDependencies, }) => messagingBootstrap({ id: MESSAGING_CONTEXT_ID })
23
24
  .query(VIEW_FIVE_ITEMS_DISCOUNT_BY_CUSTOMER_ID, viewFiveItemsDiscountByCustomerIdHandler, {
24
25
  view: fiveItemsDiscountByCustomerIdView,
25
26
  })
@@ -43,6 +44,9 @@ const baseBootstrap = ({ checkoutByIdView, firstAvailableCheckoutByCustomerIdVie
43
44
  .command(KEEP_CHECKOUT_ITEM, keepCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
44
45
  .command(RETURN_CHECKOUT_ITEM, returnCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
45
46
  .command(REPLACE_CHECKOUT_ITEM, replaceCheckoutItemHandler)(getCheckoutItem, saveCheckoutItem, ...checkoutItemsDependencies)
47
+ .query(VIEW_PRICING_BY_CHECKOUT_ID, viewPricingByCheckoutIdHandler, {
48
+ view: pricingByCheckoutIdView,
49
+ })
46
50
  .query(VIEW_BOOKED_SIZE_CHANGE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM, viewBookedSizeChangeProductsVariantsForCheckoutItemHandler, {
47
51
  view: bookedSizeChangeProductsVariantsForCheckoutItemView,
48
52
  })
@@ -9,6 +9,7 @@ import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/checko
9
9
  import { httpFiveItemsDiscountByCustomerIdView } from "../projection/checkout/httpFiveItemsDiscountByCustomerIdView";
10
10
  import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/checkout/httpIsCheckoutEnabledByCustomerIdView";
11
11
  import { httpCheckoutItemByIdView } from "../projection/checkoutItem/httpCheckoutItemByIdView";
12
+ import { httpPricingByCheckoutIdView } from "../projection/pricing/httpPricingByCheckoutIdView";
12
13
  import { httpReturnQuestionsByCheckoutItemIdView } from "../projection/returnQuestion/httpReturnQuestionsByCheckoutItemIdView";
13
14
  import { storageUiSettingByKeyView } from "../projection/uiSetting/storageUiSettingByKeyView";
14
15
  import { baseBootstrap } from "./baseBootstrap";
@@ -27,6 +28,9 @@ const bootstrap = ({ apiUrl, getAuthToken }) => {
27
28
  bookedSizeChangeProductsVariantsForCheckoutItemView: httpBookedSizeChangeProductsVariantsForCheckoutItemView({
28
29
  httpPost,
29
30
  }),
31
+ pricingByCheckoutIdView: httpPricingByCheckoutIdView({
32
+ httpPost,
33
+ }),
30
34
  getUiSetting,
31
35
  saveUiSetting,
32
36
  uiSettingsDependencies: [{ read, write }],
@@ -11,7 +11,6 @@ const toCheckoutBookingDomain = (checkoutBooking) => {
11
11
  };
12
12
  const toCheckoutBookingProjection = (checkoutBooking) => ({
13
13
  id: checkoutBooking.aggregateId,
14
- checkoutId: checkoutBooking.checkoutId,
15
14
  checkoutItemIds: checkoutBooking.checkoutItemIds,
16
15
  });
17
16
  const getCheckoutBooking = ({ queryBus }) => async (aggregateId) => toCheckoutBookingDomain(await queryBus(viewBookedSizeChangeProductsVariantsForCheckoutItem({ checkoutItemId: aggregateId })));
@@ -4,7 +4,6 @@ import { httpCheckoutBookingsBook } from "./httpCheckoutBookingsBook";
4
4
  const toDomain = (checkoutBooking) => {
5
5
  invariant(checkoutBooking, "No checkout booking found!");
6
6
  return {
7
- checkoutId: checkoutBooking.checkoutId,
8
7
  checkoutItemIds: checkoutBooking.checkoutItemIds,
9
8
  aggregateId: checkoutBooking.id,
10
9
  domainEvents: [],
@@ -1,15 +1,14 @@
1
1
  import { CHECKOUT_BOOKING_BOOKED, } from "../../../../domain/checkoutBooking/model/checkoutBookingBooked";
2
2
  const isCheckoutBookingBooked = (event) => event.name === CHECKOUT_BOOKING_BOOKED;
3
- const httpCheckoutBookingsBook = ({ httpPost }) => async ({ aggregateId, checkoutId, domainEvents }) => {
3
+ const httpCheckoutBookingsBook = ({ httpPost }) => async ({ aggregateId, domainEvents }) => {
4
4
  const checkoutBookingBooked = domainEvents.find(isCheckoutBookingBooked);
5
5
  if (!checkoutBookingBooked) {
6
6
  return;
7
7
  }
8
8
  const { checkoutItemId } = checkoutBookingBooked;
9
9
  await httpPost({
10
- endpoint: "/book-size-change-product-variants-for-checkout-item",
10
+ endpoint: "/book-checkout-booking-for-checkout-item",
11
11
  body: {
12
- checkoutId,
13
12
  checkoutItemId,
14
13
  checkoutBookingId: aggregateId,
15
14
  },
@@ -4,7 +4,6 @@ interface BookFunction {
4
4
  }
5
5
  declare type UseBookCheckouBookingForCheckoutItem = [book: BookFunction, status: CommandStatus];
6
6
  interface UseBookCheckouBookingForCheckoutItemFunctionArgs {
7
- readonly checkoutId: string;
8
7
  readonly checkoutItemId: string;
9
8
  readonly checkoutBookingId: string | undefined;
10
9
  }
@@ -3,13 +3,12 @@ import { useCallback } from "react";
3
3
  import { v4 as uuid } from "uuid";
4
4
  import { bookCheckoutBookingForCheckoutItem } from "../../../../domain/checkoutBooking/command/bookCheckoutBookingForCheckoutItem";
5
5
  import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
6
- const useBookCheckouBookingForCheckoutItem = ({ checkoutId, checkoutItemId, checkoutBookingId, }) => {
6
+ const useBookCheckouBookingForCheckoutItem = ({ checkoutItemId, checkoutBookingId, }) => {
7
7
  const [commandBus, status] = useCommand({ contextId: MESSAGING_CONTEXT_ID });
8
8
  const book = useCallback(() => commandBus(bookCheckoutBookingForCheckoutItem({
9
9
  aggregateId: checkoutBookingId || uuid(),
10
- checkoutId,
11
10
  checkoutItemId,
12
- })), [checkoutBookingId, checkoutId, checkoutItemId, commandBus]);
11
+ })), [checkoutBookingId, checkoutItemId, commandBus]);
13
12
  return [book, status];
14
13
  };
15
14
  export { useBookCheckouBookingForCheckoutItem };
@@ -0,0 +1,12 @@
1
+ import { PricingByCheckoutIdView } from "../../../projection/pricing/viewPricingByCheckoutId";
2
+ import { HttpPostFunction } from "../../delivery/http/httpClient";
3
+ interface HttpPricingByCheckoutIdView extends PricingByCheckoutIdView {
4
+ }
5
+ interface HttpPricingByCheckoutIdViewFunctionArgs {
6
+ readonly httpPost: HttpPostFunction;
7
+ }
8
+ interface HttpPricingByCheckoutIdViewFunction {
9
+ (args: HttpPricingByCheckoutIdViewFunctionArgs): HttpPricingByCheckoutIdView;
10
+ }
11
+ declare const httpPricingByCheckoutIdView: HttpPricingByCheckoutIdViewFunction;
12
+ export { httpPricingByCheckoutIdView };
@@ -0,0 +1,9 @@
1
+ const httpPricingByCheckoutIdView = ({ httpPost }) => async ({ checkoutId, signal }) => {
2
+ const response = await httpPost({
3
+ endpoint: "/view-pricing-by-checkout-id",
4
+ body: { checkoutId },
5
+ signal,
6
+ });
7
+ return !response.ok || response.status === 404 ? null : (await response.json()).result;
8
+ };
9
+ export { httpPricingByCheckoutIdView };
@@ -0,0 +1,3 @@
1
+ import { PricingProjection } from "../../../projection/pricing/pricing";
2
+ declare const pricing: PricingProjection;
3
+ export { pricing };
@@ -1,4 +1,4 @@
1
- import { Currency } from "../../domain/checkoutItem/model/currency";
1
+ import { Currency } from "../../../domain/checkoutItem/model/currency";
2
2
  const pricing = {
3
3
  orderTotal: {
4
4
  amount: 14323,
@@ -0,0 +1,10 @@
1
+ import { UseQueryFunctionResult } from "@lookiero/messaging-react";
2
+ import { PricingProjection } from "../../../../projection/pricing/pricing";
3
+ interface UseViewPricingByCheckoutIdFunctionArgs {
4
+ readonly checkoutId: string;
5
+ }
6
+ interface UseViewPricingByCheckoutIdFunction {
7
+ (args: UseViewPricingByCheckoutIdFunctionArgs): UseQueryFunctionResult<PricingProjection>;
8
+ }
9
+ declare const useViewPricingByCheckoutId: UseViewPricingByCheckoutIdFunction;
10
+ export { useViewPricingByCheckoutId };
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@lookiero/messaging-react";
2
+ import { viewPricingByCheckoutId } from "../../../../projection/pricing/viewPricingByCheckoutId";
3
+ import { MESSAGING_CONTEXT_ID } from "../../../delivery/baseBootstrap";
4
+ const useViewPricingByCheckoutId = ({ checkoutId }) => useQuery({
5
+ query: viewPricingByCheckoutId({ checkoutId }),
6
+ contextId: MESSAGING_CONTEXT_ID,
7
+ options: { staleTime: Infinity, retry: false, refetchOnWindowFocus: false },
8
+ });
9
+ export { useViewPricingByCheckoutId };
@@ -40,7 +40,6 @@ const Item = ({ customerId }) => {
40
40
  });
41
41
  const [bookCheckouBooking] = useBookCheckouBookingForCheckoutItem({
42
42
  checkoutBookingId: bookedSizeChangeProductsVariants?.id,
43
- checkoutId: checkout?.id,
44
43
  checkoutItemId: checkoutItem.id,
45
44
  });
46
45
  const [returnQuestions, returnQuestionsStatus] = useListReturnQuestionsByCheckoutItemId({
@@ -1,7 +1,7 @@
1
1
  import { QueryStatus } from "@lookiero/messaging-react";
2
2
  import React, { useCallback, useState } from "react";
3
- import { pricing } from "../../../../projection/pricing/pricing.mock";
4
3
  import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
4
+ import { pricing } from "../../../projection/pricing/pricing.mock";
5
5
  import { Body } from "../../components/layouts/body/Body";
6
6
  import { SafeAreaScrollView } from "../../components/templates/SafeAreaScrollView";
7
7
  import { Spinner } from "../../shared/components/atoms/spinner/Spinner";
@@ -1,6 +1,5 @@
1
1
  interface CheckoutBookingProjection {
2
2
  readonly id: string;
3
- readonly checkoutId: string;
4
3
  readonly checkoutItemIds: string[];
5
4
  }
6
5
  export type { CheckoutBookingProjection };
@@ -0,0 +1,25 @@
1
+ import { CancelableQueryViewArgs, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { PricingProjection } from "./pricing";
3
+ declare const VIEW_PRICING_BY_CHECKOUT_ID = "view_pricing_by_checkout_id";
4
+ interface ViewPricingByCheckoutIdPayload {
5
+ readonly checkoutId: string;
6
+ }
7
+ interface ViewPricingByCheckoutId extends Query<typeof VIEW_PRICING_BY_CHECKOUT_ID>, ViewPricingByCheckoutIdPayload {
8
+ }
9
+ interface ViewPricingByCheckoutIdFunction {
10
+ (payload: ViewPricingByCheckoutIdPayload): ViewPricingByCheckoutId;
11
+ }
12
+ declare const viewPricingByCheckoutId: ViewPricingByCheckoutIdFunction;
13
+ declare type ViewPricingByCheckoutIdResult = PricingProjection | null;
14
+ interface PricingByCheckoutIdViewArgs extends CancelableQueryViewArgs {
15
+ readonly checkoutId: string;
16
+ }
17
+ interface PricingByCheckoutIdView {
18
+ (args: PricingByCheckoutIdViewArgs): Promise<ViewPricingByCheckoutIdResult>;
19
+ }
20
+ interface ViewPricingByCheckoutIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
21
+ readonly view: PricingByCheckoutIdView;
22
+ }
23
+ declare const viewPricingByCheckoutIdHandler: QueryHandlerFunction<ViewPricingByCheckoutId, ViewPricingByCheckoutIdResult, ViewPricingByCheckoutIdHandlerFunctionArgs>;
24
+ export type { ViewPricingByCheckoutId, PricingByCheckoutIdView, ViewPricingByCheckoutIdResult };
25
+ export { VIEW_PRICING_BY_CHECKOUT_ID, viewPricingByCheckoutId, viewPricingByCheckoutIdHandler };
@@ -0,0 +1,8 @@
1
+ import { query, } from "@lookiero/messaging";
2
+ const VIEW_PRICING_BY_CHECKOUT_ID = "view_pricing_by_checkout_id";
3
+ const viewPricingByCheckoutId = (payload) => ({
4
+ ...query({ name: VIEW_PRICING_BY_CHECKOUT_ID }),
5
+ ...payload,
6
+ });
7
+ const viewPricingByCheckoutIdHandler = ({ view, signal }) => async ({ checkoutId }) => view({ checkoutId, signal });
8
+ export { VIEW_PRICING_BY_CHECKOUT_ID, viewPricingByCheckoutId, viewPricingByCheckoutIdHandler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -1,3 +0,0 @@
1
- import { PricingProjection } from "./pricing";
2
- declare const pricing: PricingProjection;
3
- export { pricing };