@lookiero/checkout 0.1.1 → 0.2.0

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 (165) hide show
  1. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +4 -4
  2. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +3 -2
  3. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +3 -2
  4. package/dist/domain/checkoutBooking/model/checkoutBooking.js +2 -1
  5. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +4 -4
  6. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.js +3 -2
  7. package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +3 -2
  8. package/dist/domain/uiSetting/command/updateUiSetting.d.ts +4 -4
  9. package/dist/domain/uiSetting/command/updateUiSetting.js +3 -2
  10. package/dist/domain/uiSetting/model/uiSetting.d.ts +3 -2
  11. package/dist/domain/uiSetting/model/uiSetting.js +2 -1
  12. package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +4 -4
  13. package/dist/domain/uiSetting/model/uiSettingUpdated.js +3 -2
  14. package/dist/domain/uiSetting/model/uiSettings.d.ts +3 -2
  15. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +2 -1
  16. package/dist/infrastructure/delivery/bootstrap.d.ts +2 -1
  17. package/dist/infrastructure/delivery/bootstrap.js +3 -2
  18. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.d.ts +2 -2
  19. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +2 -1
  20. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -2
  21. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
  22. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +13 -0
  23. package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +9 -0
  24. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +2 -2
  25. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +2 -1
  26. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +3 -3
  27. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.js +3 -2
  28. package/dist/infrastructure/persistence/asyncStorageStorage.d.ts +3 -2
  29. package/dist/infrastructure/persistence/asyncStorageStorage.js +3 -2
  30. package/dist/infrastructure/persistence/storage.d.ts +3 -2
  31. package/dist/infrastructure/persistence/uiSettingData.d.ts +2 -1
  32. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
  33. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.d.ts +2 -0
  34. package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.js +6 -0
  35. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +2 -1
  36. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +2 -1
  37. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +3 -3
  38. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +9 -5
  39. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +2 -2
  40. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +2 -1
  41. package/dist/infrastructure/ui/Root.js +8 -10
  42. package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +9 -0
  43. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +4 -4
  44. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +13 -10
  45. package/dist/infrastructure/ui/routing/Routing.js +11 -14
  46. package/dist/infrastructure/ui/settings/UISettings.d.ts +4 -0
  47. package/dist/infrastructure/ui/settings/UISettings.js +5 -0
  48. package/dist/infrastructure/ui/views/intro/Intro.js +5 -7
  49. package/dist/infrastructure/ui/views/item/Item.js +6 -8
  50. package/dist/infrastructure/ui/views/summary/Summary.js +5 -7
  51. package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +6 -6
  52. package/dist/projection/uiSetting/viewUiSettingByKey.js +4 -3
  53. package/package.json +6 -3
  54. package/.eslintignore +0 -7
  55. package/.eslintrc +0 -72
  56. package/.expo-shared/assets.json +0 -4
  57. package/.github/CODEOWNERS +0 -1
  58. package/.github/actions/version/action.yaml +0 -32
  59. package/.github/dependabot.yaml +0 -10
  60. package/.github/workflows/build.yaml +0 -71
  61. package/.github/workflows/publish.yaml +0 -52
  62. package/.husky/pre-commit +0 -4
  63. package/.husky/prepare-commit-msg +0 -26
  64. package/.husky/prepush +0 -12
  65. package/.lintstagedrc.json +0 -4
  66. package/.nvmrc +0 -1
  67. package/.prettierignore +0 -2
  68. package/.prettierrc.json +0 -6
  69. package/@types/aurora-next.d.ts +0 -1
  70. package/app.config.js +0 -4
  71. package/app.json +0 -31
  72. package/assets/adaptive-icon.png +0 -0
  73. package/assets/favicon.png +0 -0
  74. package/assets/icon.png +0 -0
  75. package/assets/splash.png +0 -0
  76. package/babel.config.js +0 -6
  77. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.d.ts +0 -3
  78. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.js +0 -3
  79. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +0 -11
  80. package/dist/infrastructure/ui/test/render.d.ts +0 -19
  81. package/dist/infrastructure/ui/test/render.js +0 -14
  82. package/jest.config.js +0 -9
  83. package/jest.setup.js +0 -3
  84. package/src/Expo.tsx +0 -59
  85. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -26
  86. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -27
  87. package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +0 -30
  88. package/src/domain/checkoutBooking/model/checkoutBooking.ts +0 -31
  89. package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +0 -23
  90. package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +0 -23
  91. package/src/domain/checkoutBooking/model/checkoutBookings.ts +0 -6
  92. package/src/domain/uiSetting/command/updateUiSetting.test.ts +0 -19
  93. package/src/domain/uiSetting/command/updateUiSetting.ts +0 -23
  94. package/src/domain/uiSetting/model/uiSetting.test.ts +0 -26
  95. package/src/domain/uiSetting/model/uiSetting.ts +0 -22
  96. package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +0 -17
  97. package/src/domain/uiSetting/model/uiSettingUpdated.ts +0 -19
  98. package/src/domain/uiSetting/model/uiSettings.ts +0 -6
  99. package/src/index.ts +0 -44
  100. package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +0 -38
  101. package/src/infrastructure/delivery/_mock/checkout.mock.ts +0 -81
  102. package/src/infrastructure/delivery/bootstrap.ts +0 -42
  103. package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +0 -51
  104. package/src/infrastructure/delivery/http/fetchHttpClient.ts +0 -41
  105. package/src/infrastructure/delivery/http/httpClient.ts +0 -18
  106. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +0 -45
  107. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +0 -32
  108. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -38
  109. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -44
  110. package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +0 -31
  111. package/src/infrastructure/domain/react/useUpdateUiSetting.ts +0 -43
  112. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +0 -50
  113. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +0 -50
  114. package/src/infrastructure/persistence/asyncStorageStorage.ts +0 -12
  115. package/src/infrastructure/persistence/storage.ts +0 -7
  116. package/src/infrastructure/persistence/uiSettingData.ts +0 -5
  117. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +0 -65
  118. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +0 -102
  119. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +0 -99
  120. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +0 -128
  121. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +0 -32
  122. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +0 -27
  123. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -51
  124. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -25
  125. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +0 -28
  126. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +0 -22
  127. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -44
  128. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -24
  129. package/src/infrastructure/projection/react/useViewIsCheckoutIntroVisible.ts +0 -5
  130. package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +0 -30
  131. package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +0 -18
  132. package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +0 -32
  133. package/src/infrastructure/projection/storageUiSettingByKeyView.ts +0 -35
  134. package/src/infrastructure/ui/Root.tsx +0 -53
  135. package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +0 -12
  136. package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +0 -35
  137. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -70
  138. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -31
  139. package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +0 -100
  140. package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +0 -52
  141. package/src/infrastructure/ui/routing/Routing.tsx +0 -64
  142. package/src/infrastructure/ui/routing/router/Router.native.ts +0 -1
  143. package/src/infrastructure/ui/routing/router/Router.ts +0 -1
  144. package/src/infrastructure/ui/routing/routes.ts +0 -6
  145. package/src/infrastructure/ui/test/render.tsx +0 -47
  146. package/src/infrastructure/ui/views/intro/Intro.test.tsx +0 -15
  147. package/src/infrastructure/ui/views/intro/Intro.tsx +0 -27
  148. package/src/infrastructure/ui/views/item/Item.tsx +0 -31
  149. package/src/infrastructure/ui/views/summary/Summary.tsx +0 -27
  150. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -40
  151. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -85
  152. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +0 -22
  153. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +0 -149
  154. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
  155. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
  156. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +0 -20
  157. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +0 -51
  158. package/src/projection/uiSetting/viewUiSettingByKey.test.ts +0 -22
  159. package/src/projection/uiSetting/viewUiSettingByKey.ts +0 -47
  160. package/tsconfig.build.json +0 -16
  161. package/tsconfig.json +0 -19
  162. package/webpack.config.js +0 -17
  163. /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.d.ts +0 -0
  164. /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.d.ts +0 -0
  165. /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.js +0 -0
