@lookiero/checkout 0.1.1

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 (202) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc +72 -0
  3. package/.expo-shared/assets.json +4 -0
  4. package/.github/CODEOWNERS +1 -0
  5. package/.github/actions/version/action.yaml +32 -0
  6. package/.github/dependabot.yaml +10 -0
  7. package/.github/workflows/build.yaml +71 -0
  8. package/.github/workflows/publish.yaml +52 -0
  9. package/.husky/pre-commit +4 -0
  10. package/.husky/prepare-commit-msg +26 -0
  11. package/.husky/prepush +12 -0
  12. package/.lintstagedrc.json +4 -0
  13. package/.nvmrc +1 -0
  14. package/.prettierignore +2 -0
  15. package/.prettierrc.json +6 -0
  16. package/@types/aurora-next.d.ts +1 -0
  17. package/README.md +19 -0
  18. package/app.config.js +4 -0
  19. package/app.json +31 -0
  20. package/assets/adaptive-icon.png +0 -0
  21. package/assets/favicon.png +0 -0
  22. package/assets/icon.png +0 -0
  23. package/assets/splash.png +0 -0
  24. package/babel.config.js +6 -0
  25. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
  26. package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +6 -0
  27. package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +8 -0
  28. package/dist/domain/checkoutBooking/model/checkoutBooking.js +16 -0
  29. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +15 -0
  30. package/dist/domain/checkoutBooking/model/checkoutBookingBooked.js +6 -0
  31. package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +6 -0
  32. package/dist/domain/checkoutBooking/model/checkoutBookings.js +1 -0
  33. package/dist/domain/uiSetting/command/updateUiSetting.d.ts +14 -0
  34. package/dist/domain/uiSetting/command/updateUiSetting.js +9 -0
  35. package/dist/domain/uiSetting/model/uiSetting.d.ts +8 -0
  36. package/dist/domain/uiSetting/model/uiSetting.js +10 -0
  37. package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +13 -0
  38. package/dist/domain/uiSetting/model/uiSettingUpdated.js +6 -0
  39. package/dist/domain/uiSetting/model/uiSettings.d.ts +6 -0
  40. package/dist/domain/uiSetting/model/uiSettings.js +1 -0
  41. package/dist/index.d.ts +22 -0
  42. package/dist/index.js +13 -0
  43. package/dist/infrastructure/delivery/_mock/bootstrap.mock.d.ts +6 -0
  44. package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +17 -0
  45. package/dist/infrastructure/delivery/_mock/checkout.mock.d.ts +9 -0
  46. package/dist/infrastructure/delivery/_mock/checkout.mock.js +45 -0
  47. package/dist/infrastructure/delivery/bootstrap.d.ts +10 -0
  48. package/dist/infrastructure/delivery/bootstrap.js +21 -0
  49. package/dist/infrastructure/delivery/http/fetchHttpClient.d.ts +14 -0
  50. package/dist/infrastructure/delivery/http/fetchHttpClient.js +18 -0
  51. package/dist/infrastructure/delivery/http/httpClient.d.ts +14 -0
  52. package/dist/infrastructure/delivery/http/httpClient.js +1 -0
  53. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.d.ts +10 -0
  54. package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +19 -0
  55. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +15 -0
  56. package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +17 -0
  57. package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +17 -0
  58. package/dist/infrastructure/domain/react/useUpdateUiSetting.js +16 -0
  59. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +18 -0
  60. package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.js +19 -0
  61. package/dist/infrastructure/persistence/asyncStorageStorage.d.ts +4 -0
  62. package/dist/infrastructure/persistence/asyncStorageStorage.js +6 -0
  63. package/dist/infrastructure/persistence/storage.d.ts +6 -0
  64. package/dist/infrastructure/persistence/storage.js +1 -0
  65. package/dist/infrastructure/persistence/uiSettingData.d.ts +5 -0
  66. package/dist/infrastructure/persistence/uiSettingData.js +1 -0
  67. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.d.ts +36 -0
  68. package/dist/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.js +30 -0
  69. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.d.ts +60 -0
  70. package/dist/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.js +54 -0
  71. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.d.ts +12 -0
  72. package/dist/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.js +7 -0
  73. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +10 -0
  74. package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +8 -0
  75. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.d.ts +10 -0
  76. package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +8 -0
  77. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.d.ts +10 -0
  78. package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +8 -0
  79. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.d.ts +3 -0
  80. package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.js +3 -0
  81. package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +10 -0
  82. package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +8 -0
  83. package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +13 -0
  84. package/dist/infrastructure/projection/storageUiSettingByKeyView.js +14 -0
  85. package/dist/infrastructure/ui/Root.d.ts +15 -0
  86. package/dist/infrastructure/ui/Root.js +25 -0
  87. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.d.ts +3 -0
  88. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +11 -0
  89. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.style.d.ts +9 -0
  90. package/dist/infrastructure/ui/components/atoms/spiner/Spinner.style.js +10 -0
  91. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.d.ts +8 -0
  92. package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +16 -0
  93. package/dist/infrastructure/ui/routing/CheckoutMiddleware.d.ts +7 -0
  94. package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +34 -0
  95. package/dist/infrastructure/ui/routing/Routing.d.ts +7 -0
  96. package/dist/infrastructure/ui/routing/Routing.js +49 -0
  97. package/dist/infrastructure/ui/routing/router/Router.d.ts +1 -0
  98. package/dist/infrastructure/ui/routing/router/Router.js +1 -0
  99. package/dist/infrastructure/ui/routing/router/Router.native.d.ts +1 -0
  100. package/dist/infrastructure/ui/routing/router/Router.native.js +1 -0
  101. package/dist/infrastructure/ui/routing/routes.d.ts +6 -0
  102. package/dist/infrastructure/ui/routing/routes.js +7 -0
  103. package/dist/infrastructure/ui/test/render.d.ts +19 -0
  104. package/dist/infrastructure/ui/test/render.js +14 -0
  105. package/dist/infrastructure/ui/views/intro/Intro.d.ts +3 -0
  106. package/dist/infrastructure/ui/views/intro/Intro.js +20 -0
  107. package/dist/infrastructure/ui/views/item/Item.d.ts +3 -0
  108. package/dist/infrastructure/ui/views/item/Item.js +23 -0
  109. package/dist/infrastructure/ui/views/summary/Summary.d.ts +3 -0
  110. package/dist/infrastructure/ui/views/summary/Summary.js +20 -0
  111. package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.d.ts +43 -0
  112. package/dist/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.js +8 -0
  113. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.d.ts +104 -0
  114. package/dist/projection/checkout/viewFirstAvailableCheckoutByCustomerId.js +43 -0
  115. package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.d.ts +16 -0
  116. package/dist/projection/checkout/viewIsCheckoutAccessibleByCustomerId.js +13 -0
  117. package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.d.ts +23 -0
  118. package/dist/projection/checkout/viewIsCheckoutEnabledByCustomerId.js +8 -0
  119. package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +28 -0
  120. package/dist/projection/uiSetting/viewUiSettingByKey.js +7 -0
  121. package/jest.config.js +9 -0
  122. package/jest.setup.js +3 -0
  123. package/package.json +75 -0
  124. package/src/Expo.tsx +59 -0
  125. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +26 -0
  126. package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +27 -0
  127. package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +30 -0
  128. package/src/domain/checkoutBooking/model/checkoutBooking.ts +31 -0
  129. package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +23 -0
  130. package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +23 -0
  131. package/src/domain/checkoutBooking/model/checkoutBookings.ts +6 -0
  132. package/src/domain/uiSetting/command/updateUiSetting.test.ts +19 -0
  133. package/src/domain/uiSetting/command/updateUiSetting.ts +23 -0
  134. package/src/domain/uiSetting/model/uiSetting.test.ts +26 -0
  135. package/src/domain/uiSetting/model/uiSetting.ts +22 -0
  136. package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +17 -0
  137. package/src/domain/uiSetting/model/uiSettingUpdated.ts +19 -0
  138. package/src/domain/uiSetting/model/uiSettings.ts +6 -0
  139. package/src/index.ts +44 -0
  140. package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +38 -0
  141. package/src/infrastructure/delivery/_mock/checkout.mock.ts +81 -0
  142. package/src/infrastructure/delivery/bootstrap.ts +42 -0
  143. package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +51 -0
  144. package/src/infrastructure/delivery/http/fetchHttpClient.ts +41 -0
  145. package/src/infrastructure/delivery/http/httpClient.ts +18 -0
  146. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +45 -0
  147. package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +32 -0
  148. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +38 -0
  149. package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +44 -0
  150. package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +31 -0
  151. package/src/infrastructure/domain/react/useUpdateUiSetting.ts +43 -0
  152. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +50 -0
  153. package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +50 -0
  154. package/src/infrastructure/persistence/asyncStorageStorage.ts +12 -0
  155. package/src/infrastructure/persistence/storage.ts +7 -0
  156. package/src/infrastructure/persistence/uiSettingData.ts +5 -0
  157. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +65 -0
  158. package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +102 -0
  159. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +99 -0
  160. package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +128 -0
  161. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +32 -0
  162. package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +27 -0
  163. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +51 -0
  164. package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +25 -0
  165. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +28 -0
  166. package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +22 -0
  167. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +44 -0
  168. package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +24 -0
  169. package/src/infrastructure/projection/react/useViewIsCheckoutIntroVisible.ts +5 -0
  170. package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +30 -0
  171. package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +18 -0
  172. package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +32 -0
  173. package/src/infrastructure/projection/storageUiSettingByKeyView.ts +35 -0
  174. package/src/infrastructure/ui/Root.tsx +53 -0
  175. package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +12 -0
  176. package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +35 -0
  177. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +70 -0
  178. package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +31 -0
  179. package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +100 -0
  180. package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +52 -0
  181. package/src/infrastructure/ui/routing/Routing.tsx +64 -0
  182. package/src/infrastructure/ui/routing/router/Router.native.ts +1 -0
  183. package/src/infrastructure/ui/routing/router/Router.ts +1 -0
  184. package/src/infrastructure/ui/routing/routes.ts +6 -0
  185. package/src/infrastructure/ui/test/render.tsx +47 -0
  186. package/src/infrastructure/ui/views/intro/Intro.test.tsx +15 -0
  187. package/src/infrastructure/ui/views/intro/Intro.tsx +27 -0
  188. package/src/infrastructure/ui/views/item/Item.tsx +31 -0
  189. package/src/infrastructure/ui/views/summary/Summary.tsx +27 -0
  190. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +40 -0
  191. package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +85 -0
  192. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +22 -0
  193. package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +149 -0
  194. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +54 -0
  195. package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +46 -0
  196. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +20 -0
  197. package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +51 -0
  198. package/src/projection/uiSetting/viewUiSettingByKey.test.ts +22 -0
  199. package/src/projection/uiSetting/viewUiSettingByKey.ts +47 -0
  200. package/tsconfig.build.json +16 -0
  201. package/tsconfig.json +19 -0
  202. package/webpack.config.js +17 -0
