@vonq/hapi-elements-types 1.3.0 → 1.5.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 (187) hide show
  1. package/enums.ts +41 -0
  2. package/package.json +6 -7
  3. package/src/_window/api.types.ts +59 -0
  4. package/src/_window/auth.types.ts +11 -0
  5. package/src/_window/config.types.ts +30 -0
  6. package/src/_window/events.types.ts +157 -0
  7. package/src/_window/index.ts +16 -0
  8. package/src/_window/instances.types.ts +18 -0
  9. package/src/_window/qa.types.ts +28 -0
  10. package/src/_window/routing.types.ts +21 -0
  11. package/src/_window/sdk.types.ts +147 -0
  12. package/src/_window/service.types.ts +67 -0
  13. package/src/_window/state.types.ts +112 -0
  14. package/src/_window/ui.types.ts +13 -0
  15. package/src/_window/utils.types.ts +34 -0
  16. package/src/_window/validation.types.ts +43 -0
  17. package/src/_window/window.ts +56 -0
  18. package/src/alert/enums.ts +22 -0
  19. package/src/alert/functions.types.ts +13 -0
  20. package/src/alert/index.ts +9 -0
  21. package/src/alert/service.types.ts +15 -0
  22. package/src/alert/state.initial.ts +16 -0
  23. package/src/alert/state.types.ts +27 -0
  24. package/src/alert/state.validations.ts +11 -0
  25. package/src/alert/types.ts +63 -0
  26. package/src/ats/api.types.ts +16 -0
  27. package/src/ats/functions.types.ts +7 -0
  28. package/src/ats/index.ts +9 -0
  29. package/src/ats/service.types.ts +17 -0
  30. package/src/ats/state.initial.ts +5 -0
  31. package/src/ats/state.types.ts +5 -0
  32. package/src/ats/state.validations.ts +6 -0
  33. package/src/ats/types.ts +19 -0
  34. package/src/basket/consts.ts +1 -0
  35. package/src/basket/functions.types.ts +40 -0
  36. package/src/basket/index.ts +12 -0
  37. package/src/basket/service.types.ts +32 -0
  38. package/src/basket/state.initial.ts +11 -0
  39. package/src/basket/state.types.ts +34 -0
  40. package/src/basket/state.validations.ts +12 -0
  41. package/src/basket/types.ts +4 -0
  42. package/src/basket/utils.ts +79 -0
  43. package/src/basket/utils.types.ts +10 -0
  44. package/src/basket/validations.types.ts +25 -0
  45. package/src/campaign/api.types.ts +45 -0
  46. package/src/campaign/consts.ts +1 -0
  47. package/src/campaign/enums.ts +17 -0
  48. package/src/campaign/functions.types.ts +90 -0
  49. package/src/campaign/index.ts +15 -0
  50. package/src/campaign/qa.types.ts +12 -0
  51. package/src/campaign/service.types.ts +48 -0
  52. package/src/campaign/state.initial.ts +84 -0
  53. package/src/campaign/state.types.ts +55 -0
  54. package/src/campaign/state.validations.ts +16 -0
  55. package/src/campaign/types.ts +237 -0
  56. package/src/campaign/utils.ts +53 -0
  57. package/src/campaign/utils.types.ts +59 -0
  58. package/src/campaign/validations.types.ts +215 -0
  59. package/src/common/LocalStorage.ts +123 -0
  60. package/src/common/browser.ts +2 -0
  61. package/src/common/color.ts +9 -0
  62. package/src/common/events/EventCommand/enums.ts +49 -0
  63. package/src/common/events/EventCommand/index.ts +4 -0
  64. package/src/common/events/EventCommand/types.ts +18 -0
  65. package/src/common/events/index.ts +4 -0
  66. package/src/common/events/types.ts +52 -0
  67. package/src/common/immutable.ts +28 -0
  68. package/src/common/index.ts +22 -0
  69. package/src/common/instances/Instance.ts +13 -0
  70. package/src/common/instances/consts.ts +1 -0
  71. package/src/common/instances/index.ts +4 -0
  72. package/src/common/json.ts +25 -0
  73. package/src/common/logger/Logger.ts +70 -0
  74. package/src/common/logger/enums.ts +12 -0
  75. package/src/common/logger/index.ts +5 -0
  76. package/src/common/logger/types.ts +7 -0
  77. package/src/common/logger-datadog/LoggerDatadog.ts +42 -0
  78. package/src/common/logger-datadog/index.ts +3 -0
  79. package/src/common/misc.ts +114 -0
  80. package/src/common/promise.ts +161 -0
  81. package/src/common/proxy.ts +77 -0
  82. package/src/common/qa.types.ts +9 -0
  83. package/src/common/regExTest.ts +12 -0
  84. package/src/common/tree.ts +148 -0
  85. package/src/common/types.ts +110 -0
  86. package/src/common/utm.ts +19 -0
  87. package/src/common/validations.types.ts +89 -0
  88. package/src/common/validators.ts +21 -0
  89. package/src/common/webComponents.ts +26 -0
  90. package/src/config/functions.types.ts +23 -0
  91. package/src/config/index.ts +5 -0
  92. package/src/config/state.initial.ts +11 -0
  93. package/src/config/state.types.ts +15 -0
  94. package/src/consts.ts +980 -0
  95. package/src/contract/api.types.ts +47 -0
  96. package/src/contract/consts.ts +1 -0
  97. package/src/contract/functions.types.ts +112 -0
  98. package/src/contract/index.ts +14 -0
  99. package/src/contract/qa.types.ts +12 -0
  100. package/src/contract/service.types.ts +54 -0
  101. package/src/contract/state.initial.ts +39 -0
  102. package/src/contract/state.types.ts +74 -0
  103. package/src/contract/state.validations.ts +21 -0
  104. package/src/contract/types.ts +145 -0
  105. package/src/contract/utils.ts +36 -0
  106. package/src/contract/utils.types.ts +11 -0
  107. package/src/contract/validations.types.ts +104 -0
  108. package/src/debugging/functions.types.ts +34 -0
  109. package/src/debugging/index.ts +6 -0
  110. package/src/debugging/state.initial.ts +10 -0
  111. package/src/debugging/state.types.ts +18 -0
  112. package/src/debugging/state.validations.ts +10 -0
  113. package/src/index.ts +22 -0
  114. package/src/language/consts.ts +6 -0
  115. package/src/language/en.ts +530 -0
  116. package/src/language/functions.types.ts +29 -0
  117. package/src/language/index.ts +11 -0
  118. package/src/language/qa.types.ts +19 -0
  119. package/src/language/state.initial.ts +13 -0
  120. package/src/language/state.types.ts +25 -0
  121. package/src/language/state.validations.ts +10 -0
  122. package/src/language/utils.ts +17 -0
  123. package/src/language/validations.types.ts +13 -0
  124. package/src/modal/consts.ts +6 -0
  125. package/src/modal/enums.ts +14 -0
  126. package/src/modal/functions.types.ts +22 -0
  127. package/src/modal/index.ts +11 -0
  128. package/src/modal/service.types.ts +32 -0
  129. package/src/modal/state.initial.ts +9 -0
  130. package/src/modal/state.types.ts +8 -0
  131. package/src/modal/state.validations.ts +6 -0
  132. package/src/modal/store.types.ts +5 -0
  133. package/src/modal/types.ts +44 -0
  134. package/src/orderJourney/consts.ts +289 -0
  135. package/src/orderJourney/enums.ts +25 -0
  136. package/src/orderJourney/functions.types.ts +140 -0
  137. package/src/orderJourney/index.ts +13 -0
  138. package/src/orderJourney/qa.types.ts +16 -0
  139. package/src/orderJourney/state.initial.ts +401 -0
  140. package/src/orderJourney/state.types.ts +99 -0
  141. package/src/orderJourney/state.validations.ts +78 -0
  142. package/src/orderJourney/types.ts +31 -0
  143. package/src/orderJourney/utils.ts +7 -0
  144. package/src/orderJourney/utils.types.ts +11 -0
  145. package/src/orderJourney/validations.types.ts +34 -0
  146. package/src/product/api.types.ts +62 -0
  147. package/src/product/consts.ts +1 -0
  148. package/src/product/enums.ts +11 -0
  149. package/src/product/functions.types.ts +156 -0
  150. package/src/product/index.ts +14 -0
  151. package/src/product/qa.types.ts +11 -0
  152. package/src/product/service.types.ts +68 -0
  153. package/src/product/state.initial.ts +28 -0
  154. package/src/product/state.types.ts +93 -0
  155. package/src/product/state.validations.ts +25 -0
  156. package/src/product/types.ts +161 -0
  157. package/src/product/utils.types.ts +22 -0
  158. package/src/product/validations.types.ts +189 -0
  159. package/src/routing/functions.types.ts +48 -0
  160. package/src/routing/index.ts +5 -0
  161. package/src/routing/state.initial.ts +10 -0
  162. package/src/routing/state.types.ts +30 -0
  163. package/src/theming/consts.ts +7727 -0
  164. package/src/theming/functions.types.ts +13 -0
  165. package/src/theming/index.ts +11 -0
  166. package/src/theming/qa.types.ts +11 -0
  167. package/src/theming/state.initial.ts +16 -0
  168. package/src/theming/state.types.ts +6 -0
  169. package/src/theming/state.validations.ts +8 -0
  170. package/src/theming/types.ts +123 -0
  171. package/src/theming/utils.ts +581 -0
  172. package/src/theming/validations.types.ts +62 -0
  173. package/src/types.ts +229 -0
  174. package/src/ui/index.ts +3 -0
  175. package/src/ui/service.types.ts +26 -0
  176. package/src/utils.ts +3 -0
  177. package/src/wallet/api.types.ts +33 -0
  178. package/src/wallet/consts.ts +3 -0
  179. package/src/wallet/functions.types.ts +58 -0
  180. package/src/wallet/index.ts +11 -0
  181. package/src/wallet/service.types.ts +26 -0
  182. package/src/wallet/state.initial.ts +18 -0
  183. package/src/wallet/state.types.ts +58 -0
  184. package/src/wallet/state.validations.ts +18 -0
  185. package/src/wallet/types.ts +65 -0
  186. package/src/wallet/validations.types.ts +18 -0
  187. package/tsconfig.json +41 -0