@@ -1,11 +0,0 @@
1
- import { View } from "react-native";
2
- import { style } from "./Spinner.style";
3
- const Spinner = () => (<View style={style.container}>
4
- <svg xmlns="http://www.w3.org/2000/svg" width="30px" height="30px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
5
- <circle cx="50" cy="50" r="32" stroke="#000000" strokeWidth="6" strokeLinecap="round" fill="none">
6
- <animateTransform attributeName="transform" type="rotate" repeatCount="indefinite" dur="1.5384615384615383s" values="0 50 50;180 50 50;720 50 50" keyTimes="0;0.5;1"></animateTransform>
7
- <animate attributeName="stroke-dasharray" repeatCount="indefinite" dur="1.5384615384615383s" values="42.22300526424682 158.83892456549995;176.93449825017714 24.127431579569617;42.22300526424682 158.83892456549995" keyTimes="0;0.5;1"></animate>
8
- </circle>
9
- </svg>
10
- </View>);
11
- export { Spinner };
@@ -1,19 +0,0 @@
1
- import { ReactElement } from "react";
2
- import { RenderAPI } from "@testing-library/react-native";
3
- import { TranslationMessages } from "@lookiero/i18n/domain/translation/model/translationMessages";
4
- import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
5
- interface Viewport {
6
- readonly height: number;
7
- readonly width: number;
8
- }
9
- interface RenderArgs {
10
- readonly locale?: string;
11
- readonly viewport?: Viewport;
12
- readonly messages?: TranslationMessages;
13
- readonly messaging?: MessagingRoot;
14
- }
15
- interface RenderWithProvidersFunction {
16
- (ui: ReactElement, args?: RenderArgs): RenderAPI;
17
- }
18
- declare const renderWithProviders: RenderWithProvidersFunction;
19
- export { renderWithProviders as render };
@@ -1,14 +0,0 @@
1
- import { Aurora } from "@lookiero/aurora-next/build/components/primitives/Aurora/Aurora";
2
- import { Fragment } from "react";
3
- import { render } from "@testing-library/react-native";
4
- import { IntlProvider } from "react-intl";
5
- const defaultViewport = { width: 1200, height: 800 };
6
- const renderWrapper = ({ locale, viewport, messages = {}, messaging: Messaging = Fragment }) =>
7
- // eslint-disable-next-line react/display-name, react/prop-types
8
- ({ children }) => (<Aurora forceViewport={viewport}>
9
- <IntlProvider messages={messages} locale={locale} onError={() => void 0}>
10
- <Messaging>{children}</Messaging>
11
- </IntlProvider>
12
- </Aurora>);
13
- const renderWithProviders = (ui, { locale, viewport, messages, messaging } = { locale: "en", viewport: defaultViewport }) => render(ui, { wrapper: renderWrapper({ locale, viewport, messages, messaging }) });
14
- export { renderWithProviders as render };
package/jest.config.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- preset: "jest-expo",
3
- transformIgnorePatterns: [
4
- "node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg|@lookiero/messaging|@lookiero/messaging-react|@lookiero/i18n|@lookiero/i18n-react|react-router-native)",
5
- ],
6
- coveragePathIgnorePatterns: ["<rootDir>/src/infrastructure/ui/test/"],
7
- testPathIgnorePatterns: ["<rootDir>/dist/"],
8
- setupFiles: ["<rootDir>/jest.setup.js"],
9
- };
package/jest.setup.js DELETED
@@ -1,3 +0,0 @@
1
- import mockAsyncStorage from "@react-native-async-storage/async-storage/jest/async-storage-mock";
2
-
3
- jest.mock("@react-native-async-storage/async-storage", () => mockAsyncStorage);
package/src/Expo.tsx DELETED
@@ -1,59 +0,0 @@
1
- import { Aurora } from "@lookiero/aurora-next/build/components/primitives/Aurora/Aurora";
2
- import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
3
- import { useFonts } from "expo-font";
4
- import { activateKeepAwake } from "expo-keep-awake";
5
- import withExpoRoot from "expo/build/launch/withExpoRoot";
6
- import { useCallback, useState } from "react";
7
- import { createRoot } from "react-dom/client";
8
- import { AppRegistry, Platform, StatusBar } from "react-native";
9
- // import { bootstrap as checkoutMockBootstrap } from "./infrastructure/delivery/_mock/bootstrap.mock";
10
- import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootstrap";
11
- import { root } from "./infrastructure/ui/Root";
12
-
13
- const apiUrl = Platform.OS === "web" ? "/local-to-dev" : "https://web2.ps.dev.aws.lookiero.es/checkout/api";
14
- const authToken =
15
- "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjIwOTUxNjAsImV4cCI6MTY2NTEzMzQxMywiZGlzcGxheU5hbWUiOiJBbGV4YW5kZXIiLCJjb3VudHJ5X2NvZGUiOiJFUyIsImFjY2Vzc1ZpYSI6ImVtYWlsIiwic3Vic2NyaXB0aW9uU3RhcnRpbmdEYXRlIjoiMjAyMC0wOS0wMSIsImltcGVyc29uYXRlZCI6ZmFsc2UsInV1aWQiOiJjZjdjNjQxZi0wZTVjLTQ4NTAtYWUwNy0yNzY3NDdlZGZkMGIiLCJpYXQiOjE2NjI1NDE0MTN9.v17FPhySnvKPjOYiZumdcy-pVQO-F_PHjWSY-tnk2xU";
16
-
17
- // const { Component: Messaging } = checkoutMockBootstrap();
18
- const { Component: Messaging } = checkoutBootstrap({ apiUrl, getAuthToken: () => authToken });
19
- const Root = root({ Messaging });
20
-
21
- const ExpoRoot = () => {
22
- const [fontsLoaded] = useFonts({
23
- ["Romie-Regular"]: require("@lookiero/aurora-fonts/Romie-Regular.ttf"),
24
- ["FoundersGroteskText-Regular"]: require("@lookiero/aurora-fonts/FoundersGroteskText-Regular.ttf"),
25
- auroraicons: require("@lookiero/aurora-iconfont/dist/auroraicons.ttf"),
26
- });
27
-
28
- const [isAccessible, setIsAccessible] = useState<boolean>();
29
- const onNotAccessible = useCallback(() => setIsAccessible(false), []);
30
-
31
- return fontsLoaded ? (
32
- <>
33
- <Aurora usePortal={false} useStack={false}>
34
- {isAccessible === false && <Text heading={true}>Checkout is not accessible!</Text>}
35
- <Root locale="es" customerId="606d8c89-d4f2-438b-89a8-906e6526992d" onNotAccessible={onNotAccessible} />
36
- </Aurora>
37
- <StatusBar />
38
- </>
39
- ) : null;
40
- };
41
-
42
- if (__DEV__) {
43
- activateKeepAwake();
44
- }
45
-
46
- AppRegistry.registerComponent("main", () => withExpoRoot(ExpoRoot));
47
-
48
- if ("web" === Platform.OS) {
49
- const rootElement = document.getElementById("root") ?? document.getElementById("main");
50
-
51
- if (rootElement) {
52
- const rootTag = createRoot(rootElement);
53
- const RootComponent = withExpoRoot(ExpoRoot);
54
-
55
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
- // @ts-ignore
57
- rootTag.render(<RootComponent />);
58
- }
59
- }
@@ -1,26 +0,0 @@
1
- import { v4 as uuid } from "uuid";
2
- import {
3
- bookSizeReplaceableProductVariantsForCheckoutItem as sut,
4
- BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM,
5
- } from "./bookSizeReplaceableProductVariantsForCheckoutItem";
6
-
7
- describe("bookSizeReplaceableProductVariantsForCheckoutItem", () => {
8
- it("returns an BookSizeReplaceableProductVariantsForCheckoutItem command", () => {
9
- const aggregateId = uuid();
10
- const checkoutBooking = {
11
- checkoutId: "this-should-be-a-uuid",
12
- checkoutItemId: "this-should-be-a-uuid",
13
- checkoutBookingId: "this-should-be-a-uuid",
14
- };
15
-
16
- const command = sut({ aggregateId, ...checkoutBooking });
17
-
18
- expect(command.aggregateId).toBe(aggregateId);
19
- expect(command.checkoutId).toBe(checkoutBooking.checkoutId);
20
- expect(command.checkoutItemId).toBe(checkoutBooking.checkoutItemId);
21
- expect(command.checkoutBookingId).toBe(checkoutBooking.checkoutBookingId);
22
- expect(command.name).toBe(BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM);
23
- expect(typeof command.messageId).toBe("string");
24
- expect(typeof command.occurredOn).toBe("number");
25
- });
26
- });
@@ -1,27 +0,0 @@
1
- import { command, Command } from "@lookiero/messaging";
2
-
3
- export const BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM =
4
- "book_size_replaceable_product_variants_for_checkout_item";
5
-
6
- interface BookSizeReplaceableProductVariantsForCheckoutItemPayload {
7
- readonly aggregateId: string;
8
- readonly checkoutId: string;
9
- readonly checkoutItemId: string;
10
- readonly checkoutBookingId: string;
11
- }
12
-
13
- export interface BookSizeReplaceableProductVariantsForCheckoutItem
14
- extends Command<typeof BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>,
15
- BookSizeReplaceableProductVariantsForCheckoutItemPayload {}
16
-
17
- interface BookSizeReplaceableProductVariantsForCheckoutItemFunction {
18
- (
19
- payload: BookSizeReplaceableProductVariantsForCheckoutItemPayload,
20
- ): BookSizeReplaceableProductVariantsForCheckoutItem;
21
- }
22
-
23
- export const bookSizeReplaceableProductVariantsForCheckoutItem: BookSizeReplaceableProductVariantsForCheckoutItemFunction =
24
- ({ aggregateId, ...payload }) => ({
25
- ...command({ aggregateId, name: BOOK_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
26
- ...payload,
27
- });
@@ -1,30 +0,0 @@
1
- import { DomainEvent, QueryBus } from "@lookiero/messaging";
2
- import { v4 as uuid } from "uuid";
3
- import { mock } from "jest-mock-extended";
4
- import { CHECKOUT_BOOKING_BOOKED } from "./checkoutBookingBooked";
5
- import { bookSizeReplaceableProductVariantsForCheckoutItemHandler as sut } from "./checkoutBooking";
6
- import { bookSizeReplaceableProductVariantsForCheckoutItem } from "../command/bookSizeReplaceableProductVariantsForCheckoutItem";
7
-
8
- describe("checkoutBooking", () => {
9
- const queryBus = mock<QueryBus>();
10
-
11
- it("bookSizeReplaceableProductVariantsForCheckoutItem publishing CheckoutBookingBooked", async () => {
12
- const aggregateId = uuid();
13
- const checkoutBooking = {
14
- checkoutId: "this-should-be-a-uuid",
15
- checkoutItemId: "this-should-be-a-uuid",
16
- checkoutBookingId: "this-should-be-a-uuid",
17
- };
18
- const state = { aggregateId, ...checkoutBooking, domainEvents: [] };
19
-
20
- const command = bookSizeReplaceableProductVariantsForCheckoutItem({ aggregateId, ...checkoutBooking });
21
-
22
- const aggregateRoot = await sut({ queryBus })({ aggregateRoot: state, command });
23
-
24
- expect(aggregateRoot.aggregateId).toBe(aggregateId);
25
- expect(aggregateRoot.checkoutId).toBe(checkoutBooking.checkoutId);
26
- expect(aggregateRoot.checkoutItemId).toBe(checkoutBooking.checkoutItemId);
27
- expect(aggregateRoot.checkoutBookingId).toBe(checkoutBooking.checkoutBookingId);
28
- expect((aggregateRoot.domainEvents as DomainEvent<string>).name).toBe(CHECKOUT_BOOKING_BOOKED);
29
- });
30
- });
@@ -1,31 +0,0 @@
1
- import { AggregateRoot, CommandHandlerFunction } from "@lookiero/messaging";
2
- import { BookSizeReplaceableProductVariantsForCheckoutItem } from "../command/bookSizeReplaceableProductVariantsForCheckoutItem";
3
- import { checkoutBookingBooked } from "./checkoutBookingBooked";
4
-
5
- export interface CheckoutBooking extends AggregateRoot {
6
- readonly checkoutId: string;
7
- readonly checkoutItemId: string;
8
- readonly checkoutBookingId: string;
9
- }
10
-
11
- export const bookSizeReplaceableProductVariantsForCheckoutItemHandler: CommandHandlerFunction<
12
- BookSizeReplaceableProductVariantsForCheckoutItem,
13
- CheckoutBooking
14
- > =
15
- () =>
16
- async ({ aggregateRoot, command }) => {
17
- const { aggregateId, checkoutId, checkoutItemId, checkoutBookingId } = command;
18
-
19
- return {
20
- ...aggregateRoot,
21
- checkoutId,
22
- checkoutItemId,
23
- checkoutBookingId,
24
- domainEvents: checkoutBookingBooked({
25
- aggregateId,
26
- checkoutId,
27
- checkoutItemId,
28
- checkoutBookingId,
29
- }),
30
- };
31
- };
@@ -1,23 +0,0 @@
1
- import { v4 as uuid } from "uuid";
2
- import { checkoutBookingBooked as sut, CHECKOUT_BOOKING_BOOKED } from "./checkoutBookingBooked";
3
-
4
- describe("checkoutBookingBooked", () => {
5
- it("returns an CheckoutBookingBooked domain event", () => {
6
- const aggregateId = uuid();
7
- const checkoutBooking = {
8
- checkoutId: "this-should-be-a-uuid",
9
- checkoutItemId: "this-should-be-a-uuid",
10
- checkoutBookingId: "this-should-be-a-uuid",
11
- };
12
-
13
- const domainEvent = sut({ aggregateId, ...checkoutBooking });
14
-
15
- expect(domainEvent.aggregateId).toBe(aggregateId);
16
- expect(domainEvent.checkoutId).toBe(checkoutBooking.checkoutId);
17
- expect(domainEvent.checkoutItemId).toBe(checkoutBooking.checkoutItemId);
18
- expect(domainEvent.checkoutBookingId).toBe(checkoutBooking.checkoutBookingId);
19
- expect(domainEvent.name).toBe(CHECKOUT_BOOKING_BOOKED);
20
- expect(typeof domainEvent.messageId).toBe("string");
21
- expect(typeof domainEvent.occurredOn).toBe("number");
22
- });
23
- });
@@ -1,23 +0,0 @@
1
- import { domainEvent, DomainEvent } from "@lookiero/messaging";
2
-
3
- export const CHECKOUT_BOOKING_BOOKED = "checkout_booking_booked";
4
-
5
- interface CheckoutBookingBookedPayload {
6
- readonly aggregateId: string;
7
- readonly checkoutId: string;
8
- readonly checkoutItemId: string;
9
- readonly checkoutBookingId: string;
10
- }
11
-
12
- export interface CheckoutBookingBooked
13
- extends DomainEvent<typeof CHECKOUT_BOOKING_BOOKED>,
14
- CheckoutBookingBookedPayload {}
15
-
16
- interface CheckoutBookingBookedFunction {
17
- (payload: CheckoutBookingBookedPayload): CheckoutBookingBooked;
18
- }
19
-
20
- export const checkoutBookingBooked: CheckoutBookingBookedFunction = ({ aggregateId, ...payload }) => ({
21
- ...domainEvent({ aggregateId, name: CHECKOUT_BOOKING_BOOKED }),
22
- ...payload,
23
- });
@@ -1,6 +0,0 @@
1
- import { RepositoryGetFunction, RepositorySaveFunction } from "@lookiero/messaging";
2
- import { CheckoutBooking } from "./checkoutBooking";
3
-
4
- export interface CheckoutBookingsGetFunction extends RepositoryGetFunction<CheckoutBooking> {}
5
-
6
- export interface CheckoutBookingsSaveFunction extends RepositorySaveFunction<CheckoutBooking> {}
@@ -1,19 +0,0 @@
1
- import { v4 as uuid } from "uuid";
2
- import { updateUiSetting as sut, UPDATE_UI_SETTING } from "./updateUiSetting";
3
-
4
- describe("updateUiSetting", () => {
5
- it("returns an UpdateUiSetting command", () => {
6
- const aggregateId = uuid();
7
- const key = "ui_setting_key";
8
- const value = "ui_setting_value";
9
-
10
- const command = sut({ aggregateId, key, value });
11
-
12
- expect(command.aggregateId).toBe(aggregateId);
13
- expect(command.key).toBe(key);
14
- expect(command.value).toBe(value);
15
- expect(command.name).toBe(UPDATE_UI_SETTING);
16
- expect(typeof command.messageId).toBe("string");
17
- expect(typeof command.occurredOn).toBe("number");
18
- });
19
- });
@@ -1,23 +0,0 @@
1
- import { command, Command } from "@lookiero/messaging";
2
-
3
- export const UPDATE_UI_SETTING = "update_ui_setting";
4
-
5
- interface UpdateUiSettingPayload {
6
- readonly aggregateId: string;
7
- readonly key: string;
8
- readonly value: unknown;
9
- }
10
-
11
- export interface UpdateUiSetting extends Command<typeof UPDATE_UI_SETTING>, UpdateUiSettingPayload {}
12
-
13
- interface UpdateUiSettingFunction {
14
- (payload: UpdateUiSettingPayload): UpdateUiSetting;
15
- }
16
-
17
- export const updateUiSetting: UpdateUiSettingFunction = ({ aggregateId, ...payload }) => ({
18
- ...command({
19
- aggregateId,
20
- name: UPDATE_UI_SETTING,
21
- }),
22
- ...payload,
23
- });
@@ -1,26 +0,0 @@
1
- import { DomainEvent, QueryBus } from "@lookiero/messaging";
2
- import { v4 as uuid } from "uuid";
3
- import { mock } from "jest-mock-extended";
4
- import { UI_SETTING_UPDATED } from "./uiSettingUpdated";
5
- import { updateUiSettingHandler as sut } from "./uiSetting";
6
- import { updateUiSetting } from "../command/updateUiSetting";
7
-
8
- describe("uiSetting", () => {
9
- const queryBus = mock<QueryBus>();
10
-
11
- it("updateUiSetting publishing UiSettingUpdated", async () => {
12
- const aggregateId = uuid();
13
- const key = "ui_setting_key";
14
- const value = "ui_setting_value";
15
- const state = { aggregateId, key, value, domainEvents: [] };
16
-
17
- const command = updateUiSetting({ aggregateId, key, value });
18
-
19
- const aggregateRoot = await sut({ queryBus })({ aggregateRoot: state, command });
20
-
21
- expect(aggregateRoot.aggregateId).toBe(aggregateId);
22
- expect(aggregateRoot.key).toBe(key);
23
- expect(aggregateRoot.value).toBe(value);
24
- expect((aggregateRoot.domainEvents as DomainEvent<string>).name).toBe(UI_SETTING_UPDATED);
25
- });
26
- });
@@ -1,22 +0,0 @@
1
- import { AggregateRoot } from "@lookiero/messaging";
2
- import { CommandHandlerFunction } from "@lookiero/messaging/domain/model";
3
- import { UpdateUiSetting } from "../command/updateUiSetting";
4
- import { uiSettingUpdated } from "./uiSettingUpdated";
5
-
6
- export interface UiSetting extends AggregateRoot {
7
- readonly key: string;
8
- readonly value: unknown;
9
- }
10
-
11
- export const updateUiSettingHandler: CommandHandlerFunction<UpdateUiSetting, UiSetting> =
12
- () =>
13
- async ({ aggregateRoot, command }) => {
14
- const { aggregateId, key, value } = command;
15
-
16
- return {
17
- ...aggregateRoot,
18
- key,
19
- value,
20
- domainEvents: uiSettingUpdated({ aggregateId, key }),
21
- };
22
- };
@@ -1,17 +0,0 @@
1
- import { v4 as uuid } from "uuid";
2
- import { uiSettingUpdated as sut, UI_SETTING_UPDATED } from "./uiSettingUpdated";
3
-
4
- describe("uiSettingUpdated", () => {
5
- it("returns an UiSettingUpdated domain event", () => {
6
- const aggregateId = uuid();
7
- const key = "ui_setting_key";
8
-
9
- const domainEvent = sut({ aggregateId, key });
10
-
11
- expect(domainEvent.aggregateId).toBe(aggregateId);
12
- expect(domainEvent.key).toBe(key);
13
- expect(domainEvent.name).toBe(UI_SETTING_UPDATED);
14
- expect(typeof domainEvent.messageId).toBe("string");
15
- expect(typeof domainEvent.occurredOn).toBe("number");
16
- });
17
- });
@@ -1,19 +0,0 @@
1
- import { domainEvent, DomainEvent } from "@lookiero/messaging";
2
-
3
- export const UI_SETTING_UPDATED = "ui_setting_updated";
4
-
5
- interface UiSettingUpdatedPayload {
6
- readonly aggregateId: string;
7
- readonly key: string;
8
- }
9
-
10
- export interface UiSettingUpdated extends DomainEvent<typeof UI_SETTING_UPDATED>, UiSettingUpdatedPayload {}
11
-
12
- interface UiSettingUpdatedFunction {
13
- (payload: UiSettingUpdatedPayload): UiSettingUpdated;
14
- }
15
-
16
- export const uiSettingUpdated: UiSettingUpdatedFunction = ({ aggregateId, key }) => ({
17
- ...domainEvent({ aggregateId, name: UI_SETTING_UPDATED }),
18
- key,
19
- });
@@ -1,6 +0,0 @@
1
- import { RepositoryGetFunction, RepositorySaveFunction } from "@lookiero/messaging";
2
- import { UiSetting } from "./uiSetting";
3
-
4
- export interface UiSettingGetFunction extends RepositoryGetFunction<UiSetting> {}
5
-
6
- export interface UiSettingSaveFunction extends RepositorySaveFunction<UiSetting> {}
package/src/index.ts DELETED
@@ -1,44 +0,0 @@
1
- import { FC } from "react";
2
- import { bootstrap as checkoutBootstrap } from "./infrastructure/delivery/bootstrap";
3
- import { root, RootProps } from "./infrastructure/ui/Root";
4
- import {
5
- IsCheckoutAccessibleByCustomerIdProjection,
6
- viewIsCheckoutAccessibleByCustomerId,
7
- } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
8
-
9
- interface IsCheckoutAccessibleFunctionArgs {
10
- readonly customerId: string | undefined;
11
- }
12
-
13
- interface IsCheckoutAccessibleFunction {
14
- (args: IsCheckoutAccessibleFunctionArgs): Promise<IsCheckoutAccessibleByCustomerIdProjection>;
15
- }
16
-
17
- interface BootstrapFunctionArgs {
18
- readonly getAuthToken: () => string;
19
- readonly apiUrl: string;
20
- }
21
-
22
- interface BootstrapFunctionReturn {
23
- readonly Root: FC<RootProps>;
24
- readonly isCheckoutAccessible: IsCheckoutAccessibleFunction;
25
- }
26
-
27
- interface BootstrapFunction {
28
- (args: BootstrapFunctionArgs): BootstrapFunctionReturn;
29
- }
30
-
31
- const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken }) => {
32
- const { Component: Messaging, queryBus } = checkoutBootstrap({ apiUrl, getAuthToken });
33
- const Root = root({ Messaging });
34
-
35
- const isCheckoutAccessible: IsCheckoutAccessibleFunction = ({ customerId }) =>
36
- queryBus(viewIsCheckoutAccessibleByCustomerId({ customerId }));
37
-
38
- return {
39
- Root,
40
- isCheckoutAccessible,
41
- };
42
- };
43
-
44
- export { bootstrap };
@@ -1,38 +0,0 @@
1
- import { bootstrap as messagingBootstrap, BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
2
- import {
3
- CheckoutItemStatus,
4
- FirstAvailableCheckoutByCustomerIdView,
5
- viewFirstAvailableCheckoutByCustomerIdHandler,
6
- VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
7
- } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
8
- import {
9
- viewIsCheckoutAccessibleByCustomerIdHandler,
10
- VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
11
- } from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
12
- import {
13
- IsCheckoutEnabledByCustomerIdView,
14
- viewIsCheckoutEnabledByCustomerIdHandler,
15
- VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
16
- } from "../../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
17
- import { startedCheckoutWithItems } from "./checkout.mock";
18
-
19
- const firstAvailableCheckoutByCustomerIdView: FirstAvailableCheckoutByCustomerIdView = async () =>
20
- startedCheckoutWithItems({ status: [CheckoutItemStatus.KEPT, CheckoutItemStatus.INITIAL] });
21
- const isCheckoutEnabledByCustomerIdView: IsCheckoutEnabledByCustomerIdView = async () => true;
22
-
23
- interface BootstrapFunction {
24
- (): BuildBootstrapFunctionReturn;
25
- }
26
-
27
- const bootstrap: BootstrapFunction = () =>
28
- messagingBootstrap({ id: "Checkout" })
29
- .query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
30
- view: firstAvailableCheckoutByCustomerIdView,
31
- })
32
- .query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
33
- view: isCheckoutEnabledByCustomerIdView,
34
- })
35
- .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
36
- .build();
37
-
38
- export { bootstrap };
@@ -1,81 +0,0 @@
1
- import { v4 as uuid } from "uuid";
2
- import {
3
- CheckoutItemProjection,
4
- CheckoutItemStatus,
5
- CheckoutProjection,
6
- CheckoutStatus,
7
- Currency,
8
- MediaPerspective,
9
- } from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
10
-
11
- interface CheckoutItemFunctionArgs {
12
- readonly status: CheckoutItemStatus;
13
- }
14
-
15
- interface CheckoutItemFunction {
16
- (args: CheckoutItemFunctionArgs): CheckoutItemProjection;
17
- }
18
-
19
- const checkoutItem: CheckoutItemFunction = ({ status }) => ({
20
- id: uuid(),
21
- status,
22
- productVariant: {
23
- id: uuid(),
24
- media: [
25
- {
26
- id: uuid(),
27
- url: "https://cdn-catalog-back-prod.envs.lookiero.tech/d2/65/d2655b80-7745-4537-bb17-eb38f960a8de.jpg",
28
- perspective: MediaPerspective.FRONT,
29
- },
30
- ],
31
- brand: "CKS",
32
- name: "Sari Tshirt lines",
33
- price: {
34
- amount: 3999,
35
- currency: Currency.EUR,
36
- },
37
- size: {
38
- id: uuid(),
39
- lookiero: "M",
40
- uk: "M",
41
- it: "M",
42
- europe: "M",
43
- unique: false,
44
- },
45
- color: {
46
- id: uuid(),
47
- label: "black_C2",
48
- },
49
- },
50
- });
51
-
52
- interface CheckoutWithItemsFunctionArgs {
53
- readonly items: CheckoutItemProjection[];
54
- }
55
-
56
- interface CheckoutWithItemsFunction {
57
- (args: CheckoutWithItemsFunctionArgs): CheckoutProjection;
58
- }
59
-
60
- const checkoutWithItems: CheckoutWithItemsFunction = ({ items }) => ({
61
- id: uuid(),
62
- status: CheckoutStatus.STARTED,
63
- customerId: uuid(),
64
- boxId: uuid(),
65
- bookingId: uuid(),
66
- expiresOn: new Date("2022-09-20"),
67
- items,
68
- });
69
-
70
- interface StartedCheckoutWithStatusFunctionArgs {
71
- readonly status: CheckoutItemStatus[];
72
- }
73
-
74
- interface StartedCheckoutWithStatusFunction {
75
- (args: StartedCheckoutWithStatusFunctionArgs): CheckoutProjection;
76
- }
77
-
78
- const startedCheckoutWithItems: StartedCheckoutWithStatusFunction = ({ status }) =>
79
- checkoutWithItems({ items: status.map((status) => checkoutItem({ status })) });
80
-
81
- export { startedCheckoutWithItems };
@@ -1,42 +0,0 @@
1
- import { bootstrap as messagingBootstrap, BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
2
- import {
3
- viewFirstAvailableCheckoutByCustomerIdHandler,
4
- VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
5
- } from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
6
- import {
7
- viewIsCheckoutAccessibleByCustomerIdHandler,
8
- VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
9
- } from "../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
10
- import {
11
- viewIsCheckoutEnabledByCustomerIdHandler,
12
- VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
13
- } from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
14
- import { httpFirstAvailableCheckoutByCustomerIdView } from "../projection/httpFirstAvailableCheckoutByCustomerIdView";
15
- import { httpIsCheckoutEnabledByCustomerIdView } from "../projection/httpIsCheckoutEnabledByCustomerIdView";
16
- import { fetchHttpGet, fetchHttpPost } from "./http/fetchHttpClient";
17
-
18
- interface BootstrapFunctionArgs {
19
- readonly getAuthToken: () => string;
20
- readonly apiUrl: string;
21
- }
22
-
23
- interface BootstrapFunction {
24
- (args: BootstrapFunctionArgs): BuildBootstrapFunctionReturn;
25
- }
26
-
27
- const bootstrap: BootstrapFunction = ({ apiUrl, getAuthToken }) => {
28
- const httpGet = fetchHttpGet({ apiUrl, getAuthToken });
29
- const httpPost = fetchHttpPost({ apiUrl, getAuthToken });
30
-
31
- return messagingBootstrap({ id: "Checkout" })
32
- .query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
33
- view: httpFirstAvailableCheckoutByCustomerIdView({ httpPost }),
34
- })
35
- .query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
36
- view: httpIsCheckoutEnabledByCustomerIdView({ httpGet }),
37
- })
38
- .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
39
- .build();
40
- };
41
-
42
- export { bootstrap };