@@ -0,0 +1,85 @@
1
+ import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+
3
+ interface SizeFormat {
4
+ readonly format: string;
5
+ readonly length?: string;
6
+ readonly size: string;
7
+ }
8
+
9
+ interface Size {
10
+ readonly id: string;
11
+ readonly europe: SizeFormat;
12
+ readonly it: SizeFormat;
13
+ readonly lookiero: SizeFormat;
14
+ readonly uk: SizeFormat;
15
+ }
16
+
17
+ interface ProductVariant {
18
+ readonly id: string;
19
+ readonly size: Size;
20
+ }
21
+
22
+ interface BookedSizeReplaceableProductVariantsProjection {
23
+ readonly booking: string | null;
24
+ readonly productVariants: ProductVariant[];
25
+ }
26
+
27
+ const VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM =
28
+ "view_booked_size_replaceable_product_variants_for_checkout_item";
29
+
30
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {
31
+ readonly checkoutItemId: string;
32
+ }
33
+
34
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItem
35
+ extends Query<typeof VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM>,
36
+ ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload {}
37
+
38
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction {
39
+ (
40
+ payload: ViewBookedSizeReplaceableProductVariantsForCheckoutItemPayload,
41
+ ): ViewBookedSizeReplaceableProductVariantsForCheckoutItem;
42
+ }
43
+
44
+ const viewBookedSizeReplaceableProductVariantsForCheckoutItem: ViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction =
45
+ (payload) => ({
46
+ ...query({ name: VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM }),
47
+ ...payload,
48
+ });
49
+
50
+ type ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult =
51
+ | BookedSizeReplaceableProductVariantsProjection
52
+ | undefined;
53
+
54
+ interface BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs {
55
+ readonly checkoutItemId: string;
56
+ }
57
+
58
+ interface BookedSizeReplaceableProductVariantsForCheckoutItemView {
59
+ (
60
+ args: BookedSizeReplaceableProductVariantsForCheckoutItemViewArgs,
61
+ ): Promise<ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult>;
62
+ }
63
+
64
+ interface ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs extends QueryHandlerFunctionArgs {
65
+ readonly view: BookedSizeReplaceableProductVariantsForCheckoutItemView;
66
+ }
67
+
68
+ const viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler: QueryHandlerFunction<
69
+ ViewBookedSizeReplaceableProductVariantsForCheckoutItem,
70
+ ViewBookedSizeReplaceableProductVariantsForCheckoutItemResult,
71
+ ViewBookedSizeReplaceableProductVariantsForCheckoutItemHandlerFunctionArgs
72
+ > =
73
+ ({ view }) =>
74
+ async ({ checkoutItemId }) =>
75
+ view({ checkoutItemId });
76
+
77
+ export {
78
+ Size,
79
+ ProductVariant,
80
+ BookedSizeReplaceableProductVariantsProjection,
81
+ VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM,
82
+ viewBookedSizeReplaceableProductVariantsForCheckoutItem,
83
+ BookedSizeReplaceableProductVariantsForCheckoutItemView,
84
+ viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
85
+ };
@@ -0,0 +1,22 @@
1
+ import { QueryBus } from "@lookiero/messaging";
2
+ import { mock } from "jest-mock-extended";
3
+ import {
4
+ CheckoutProjection,
5
+ viewFirstAvailableCheckoutByCustomerId,
6
+ viewFirstAvailableCheckoutByCustomerIdHandler as sut,
7
+ } from "./viewFirstAvailableCheckoutByCustomerId";
8
+
9
+ const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
10
+ const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" } as CheckoutProjection;
11
+ const queryBus = mock<QueryBus>();
12
+
13
+ describe("viewFirstAvailableCheckoutByCustomerId", () => {
14
+ it("returns the first available checkout by customer id", async () => {
15
+ const query = viewFirstAvailableCheckoutByCustomerId({ customerId });
16
+ const view = jest.fn(() => Promise.resolve(checkoutProjection));
17
+
18
+ const checkoutProjectionResult = await sut({ view, queryBus })(query);
19
+
20
+ expect(checkoutProjectionResult).toBe(checkoutProjection);
21
+ });
22
+ });
@@ -0,0 +1,149 @@
1
+ import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+
3
+ enum MediaPerspective {
4
+ BACK = "BACK",
5
+ BOTTOM_UP = "BOTTOM_UP",
6
+ COLLAGE = "COLLAGE",
7
+ DETAIL = "DETAIL",
8
+ FLAT_BACK = "FLAT_BACK",
9
+ FRONT = "FRONT",
10
+ FRONT_FAR = "FRONT_FAR",
11
+ LABEL = "LABEL",
12
+ MAIN = "MAIN",
13
+ MAIN_TRANSPARENT = "MAIN_TRANSPARENT",
14
+ OTHER = "OTHER",
15
+ SIDE = "SIDE",
16
+ }
17
+
18
+ interface MediaProjection {
19
+ readonly id: string;
20
+ readonly url: string;
21
+ readonly perspective: MediaPerspective;
22
+ }
23
+
24
+ enum Currency {
25
+ EUR = "EUR",
26
+ GBP = "GBP",
27
+ }
28
+
29
+ interface PriceProjection {
30
+ readonly amount: number;
31
+ readonly currency: Currency;
32
+ readonly discountedPrice?: {
33
+ readonly amount: number;
34
+ readonly percentage: number;
35
+ };
36
+ }
37
+
38
+ interface SizeProjection {
39
+ readonly id: string;
40
+ readonly lookiero: string;
41
+ readonly uk: string;
42
+ readonly it: string;
43
+ readonly europe: string;
44
+ readonly unique: boolean;
45
+ readonly visualOrder?: number;
46
+ }
47
+
48
+ interface ColorProjection {
49
+ readonly id: string;
50
+ readonly label: string;
51
+ }
52
+
53
+ interface CheckoutItemProductVariantProjection {
54
+ readonly id: string;
55
+ readonly media: MediaProjection[];
56
+ readonly brand: string;
57
+ readonly name: string;
58
+ readonly price: PriceProjection;
59
+ readonly size: SizeProjection;
60
+ readonly color: ColorProjection;
61
+ }
62
+
63
+ enum CheckoutItemStatus {
64
+ INITIAL = "INITIAL",
65
+ KEPT = "KEPT",
66
+ RETURNED = "RETURNED",
67
+ REPLACED = "REPLACED",
68
+ EXPIRED = "EXPIRED",
69
+ }
70
+
71
+ interface CheckoutItemProjection {
72
+ readonly id: string;
73
+ readonly status: CheckoutItemStatus;
74
+ readonly replacedFor?: string;
75
+ readonly productVariant: CheckoutItemProductVariantProjection;
76
+ // readonly feedbacks: Feedback[];
77
+ }
78
+
79
+ enum CheckoutStatus {
80
+ AVAILABLE = "AVAILABLE",
81
+ NOTIFIED = "NOTIFIED",
82
+ STARTED = "STARTED",
83
+ COMPLETED = "COMPLETED",
84
+ }
85
+
86
+ interface CheckoutProjection {
87
+ readonly id: string;
88
+ readonly customerId: string;
89
+ readonly boxId: string;
90
+ readonly bookingId: string;
91
+ readonly status: CheckoutStatus;
92
+ readonly expiresOn: Date;
93
+ readonly items: CheckoutItemProjection[];
94
+ }
95
+
96
+ const VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID = "view_first_available_checkout_by_customer_id";
97
+
98
+ interface ViewFirstAvailableCheckoutByCustomerIdPayload {
99
+ readonly customerId: string;
100
+ }
101
+
102
+ interface ViewFirstAvailableCheckoutByCustomerId
103
+ extends Query<typeof VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID>,
104
+ ViewFirstAvailableCheckoutByCustomerIdPayload {}
105
+
106
+ interface ViewFirstAvailableCheckoutByCustomerIdFunction {
107
+ (payload: ViewFirstAvailableCheckoutByCustomerIdPayload): ViewFirstAvailableCheckoutByCustomerId;
108
+ }
109
+
110
+ const viewFirstAvailableCheckoutByCustomerId: ViewFirstAvailableCheckoutByCustomerIdFunction = (payload) => ({
111
+ ...query({ name: VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID }),
112
+ ...payload,
113
+ });
114
+
115
+ type ViewFirstAvailableCheckoutByCustomerIdResult = CheckoutProjection | undefined;
116
+
117
+ interface FirstAvailableCheckoutByCustomerIdViewArgs {
118
+ readonly customerId: string;
119
+ }
120
+
121
+ interface FirstAvailableCheckoutByCustomerIdView {
122
+ (args: FirstAvailableCheckoutByCustomerIdViewArgs): Promise<ViewFirstAvailableCheckoutByCustomerIdResult>;
123
+ }
124
+
125
+ interface ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
126
+ readonly view: FirstAvailableCheckoutByCustomerIdView;
127
+ }
128
+
129
+ const viewFirstAvailableCheckoutByCustomerIdHandler: QueryHandlerFunction<
130
+ ViewFirstAvailableCheckoutByCustomerId,
131
+ ViewFirstAvailableCheckoutByCustomerIdResult,
132
+ ViewFirstAvailableCheckoutByCustomerIdHandlerFunctionArgs
133
+ > =
134
+ ({ view }) =>
135
+ async ({ customerId }) =>
136
+ view({ customerId });
137
+
138
+ export {
139
+ CheckoutProjection,
140
+ CheckoutStatus,
141
+ CheckoutItemProjection,
142
+ CheckoutItemStatus,
143
+ MediaPerspective,
144
+ Currency,
145
+ VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
146
+ viewFirstAvailableCheckoutByCustomerId,
147
+ FirstAvailableCheckoutByCustomerIdView,
148
+ viewFirstAvailableCheckoutByCustomerIdHandler,
149
+ };
@@ -0,0 +1,54 @@
1
+ import { bootstrap } from "@lookiero/messaging";
2
+ import {
3
+ CheckoutProjection,
4
+ viewFirstAvailableCheckoutByCustomerIdHandler,
5
+ VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
6
+ } from "./viewFirstAvailableCheckoutByCustomerId";
7
+ import {
8
+ viewIsCheckoutAccessibleByCustomerId,
9
+ viewIsCheckoutAccessibleByCustomerIdHandler,
10
+ VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
11
+ } from "./viewIsCheckoutAccessibleByCustomerId";
12
+ import {
13
+ viewIsCheckoutEnabledByCustomerIdHandler,
14
+ VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
15
+ } from "./viewIsCheckoutEnabledByCustomerId";
16
+
17
+ const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
18
+ const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" };
19
+ const firstAvailableCheckoutByCustomerIdViewMock = jest.fn();
20
+ const isCheckoutEnabledByCustomerIdViewMock = jest.fn();
21
+
22
+ const { queryBus } = bootstrap()
23
+ .query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
24
+ view: firstAvailableCheckoutByCustomerIdViewMock,
25
+ })
26
+ .query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
27
+ view: isCheckoutEnabledByCustomerIdViewMock,
28
+ })
29
+ .query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
30
+ .build();
31
+
32
+ // expectedResult, customerId, CheckoutProjection, isCheckoutEnabled
33
+ type Scenarios = [boolean, string | undefined, CheckoutProjection | undefined, boolean][];
34
+ const scenarios: Scenarios = [
35
+ [false, undefined, checkoutProjection, true],
36
+ [false, customerId, undefined, true],
37
+ [false, customerId, checkoutProjection, false],
38
+ [true, customerId, checkoutProjection, true],
39
+ ];
40
+
41
+ describe("viewIsCheckoutAccessibleByCustomerId", () => {
42
+ test.each(scenarios)(
43
+ "Returns %s when customer is %s, checkout projection is %s and the checkout is enabled: %s",
44
+ async (expectedResult, customerId, checkout, isEnabled) => {
45
+ firstAvailableCheckoutByCustomerIdViewMock.mockReturnValue(checkout);
46
+ isCheckoutEnabledByCustomerIdViewMock.mockReturnValue(isEnabled);
47
+ const query = viewIsCheckoutAccessibleByCustomerId({ customerId });
48
+
49
+ const result = await queryBus(query);
50
+
51
+ expect(result).toBe(expectedResult);
52
+ },
53
+ );
54
+ });
@@ -0,0 +1,46 @@
1
+ import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+ import { viewFirstAvailableCheckoutByCustomerId } from "./viewFirstAvailableCheckoutByCustomerId";
3
+ import { viewIsCheckoutEnabledByCustomerId } from "./viewIsCheckoutEnabledByCustomerId";
4
+
5
+ type IsCheckoutAccessibleByCustomerIdProjection = boolean;
6
+
7
+ const VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID = "view_is_checkout_accessible_by_customer_id";
8
+
9
+ interface ViewIsCheckoutAccessibleByCustomerIdPayload {
10
+ readonly customerId: string | undefined;
11
+ }
12
+
13
+ interface ViewIsCheckoutAccessibleByCustomerId
14
+ extends Query<typeof VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID>,
15
+ ViewIsCheckoutAccessibleByCustomerIdPayload {}
16
+
17
+ interface ViewIsCheckoutAccessibleByCustomerIdFunction {
18
+ (payload: ViewIsCheckoutAccessibleByCustomerIdPayload): ViewIsCheckoutAccessibleByCustomerId;
19
+ }
20
+
21
+ const viewIsCheckoutAccessibleByCustomerId: ViewIsCheckoutAccessibleByCustomerIdFunction = (payload) => ({
22
+ ...query({ name: VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID }),
23
+ ...payload,
24
+ });
25
+
26
+ interface ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {}
27
+
28
+ const isNonEmptyCustomerId = (customerId: string | undefined): customerId is string => Boolean(customerId);
29
+
30
+ const viewIsCheckoutAccessibleByCustomerIdHandler: QueryHandlerFunction<
31
+ ViewIsCheckoutAccessibleByCustomerId,
32
+ IsCheckoutAccessibleByCustomerIdProjection,
33
+ ViewIsCheckoutAccessibleByCustomerIdHandlerFunctionArgs
34
+ > =
35
+ ({ queryBus }) =>
36
+ async ({ customerId }) =>
37
+ isNonEmptyCustomerId(customerId) &&
38
+ Boolean(await queryBus(viewFirstAvailableCheckoutByCustomerId({ customerId }))) &&
39
+ Boolean(await queryBus(viewIsCheckoutEnabledByCustomerId({ customerId })));
40
+
41
+ export {
42
+ IsCheckoutAccessibleByCustomerIdProjection,
43
+ VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
44
+ viewIsCheckoutAccessibleByCustomerId,
45
+ viewIsCheckoutAccessibleByCustomerIdHandler,
46
+ };
@@ -0,0 +1,20 @@
1
+ import { QueryBus } from "@lookiero/messaging";
2
+ import { mock } from "jest-mock-extended";
3
+ import {
4
+ viewIsCheckoutEnabledByCustomerId,
5
+ viewIsCheckoutEnabledByCustomerIdHandler as sut,
6
+ } from "./viewIsCheckoutEnabledByCustomerId";
7
+
8
+ const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
9
+ const queryBus = mock<QueryBus>();
10
+
11
+ describe("viewIsCheckoutEnabledByCustomerId", () => {
12
+ it("returns true/false if the checkout is enabled/not by customer id", async () => {
13
+ const query = viewIsCheckoutEnabledByCustomerId({ customerId });
14
+ const view = jest.fn(() => Promise.resolve(true));
15
+
16
+ const result = await sut({ view, queryBus })(query);
17
+
18
+ expect(result).toBe(true);
19
+ });
20
+ });
@@ -0,0 +1,51 @@
1
+ import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+
3
+ type IsCheckoutEnabledByCustomerIdProjection = boolean;
4
+
5
+ const VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID = "view_is_checkout_enabled_by_customer_id";
6
+
7
+ interface ViewIsCheckoutEnabledByCustomerIdPayload {
8
+ readonly customerId: string;
9
+ }
10
+
11
+ interface ViewIsCheckoutEnabledByCustomerId
12
+ extends Query<typeof VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID>,
13
+ ViewIsCheckoutEnabledByCustomerIdPayload {}
14
+
15
+ interface ViewIsCheckoutEnabledByCustomerIdFunction {
16
+ (payload: ViewIsCheckoutEnabledByCustomerIdPayload): ViewIsCheckoutEnabledByCustomerId;
17
+ }
18
+
19
+ const viewIsCheckoutEnabledByCustomerId: ViewIsCheckoutEnabledByCustomerIdFunction = (payload) => ({
20
+ ...query({ name: VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID }),
21
+ ...payload,
22
+ });
23
+
24
+ interface IsCheckoutEnabledByCustomerIdViewArgs {
25
+ readonly customerId: string;
26
+ }
27
+
28
+ interface IsCheckoutEnabledByCustomerIdView {
29
+ (args: IsCheckoutEnabledByCustomerIdViewArgs): Promise<IsCheckoutEnabledByCustomerIdProjection>;
30
+ }
31
+
32
+ interface ViewIsCheckoutEnabledByCustomerIdHandlerFunctionArgs extends QueryHandlerFunctionArgs {
33
+ readonly view: IsCheckoutEnabledByCustomerIdView;
34
+ }
35
+
36
+ const viewIsCheckoutEnabledByCustomerIdHandler: QueryHandlerFunction<
37
+ ViewIsCheckoutEnabledByCustomerId,
38
+ IsCheckoutEnabledByCustomerIdProjection,
39
+ ViewIsCheckoutEnabledByCustomerIdHandlerFunctionArgs
40
+ > =
41
+ ({ view }) =>
42
+ async ({ customerId }) =>
43
+ view({ customerId });
44
+
45
+ export {
46
+ IsCheckoutEnabledByCustomerIdProjection,
47
+ VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
48
+ viewIsCheckoutEnabledByCustomerId,
49
+ IsCheckoutEnabledByCustomerIdView,
50
+ viewIsCheckoutEnabledByCustomerIdHandler,
51
+ };
@@ -0,0 +1,22 @@
1
+ import { QueryBus } from "@lookiero/messaging";
2
+ import { mock } from "jest-mock-extended";
3
+ import { viewUiSettingByKey, viewUiSettingByKeyHandler as sut, UiSettingProjection } from "./viewUiSettingByKey";
4
+
5
+ const uiSettingKey = "ui_setting_key";
6
+ const uiSettingProjection: UiSettingProjection = {
7
+ id: "this-should-be-a-uuid",
8
+ key: uiSettingKey,
9
+ value: "ui_setting_value",
10
+ };
11
+ const queryBus = mock<QueryBus>();
12
+
13
+ describe("viewUiSettingByKey", () => {
14
+ it("returns ui setting by key", async () => {
15
+ const query = viewUiSettingByKey({ key: uiSettingKey });
16
+ const view = jest.fn(() => Promise.resolve(uiSettingProjection));
17
+
18
+ const uiSettingProjectionResult = await sut({ view, queryBus })(query);
19
+
20
+ expect(uiSettingProjectionResult).toBe(uiSettingProjection);
21
+ });
22
+ });
@@ -0,0 +1,47 @@
1
+ import { query, Query, QueryHandlerFunction, QueryHandlerFunctionArgs } from "@lookiero/messaging";
2
+
3
+ export interface UiSettingProjection {
4
+ readonly id: string;
5
+ readonly key: string;
6
+ readonly value: unknown;
7
+ }
8
+
9
+ export const VIEW_UI_SETTING_BY_KEY = "view_ui_setting_by_key";
10
+
11
+ interface ViewUiSettingByKeyPayload {
12
+ readonly key: string;
13
+ }
14
+
15
+ interface ViewUiSettingByKey extends Query<typeof VIEW_UI_SETTING_BY_KEY>, ViewUiSettingByKeyPayload {}
16
+
17
+ interface ViewUiSettingByKeyFunction {
18
+ (payload: ViewUiSettingByKeyPayload): ViewUiSettingByKey;
19
+ }
20
+
21
+ type ViewUiSettingByKeyResult = UiSettingProjection | undefined;
22
+
23
+ interface UiSettingByKeyViewArgs {
24
+ readonly key: string;
25
+ }
26
+
27
+ export interface UiSettingByKeyView {
28
+ (args: UiSettingByKeyViewArgs): Promise<ViewUiSettingByKeyResult>;
29
+ }
30
+
31
+ interface ViewUiSettingByKeyHandlerFunctionArgs extends QueryHandlerFunctionArgs {
32
+ readonly view: UiSettingByKeyView;
33
+ }
34
+
35
+ export const viewUiSettingByKey: ViewUiSettingByKeyFunction = (payload) => ({
36
+ ...query({ name: VIEW_UI_SETTING_BY_KEY }),
37
+ ...payload,
38
+ });
39
+
40
+ export const viewUiSettingByKeyHandler: QueryHandlerFunction<
41
+ ViewUiSettingByKey,
42
+ ViewUiSettingByKeyResult,
43
+ ViewUiSettingByKeyHandlerFunctionArgs
44
+ > =
45
+ ({ view }) =>
46
+ async ({ key }) =>
47
+ view({ key });
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ },
6
+ "exclude": [
7
+ "node_modules",
8
+ "babel.config.js",
9
+ "metro.config.js",
10
+ "jest.config.js",
11
+ "dist",
12
+ "src/Expo.tsx",
13
+ "**/*.test.ts",
14
+ "**/*.test.tsx"
15
+ ]
16
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "expo/tsconfig.base",
3
+ "compilerOptions": {
4
+ "module": "esnext",
5
+ "allowJs": false,
6
+ "noEmit": false,
7
+ "declaration": true,
8
+ "strict": true,
9
+ "useUnknownInCatchVariables": true,
10
+ "noImplicitAny": true,
11
+ "noImplicitOverride": true,
12
+ "noImplicitReturns": true,
13
+ "noUnusedLocals": true,
14
+ "noUnusedParameters": true,
15
+ "noUncheckedIndexedAccess": true,
16
+ "forceConsistentCasingInFileNames": true
17
+ },
18
+ "exclude": ["dist"]
19
+ }
@@ -0,0 +1,17 @@
1
+ const createExpoWebpackConfigAsync = require("@expo/webpack-config");
2
+
3
+ module.exports = async function (env, argv) {
4
+ const config = await createExpoWebpackConfigAsync(env, argv);
5
+
6
+ config.devServer.proxy = {
7
+ ["/local-to-dev"]: {
8
+ target: "https://web2.ps.dev.aws.lookiero.es/checkout/api",
9
+ pathRewrite: { ["^/local-to-dev"]: "" },
10
+ secure: false,
11
+ changeOrigin: true,
12
+ logLevel: "debug",
13
+ },
14
+ };
15
+
16
+ return config;
17
+ };