@@ -0,0 +1,112 @@
1
+ import { AlertStoreState } from "../alert/state.types"
2
+ import { BasketStoreState } from "../basket/state.types"
3
+ import { CampaignStoreState } from "../campaign/state.types"
4
+ import { ContractStoreState } from "../contract/state.types"
5
+ import { DebuggingStoreState } from "../debugging/state.types"
6
+ import { LanguageStoreState } from "../language/state.types"
7
+ import { ProductStoreState } from "../product/state.types"
8
+ import { ThemeStoreState } from "../theming/state.types"
9
+ import { OrderJourneyStoreState } from "../orderJourney/state.types"
10
+ import { WalletStoreState } from "../wallet/state.types"
11
+ import { ModalStoreState } from "../modal/state.types"
12
+ import { WindowHapiEventCommandCallbackHandler } from "../common/events/types"
13
+ import { WindowHapiModuleName } from "../../enums"
14
+ import { ATSStoreState } from "../ats/state.types"
15
+ import { ModuleWithConstructorArgs } from "../types"
16
+ import { WindowHapi } from "./window"
17
+ import { WindowHapiValidationsCommon } from "../common/validations.types"
18
+ import { WindowHapiValidationsBasket } from "../basket/validations.types"
19
+ import { WindowHapiValidationsCampaign } from "../campaign/validations.types"
20
+ import { WindowHapiValidationsContract } from "../contract/validations.types"
21
+ import { WindowHapiValidationsLanguage } from "../language/validations.types"
22
+ import { WindowHapiValidationsProduct } from "../product/validations.types"
23
+ import { WindowHapiValidationsTheming } from "../theming/validations.types"
24
+ import { WindowHapiValidationsOrderJourney } from "../orderJourney/validations.types"
25
+ import { WindowHapiValidationsWallet } from "../wallet/validations.types"
26
+ import { WindowHapiValidations } from "./validation.types"
27
+
28
+ export type WindowHapiState = ModuleWithConstructorArgs<
29
+ {
30
+ [WindowHapiModuleName.alert]: WindowHapiStateModule<AlertStoreState>
31
+ [WindowHapiModuleName.basket]: WindowHapiStateModule<BasketStoreState>
32
+ [WindowHapiModuleName.campaign]: WindowHapiStateModule<CampaignStoreState>
33
+ [WindowHapiModuleName.contract]: WindowHapiStateModule<ContractStoreState>
34
+ [WindowHapiModuleName.debugging]: WindowHapiStateModule<DebuggingStoreState>
35
+ [WindowHapiModuleName.language]: WindowHapiStateModule<LanguageStoreState>
36
+ [WindowHapiModuleName.product]: WindowHapiStateModule<ProductStoreState>
37
+ [WindowHapiModuleName.theming]: WindowHapiStateModule<ThemeStoreState>
38
+ [WindowHapiModuleName.orderJourney]: WindowHapiStateModule<OrderJourneyStoreState>
39
+ [WindowHapiModuleName.wallet]: WindowHapiStateModule<WalletStoreState>
40
+ [WindowHapiModuleName.modal]: WindowHapiStateModule<ModalStoreState>
41
+ [WindowHapiModuleName.ats]: WindowHapiStateModule<ATSStoreState>
42
+ getModuleByName: (
43
+ name: string,
44
+ ) => WindowHapiStateModule<any> | undefined
45
+ handleDefaultStateFromQueryParams: (params: string | string[]) => void
46
+ shouldPreventStateDispatch: boolean
47
+ stores: {
48
+ alert: WindowHapiStateModule<AlertStoreState>
49
+ basket: WindowHapiStateModule<BasketStoreState>
50
+ campaign: WindowHapiStateModule<CampaignStoreState>
51
+ contract: WindowHapiStateModule<ContractStoreState>
52
+ debugging: WindowHapiStateModule<DebuggingStoreState>
53
+ language: WindowHapiStateModule<LanguageStoreState>
54
+ product: WindowHapiStateModule<ProductStoreState>
55
+ theming: WindowHapiStateModule<ThemeStoreState>
56
+ orderJourney: WindowHapiStateModule<OrderJourneyStoreState>
57
+ wallet: WindowHapiStateModule<WalletStoreState>
58
+ modal: WindowHapiStateModule<ModalStoreState>
59
+ ats: WindowHapiStateModule<ATSStoreState>
60
+ }
61
+ toJSON: Record<string, any>
62
+ },
63
+ { readonly core: WindowHapi }
64
+ >
65
+
66
+ export type WindowHapiStatesJSON = {
67
+ [WindowHapiModuleName.alert]: AlertStoreState
68
+ [WindowHapiModuleName.basket]: BasketStoreState
69
+ [WindowHapiModuleName.campaign]: CampaignStoreState
70
+ [WindowHapiModuleName.contract]: ContractStoreState
71
+ [WindowHapiModuleName.debugging]: DebuggingStoreState
72
+ [WindowHapiModuleName.language]: LanguageStoreState
73
+ [WindowHapiModuleName.product]: ProductStoreState
74
+ [WindowHapiModuleName.theming]: ThemeStoreState
75
+ [WindowHapiModuleName.orderJourney]: OrderJourneyStoreState
76
+ [WindowHapiModuleName.wallet]: WalletStoreState
77
+ [WindowHapiModuleName.modal]: ModalStoreState
78
+ [WindowHapiModuleName.ats]: ATSStoreState
79
+ }
80
+
81
+ export type WindowHapiStateBase = {
82
+ __stateName: string
83
+ toJSON: any
84
+ }
85
+
86
+ export type HapiStateValueWithListener<T> = {
87
+ on: (callback: WindowHapiEventCommandCallbackHandler) => void
88
+ value: T
89
+ }
90
+
91
+ export type WindowHapiStateModule<T> = WindowHapiStateBase & {
92
+ [P in keyof T]:
93
+ | T[P]
94
+ | HapiStateValueWithListener<T[P]>
95
+ | ((v: T[P]) => void)
96
+ }
97
+
98
+ export type StateValidationKey =
99
+ | keyof WindowHapiValidations
100
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsCommon}`
101
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsBasket}`
102
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsCampaign}`
103
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsContract}`
104
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsLanguage}`
105
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsProduct}`
106
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsTheming}`
107
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsOrderJourney}`
108
+ | `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsWallet}`
109
+
110
+ export type StateValidations<State> = {
111
+ [P in keyof State]: StateValidationKey | undefined
112
+ }
@@ -0,0 +1,13 @@
1
+ import { ModuleWithConstructorArgs } from "../types"
2
+ import { WindowHapi } from "./window"
3
+
4
+ export type WindowHapiUI = ModuleWithConstructorArgs<
5
+ {
6
+ addUIElementToBody: (
7
+ elementName: "he-ui-modals" | "he-ui-alertbar",
8
+ ) => void
9
+ toggleModal: () => void
10
+ toggleAlertbar: () => void
11
+ },
12
+ { readonly core: WindowHapi }
13
+ >
@@ -0,0 +1,34 @@
1
+ import { WindowHapiModuleName } from "../../enums"
2
+ import { ModuleWithConstructorArgs } from "../types"
3
+ import { WindowHapiUtilsProduct } from "../product/utils.types"
4
+ import { WindowHapiUtilsContract } from "../contract/utils.types"
5
+ import { WindowHapiUtilsCampaign } from "../campaign/utils.types"
6
+ import { WindowHapiUtilsBasket } from "../basket/utils.types"
7
+ import { WindowHapiUtilsOrderJourney } from "../orderJourney/utils.types"
8
+ import { WindowHapi } from "./window"
9
+
10
+ export type WindowHapiUtils = ModuleWithConstructorArgs<
11
+ {
12
+ isObject: (item: any) => boolean
13
+ mergeDeepOverwriteArrays: (
14
+ original: Record<string, any>,
15
+ overwrites: Record<string, any>,
16
+ ) => Record<string, any>
17
+ getComponentNameIndexSuffix: (instanceName: string) => string
18
+ getIframeLoadingSpinner: () => HTMLDivElement
19
+ product: WindowHapiUtilsProduct
20
+ contract: WindowHapiUtilsContract
21
+ campaign: WindowHapiUtilsCampaign
22
+ basket: WindowHapiUtilsBasket
23
+ orderJourney: WindowHapiUtilsOrderJourney
24
+
25
+ utilities: {
26
+ [WindowHapiModuleName.basket]: WindowHapiUtilsBasket
27
+ [WindowHapiModuleName.campaign]: WindowHapiUtilsCampaign
28
+ [WindowHapiModuleName.contract]: WindowHapiUtilsContract
29
+ [WindowHapiModuleName.product]: WindowHapiUtilsProduct
30
+ [WindowHapiModuleName.orderJourney]: WindowHapiUtilsOrderJourney
31
+ }
32
+ },
33
+ { readonly core: WindowHapi }
34
+ >
@@ -0,0 +1,43 @@
1
+ import { z } from "zod"
2
+ import { WindowHapiModuleName } from "../../enums"
3
+ import { ModuleWithConstructorArgs } from "../types"
4
+ import { WindowHapi } from "./window"
5
+ import { WindowHapiValidationsCommon } from "../common/validations.types"
6
+ import { WindowHapiValidationsProduct } from "../product/validations.types"
7
+ import { WindowHapiValidationsContract } from "../contract/validations.types"
8
+ import { WindowHapiValidationsCampaign } from "../campaign/validations.types"
9
+ import { WindowHapiValidationsBasket } from "../basket/validations.types"
10
+ import { WindowHapiValidationsWallet } from "../wallet/validations.types"
11
+ import { WindowHapiValidationsTheming } from "../theming/validations.types"
12
+ import { WindowHapiValidationsLanguage } from "../language/validations.types"
13
+ import { WindowHapiValidationsOrderJourney } from "../orderJourney/validations.types"
14
+
15
+ export type WindowHapiValidations = ModuleWithConstructorArgs<
16
+ {
17
+ validator: typeof z
18
+ messages: Record<string, string | Function>
19
+ [WindowHapiModuleName.common]: WindowHapiValidationsCommon
20
+ [WindowHapiModuleName.product]: WindowHapiValidationsProduct
21
+ [WindowHapiModuleName.contract]: WindowHapiValidationsContract
22
+ [WindowHapiModuleName.campaign]: WindowHapiValidationsCampaign
23
+ [WindowHapiModuleName.basket]: WindowHapiValidationsBasket
24
+ [WindowHapiModuleName.wallet]: WindowHapiValidationsWallet
25
+ [WindowHapiModuleName.theming]: WindowHapiValidationsTheming
26
+ [WindowHapiModuleName.language]: WindowHapiValidationsLanguage
27
+ [WindowHapiModuleName.orderJourney]: WindowHapiValidationsOrderJourney
28
+ throwError: (error: string | undefined) => void
29
+ throwHasNoSetterError: (propertyName: string) => void
30
+ checkAndThrowArgumentUndefinedOrInvalidTypeError: (
31
+ parameter: any,
32
+ parameterName: string,
33
+ typeString: string,
34
+ invalidator?: Function,
35
+ ) => void
36
+ runSDKEventsValidations: (callback: Function) => void
37
+ },
38
+ { readonly core: WindowHapi }
39
+ >
40
+
41
+ export type ValidationSubmoduleConstructorArgs = {
42
+ readonly validation: WindowHapiValidations
43
+ }
@@ -0,0 +1,56 @@
1
+ import { Logger } from "../common/logger/Logger"
2
+ import { WindowHapiUtils } from "./utils.types"
3
+ import { WindowHapiValidations } from "./validation.types"
4
+ import { WindowHapiState } from "./state.types"
5
+ import { WindowHapiInstances } from "./instances.types"
6
+ import { WindowHapiRouting } from "./routing.types"
7
+ import { WindowHapiAuth } from "./auth.types"
8
+ import { WindowHapiEvents } from "./events.types"
9
+ import { WindowHapiUI } from "./ui.types"
10
+ import { WindowHapiAPI } from "./api.types"
11
+ import { WindowHapiSDK } from "./sdk.types"
12
+ import { WindowHapiService } from "./service.types"
13
+ import HapiInstance from "../common/instances/Instance"
14
+ import { WindowHapiQA } from "./qa.types"
15
+ import { ModuleWithConstructorArgs } from "../types"
16
+
17
+ export type WindowHapi = {
18
+ logger: Logger
19
+ utils: ModuleWithConstructorArgs<
20
+ WindowHapiUtils,
21
+ { readonly core: WindowHapi }
22
+ >
23
+ validation: ModuleWithConstructorArgs<
24
+ WindowHapiValidations,
25
+ { readonly core: WindowHapi }
26
+ >
27
+ state: ModuleWithConstructorArgs<
28
+ WindowHapiState,
29
+ { readonly core: WindowHapi }
30
+ >
31
+ instances: ModuleWithConstructorArgs<
32
+ WindowHapiInstances,
33
+ { readonly core: WindowHapi }
34
+ >
35
+ routing: ModuleWithConstructorArgs<
36
+ WindowHapiRouting,
37
+ { readonly core: WindowHapi }
38
+ >
39
+ auth: ModuleWithConstructorArgs<
40
+ WindowHapiAuth,
41
+ { readonly core: WindowHapi }
42
+ >
43
+ events: ModuleWithConstructorArgs<
44
+ WindowHapiEvents,
45
+ { readonly core: WindowHapi }
46
+ >
47
+ ui: ModuleWithConstructorArgs<WindowHapiUI, { readonly core: WindowHapi }>
48
+ api: ModuleWithConstructorArgs<WindowHapiAPI, { readonly core: WindowHapi }>
49
+ sdk: ModuleWithConstructorArgs<WindowHapiSDK, { readonly core: WindowHapi }>
50
+ service: ModuleWithConstructorArgs<
51
+ WindowHapiService,
52
+ { readonly core: WindowHapi }
53
+ >
54
+ instance: HapiInstance
55
+ qa: ModuleWithConstructorArgs<WindowHapiQA, { readonly core: WindowHapi }>
56
+ }
@@ -0,0 +1,22 @@
1
+ export enum AlertKey {
2
+ backendErrorMessage = "backend-error-message",
3
+ topupSuccess = "topup-success",
4
+ contractRemoveSuccess = "contract-removed",
5
+ contractCreateSuccess = "contract-created",
6
+ contractGroupCreateSuccess = "contract-group-created",
7
+ campaignTakeOfflineSuccess = "campaign-take-offline-success",
8
+ campaignOrderSuccess = "campaign-order-success",
9
+ campaignCopySuccess = "campaign-copy-success",
10
+ buttonCopySuccess = "copy-button-success",
11
+ productAddToBasket = "add-product-to-basket-success",
12
+ productRemoveFromBasket = "remove-product-from-basket-warning",
13
+ utmCodeConfirmation = "utm-code-confirmation",
14
+ }
15
+
16
+ export enum AlertType {
17
+ "success" = "success",
18
+ "info" = "info",
19
+ "warning" = "warning",
20
+ "error" = "error",
21
+ "custom" = "custom",
22
+ }
@@ -0,0 +1,13 @@
1
+ import { AlertKey } from "./enums"
2
+ import { Alert, AlertOptions, AlertProps } from "./types"
3
+
4
+ export type AlertStoreShowHandler = (
5
+ key: AlertKey,
6
+ props: AlertProps | undefined,
7
+ options: AlertOptions,
8
+ ) => void
9
+ export type AlertStoreSetAlertsHandler = (alerts: Alert[]) => void
10
+ export type AlertStoreFunctions = {
11
+ showAlert: AlertStoreShowHandler
12
+ setAlerts: AlertStoreSetAlertsHandler
13
+ }
@@ -0,0 +1,9 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from './enums';
4
+ export * from './functions.types';
5
+ export * from './service.types';
6
+ export * from './state.initial';
7
+ export * from './state.types';
8
+ export * from './state.validations';
9
+ export * from './types';
@@ -0,0 +1,15 @@
1
+ import { AlertKey } from "./enums"
2
+ import { AlertOptions } from "./types"
3
+ import { ModuleWithConstructorArgs } from "../types"
4
+ import { WindowHapiService } from "../_window/service.types"
5
+
6
+ export type WindowHapiServiceAlert = ModuleWithConstructorArgs<
7
+ {
8
+ show: (
9
+ key: AlertKey,
10
+ props: any | undefined,
11
+ options: AlertOptions,
12
+ ) => void
13
+ },
14
+ { readonly service: WindowHapiService }
15
+ >
@@ -0,0 +1,16 @@
1
+ import { AlertStoreState } from "./state.types"
2
+ import { AlertType } from "./enums"
3
+
4
+ export const initialAlertStoreState: AlertStoreState = {
5
+ alerts: [],
6
+ errorOptions: null,
7
+ infoOptions: null,
8
+ warningOptions: null,
9
+ successOptions: null,
10
+ defaultOptions: {
11
+ shouldShowDismiss: true,
12
+ position: "top-center",
13
+ autoClose: 5000,
14
+ type: AlertType.info,
15
+ },
16
+ }
@@ -0,0 +1,27 @@
1
+ import { Alert, AlertOptions } from "./types"
2
+ export type AlertStoreState = {
3
+ /**
4
+ * List of alert objects to be shown
5
+ */
6
+ alerts: Alert[]
7
+ /**
8
+ * Default options object for Toast (Snack) notifications. Contains options like duration, show/hide close button, position.
9
+ */
10
+ defaultOptions: AlertOptions
11
+ /**
12
+ * Extends default options and sets the type to "success". **This value is a computed getter meaning that it cannot be set from outside**
13
+ */
14
+ successOptions: AlertOptions | null
15
+ /**
16
+ * Extends default options and sets the type to "info". **This value is a computed getter meaning that it cannot be set from outside**
17
+ */
18
+ infoOptions: AlertOptions | null
19
+ /**
20
+ * Extends default options and sets the type to "warning". **This value is a computed getter meaning that it cannot be set from outside**
21
+ */
22
+ warningOptions: AlertOptions | null
23
+ /**
24
+ * Extends default options and sets the type to "error". **This value is a computed getter meaning that it cannot be set from outside**
25
+ */
26
+ errorOptions: AlertOptions | null
27
+ }
@@ -0,0 +1,11 @@
1
+ import { AlertStoreState } from "./state.types"
2
+ import { StateValidations } from "../_window/state.types"
3
+
4
+ export const alertStoreStateValidations: StateValidations<AlertStoreState> = {
5
+ alerts: undefined,
6
+ errorOptions: "throwHasNoSetterError",
7
+ infoOptions: "throwHasNoSetterError",
8
+ warningOptions: "throwHasNoSetterError",
9
+ successOptions: "throwHasNoSetterError",
10
+ defaultOptions: undefined,
11
+ }
@@ -0,0 +1,63 @@
1
+ import { ToastOptions } from "react-toastify/dist/types"
2
+ import { AlertKey } from "./enums"
3
+ import { AnyNonFunction } from "../common/types"
4
+
5
+ export type AlertOptions = ToastOptions & {
6
+ shouldShowDismiss?: boolean
7
+ }
8
+
9
+ export type ContractCreateSuccessAlertProps = {
10
+ contractName: string
11
+ }
12
+
13
+ export type ContractRemoveSuccessAlertProps = {
14
+ contractName: string
15
+ }
16
+
17
+ export type ContractGroupCreateSuccessAlertProps = {
18
+ groupName: string
19
+ }
20
+
21
+ export type BackendErrorMessageAlertProps = {
22
+ errorMessage: string
23
+ }
24
+
25
+ export type WalletTopUpSuccessAlertProps = {
26
+ amountInDollars: number
27
+ }
28
+
29
+ export type UTMCodesSuccessAlertProps = {
30
+ type: "save" | "reset"
31
+ }
32
+
33
+ export type ButtonCopySuccessAlertProps = {}
34
+
35
+ export type CampaignOrderSuccessAlertProps = {}
36
+
37
+ export type CampaignCopySuccessAlertProps = {}
38
+
39
+ export type CampaignTakeOfflineSuccessAlertProps = {}
40
+
41
+ export type ProductAddToBasketSuccessAlertProps = {}
42
+
43
+ export type ProductRemoveFromBasketWarningAlertProps = {}
44
+
45
+ export type AlertProps = AnyNonFunction<
46
+ | ContractCreateSuccessAlertProps
47
+ | ContractRemoveSuccessAlertProps
48
+ | ContractGroupCreateSuccessAlertProps
49
+ | BackendErrorMessageAlertProps
50
+ | WalletTopUpSuccessAlertProps
51
+ | ButtonCopySuccessAlertProps
52
+ | CampaignOrderSuccessAlertProps
53
+ | CampaignCopySuccessAlertProps
54
+ | CampaignTakeOfflineSuccessAlertProps
55
+ | ProductAddToBasketSuccessAlertProps
56
+ | ProductRemoveFromBasketWarningAlertProps
57
+ >
58
+
59
+ export type Alert = {
60
+ key: AlertKey
61
+ props: AlertProps | undefined
62
+ options: AlertOptions
63
+ }
@@ -0,0 +1,16 @@
1
+ import { AxiosRequestConfig } from "axios/index"
2
+ import { ATSSettings } from "./types"
3
+ import { WindowHapiAPI, WindowHapiAPIModule } from "../_window/api.types"
4
+ import { ModuleWithConstructorArgs } from "../types"
5
+
6
+ export type WindowHapiAPIATSConfigs = {
7
+ getUserSettings: AxiosRequestConfig<any>
8
+ }
9
+
10
+ export type WindowHapiAPIATSRequests = {
11
+ getUserSettings: () => Promise<ATSSettings>
12
+ }
13
+ export type WindowHapiAPIATS = ModuleWithConstructorArgs<
14
+ WindowHapiAPIModule<WindowHapiAPIATSRequests, WindowHapiAPIATSConfigs>,
15
+ { readonly api: WindowHapiAPI }
16
+ >
@@ -0,0 +1,7 @@
1
+ import { ATSSettings } from "./types"
2
+
3
+ export type ATSStoreSetUserSettingsHandler = (settings: ATSSettings) => void
4
+
5
+ export type ATSStoreFunctions = {
6
+ setUserSettings: ATSStoreSetUserSettingsHandler
7
+ }
@@ -0,0 +1,9 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from './api.types';
4
+ export * from './functions.types';
5
+ export * from './service.types';
6
+ export * from './state.initial';
7
+ export * from './state.types';
8
+ export * from './state.validations';
9
+ export * from './types';
@@ -0,0 +1,17 @@
1
+ import {
2
+ HapiServiceFunctionWithLifecycleHooks,
3
+ WindowHapiService,
4
+ } from "../_window/service.types"
5
+ import { ATSSettings } from "./types"
6
+ import { ModuleWithConstructorArgs } from "../types"
7
+
8
+ export type ATSServiceGetUserSettingsHandler = () => Promise<
9
+ ATSSettings | undefined
10
+ >
11
+
12
+ export type WindowHapiServiceATS = ModuleWithConstructorArgs<
13
+ {
14
+ getUserSettings: HapiServiceFunctionWithLifecycleHooks<ATSServiceGetUserSettingsHandler>
15
+ },
16
+ { readonly service: WindowHapiService }
17
+ >
@@ -0,0 +1,5 @@
1
+ import { ATSStoreState } from "./state.types"
2
+
3
+ export const initialATSStoreState: ATSStoreState = {
4
+ userSettings: null,
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ATSSettings } from "./types"
2
+
3
+ export type ATSStoreState = {
4
+ userSettings: ATSSettings | null
5
+ }
@@ -0,0 +1,6 @@
1
+ import { ATSStoreState } from "./state.types"
2
+ import { StateValidations } from "../_window/state.types"
3
+
4
+ export const atsStoreStateValidations: StateValidations<ATSStoreState> = {
5
+ userSettings: "common.genericObject",
6
+ }
@@ -0,0 +1,19 @@
1
+ import { WalletPaymentIntentPaymentMethod } from "../wallet/types"
2
+
3
+ export type ATSUserPaymentSetting = {
4
+ currency: string
5
+ max_outstanding_balance: string
6
+ max_purchase_order: string
7
+ min_topup: string
8
+ payment_method_types: WalletPaymentIntentPaymentMethod[] | null
9
+ }
10
+ export type ATSUserSettings = {
11
+ ats_managed_payment: boolean
12
+ can_pay_with_purchase_order: boolean
13
+ can_use_wallets: boolean
14
+ invoice_currency: string
15
+ }
16
+ export type ATSSettings = {
17
+ payment_settings: ATSUserPaymentSetting[]
18
+ settings: ATSUserSettings
19
+ }
@@ -0,0 +1 @@
1
+ export const CAMPAIGN_BASKET_PRODUCTS_LOCALSTORAGE_KEY = "basketProducts"
@@ -0,0 +1,40 @@
1
+ import { BasketProduct } from "./types"
2
+ import { Product } from "../product/types"
3
+ import { Contract } from "../contract/types"
4
+
5
+ export type BasketStoreClearHandler = () => void
6
+ export type BasketStoreAddProductOrContractByIdHandler = (
7
+ contractOrProductId: string,
8
+ isProduct: boolean,
9
+ ) => void
10
+ export type BasketStoreRemoveProductOrContractByIdHandler = (
11
+ contractOrProductId: string,
12
+ ) => void
13
+ export type BasketStoreSetProductsMetaHandler = (
14
+ productOrContractIds: BasketProduct[],
15
+ ) => void
16
+ export type BasketStoreSetProductsAreLoadingHandler = (
17
+ isLoading: boolean,
18
+ ) => void
19
+ export type BasketStoreSetProductsHandler = (
20
+ data: (Product | Contract)[],
21
+ ) => void
22
+
23
+ export type BasketStoreFunctions = {
24
+ /**
25
+ * Removes all products and contracts from Basket
26
+ */
27
+ clear: BasketStoreClearHandler
28
+ /**
29
+ * Sets the array of Products and/or Contracts to be displayed in the Basket
30
+ */
31
+ setProducts: BasketStoreSetProductsHandler
32
+ /**
33
+ * Shows a loading spinner in the Basket when `products` are loading
34
+ */
35
+ setProductsAreLoading: BasketStoreSetProductsAreLoadingHandler
36
+ /**
37
+ * Sets array of objects with `id: string | number` for and `isProduct: boolean` so that the up-to-date data can be loaded from the API and set to `products`
38
+ */
39
+ setProductsMeta: BasketStoreSetProductsMetaHandler
40
+ }
@@ -0,0 +1,12 @@
1
+ // created from 'create-ts-index'
2
+
3
+ export * from './consts';
4
+ export * from './functions.types';
5
+ export * from './service.types';
6
+ export * from './state.initial';
7
+ export * from './state.types';
8
+ export * from './state.validations';
9
+ export * from './types';
10
+ export * from './utils';
11
+ export * from './utils.types';
12
+ export * from './validations.types';
@@ -0,0 +1,32 @@
1
+ import { Contract } from "../contract/types"
2
+ import { Product } from "../product/types"
3
+ import { BasketProduct } from "./types"
4
+ import {
5
+ HapiServiceFunctionWithLifecycleHooks,
6
+ WindowHapiService,
7
+ } from "../_window/service.types"
8
+ import { ModuleWithConstructorArgs } from "../types"
9
+
10
+ export type BasketServiceGetProductsHandler = () => Promise<
11
+ (Product | Contract)[]
12
+ >
13
+ export type BasketServiceAddProductOrContractByIdHandler = (
14
+ contractOrProductId: string,
15
+ isProduct: boolean,
16
+ ) => void
17
+ export type BasketServiceRemoveProductOrContractByIdHandler = (
18
+ contractOrProductId: string,
19
+ ) => void
20
+
21
+ export type WindowHapiServiceBasket = ModuleWithConstructorArgs<
22
+ {
23
+ setBasketProductsAndMetaByItemData: (
24
+ basketItemData: (Contract | Product)[],
25
+ ) => BasketProduct[]
26
+ getProducts: HapiServiceFunctionWithLifecycleHooks<BasketServiceGetProductsHandler>
27
+ addProductOrContractById: HapiServiceFunctionWithLifecycleHooks<BasketServiceAddProductOrContractByIdHandler>
28
+ removeProductOrContractById: HapiServiceFunctionWithLifecycleHooks<BasketServiceRemoveProductOrContractByIdHandler>
29
+ clear: () => BasketProduct[]
30
+ },
31
+ { readonly service: WindowHapiService }
32
+ >
@@ -0,0 +1,11 @@
1
+ import { BasketStoreState } from "./state.types"
2
+
3
+ export const initialBasketStoreState: BasketStoreState = {
4
+ totalInUSD: 0,
5
+ totalInEUR: 0,
6
+ totalInGBP: 0,
7
+ totalInDisplayCurrency: 0,
8
+ productsMeta: [],
9
+ products: [],
10
+ productsAreLoading: false,
11
+ }