@vonq/hapi-elements-types 1.4.0 → 1.6.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.
- package/package.json +17 -8
- package/src/_window/api.types.ts +61 -0
- package/src/_window/auth.types.ts +13 -0
- package/src/_window/config.types.ts +5 -0
- package/src/_window/events.types.ts +158 -0
- package/src/_window/index.ts +16 -0
- package/src/_window/instances.types.ts +27 -0
- package/src/_window/qa.types.ts +30 -0
- package/src/_window/routing.types.ts +23 -0
- package/src/_window/sdk.types.ts +149 -0
- package/src/_window/service.types.ts +69 -0
- package/src/_window/state.types.ts +114 -0
- package/src/_window/ui.types.ts +15 -0
- package/src/_window/utils.types.ts +36 -0
- package/src/_window/validation.types.ts +45 -0
- package/src/_window/window.ts +140 -0
- package/src/alert/enums.ts +22 -0
- package/src/alert/index.ts +6 -0
- package/src/alert/service.types.ts +15 -0
- package/src/alert/state.types.ts +9 -0
- package/src/alert/types.ts +63 -0
- package/src/ats/api.types.ts +16 -0
- package/src/ats/index.ts +6 -0
- package/src/ats/service.types.ts +17 -0
- package/src/ats/state.types.ts +5 -0
- package/src/ats/types.ts +19 -0
- package/src/basket/index.ts +7 -0
- package/src/basket/service.types.ts +32 -0
- package/src/basket/state.types.ts +34 -0
- package/src/basket/types.ts +4 -0
- package/src/basket/utils.types.ts +10 -0
- package/src/basket/validations.types.ts +25 -0
- package/src/campaign/api.types.ts +45 -0
- package/src/campaign/enums.ts +17 -0
- package/src/campaign/index.ts +10 -0
- package/src/campaign/qa.types.ts +12 -0
- package/src/campaign/service.types.ts +48 -0
- package/src/campaign/state.types.ts +55 -0
- package/src/campaign/types.ts +237 -0
- package/src/campaign/utils.types.ts +59 -0
- package/src/campaign/validations.types.ts +215 -0
- package/src/common/enums.ts +42 -0
- package/src/common/events/EventCommand/enums.ts +49 -0
- package/src/common/events/EventCommand/index.ts +4 -0
- package/src/common/events/EventCommand/types.ts +18 -0
- package/src/common/events/index.ts +4 -0
- package/src/common/events/types.ts +52 -0
- package/src/common/index.ts +7 -0
- package/src/common/logger/enums.ts +12 -0
- package/src/common/logger/types.ts +18 -0
- package/src/common/qa.types.ts +9 -0
- package/src/common/types.ts +109 -0
- package/src/common/validations.types.ts +89 -0
- package/src/common/validator/types.ts +4 -0
- package/src/contract/api.types.ts +47 -0
- package/src/contract/index.ts +9 -0
- package/src/contract/qa.types.ts +12 -0
- package/src/contract/service.types.ts +54 -0
- package/src/contract/state.types.ts +74 -0
- package/src/contract/types.ts +145 -0
- package/src/contract/utils.types.ts +11 -0
- package/src/contract/validations.types.ts +104 -0
- package/src/debugging/index.ts +3 -0
- package/src/debugging/state.types.ts +18 -0
- package/src/index.ts +18 -0
- package/src/language/index.ts +5 -0
- package/src/language/qa.types.ts +19 -0
- package/src/language/state.types.ts +25 -0
- package/src/language/validations.types.ts +13 -0
- package/src/modal/enums.ts +14 -0
- package/src/modal/index.ts +6 -0
- package/src/modal/service.types.ts +32 -0
- package/src/modal/state.types.ts +8 -0
- package/src/modal/types.ts +44 -0
- package/src/orderJourney/enums.ts +25 -0
- package/src/orderJourney/index.ts +8 -0
- package/src/orderJourney/qa.types.ts +16 -0
- package/src/orderJourney/state.types.ts +99 -0
- package/src/orderJourney/types.ts +31 -0
- package/src/orderJourney/utils.types.ts +11 -0
- package/src/orderJourney/validations.types.ts +34 -0
- package/src/product/api.types.ts +62 -0
- package/src/product/enums.ts +11 -0
- package/src/product/index.ts +10 -0
- package/src/product/qa.types.ts +11 -0
- package/src/product/service.types.ts +68 -0
- package/src/product/state.types.ts +93 -0
- package/src/product/types.ts +161 -0
- package/src/product/utils.types.ts +22 -0
- package/src/product/validations.types.ts +189 -0
- package/src/routing/index.ts +3 -0
- package/src/routing/state.types.ts +30 -0
- package/src/theming/index.ts +6 -0
- package/src/theming/qa.types.ts +11 -0
- package/src/theming/state.types.ts +6 -0
- package/src/theming/types.ts +123 -0
- package/src/theming/validations.types.ts +62 -0
- package/src/ui/index.ts +3 -0
- package/src/ui/service.types.ts +26 -0
- package/src/wallet/api.types.ts +33 -0
- package/src/wallet/index.ts +7 -0
- package/src/wallet/service.types.ts +26 -0
- package/src/wallet/state.types.ts +58 -0
- package/src/wallet/types.ts +65 -0
- package/src/wallet/validations.types.ts +18 -0
- package/tsconfig.json +36 -0
- package/index.d.ts +0 -5207
@@ -0,0 +1,114 @@
|
|
1
|
+
import { AlertState } from "../alert/state.types"
|
2
|
+
import { BasketState } from "../basket/state.types"
|
3
|
+
import { CampaignState } from "../campaign/state.types"
|
4
|
+
import { ContractState } from "../contract/state.types"
|
5
|
+
import { DebuggingState } from "../debugging/state.types"
|
6
|
+
import { LanguageState } from "../language/state.types"
|
7
|
+
import { ProductState } from "../product/state.types"
|
8
|
+
import { ThemingState } from "../theming/state.types"
|
9
|
+
import { OrderJourneyState } from "../orderJourney/state.types"
|
10
|
+
import { WalletState } from "../wallet/state.types"
|
11
|
+
import { ModalState } from "../modal/state.types"
|
12
|
+
import { WindowHapiEventCommandCallbackHandler } from "../common/events/types"
|
13
|
+
import { WindowHapiModuleName } from "../common/enums"
|
14
|
+
import { ATSState } from "../ats/state.types"
|
15
|
+
import {
|
16
|
+
WindowHapiModuleWithConstructorArgs,
|
17
|
+
WindowHapiClassInterface,
|
18
|
+
} from "./window"
|
19
|
+
import { WindowHapiValidationsCommon } from "../common/validations.types"
|
20
|
+
import { WindowHapiValidationsBasket } from "../basket/validations.types"
|
21
|
+
import { WindowHapiValidationsCampaign } from "../campaign/validations.types"
|
22
|
+
import { WindowHapiValidationsContract } from "../contract/validations.types"
|
23
|
+
import { WindowHapiValidationsLanguage } from "../language/validations.types"
|
24
|
+
import { WindowHapiValidationsProduct } from "../product/validations.types"
|
25
|
+
import { WindowHapiValidationsTheming } from "../theming/validations.types"
|
26
|
+
import { WindowHapiValidationsOrderJourney } from "../orderJourney/validations.types"
|
27
|
+
import { WindowHapiValidationsWallet } from "../wallet/validations.types"
|
28
|
+
import { WindowHapiValidations } from "./validation.types"
|
29
|
+
|
30
|
+
export type WindowHapiState = WindowHapiModuleWithConstructorArgs<
|
31
|
+
{
|
32
|
+
[WindowHapiModuleName.alert]: WindowHapiStateModule<AlertState>
|
33
|
+
[WindowHapiModuleName.basket]: WindowHapiStateModule<BasketState>
|
34
|
+
[WindowHapiModuleName.campaign]: WindowHapiStateModule<CampaignState>
|
35
|
+
[WindowHapiModuleName.contract]: WindowHapiStateModule<ContractState>
|
36
|
+
[WindowHapiModuleName.debugging]: WindowHapiStateModule<DebuggingState>
|
37
|
+
[WindowHapiModuleName.language]: WindowHapiStateModule<LanguageState>
|
38
|
+
[WindowHapiModuleName.product]: WindowHapiStateModule<ProductState>
|
39
|
+
[WindowHapiModuleName.theming]: WindowHapiStateModule<ThemingState>
|
40
|
+
[WindowHapiModuleName.orderJourney]: WindowHapiStateModule<OrderJourneyState>
|
41
|
+
[WindowHapiModuleName.wallet]: WindowHapiStateModule<WalletState>
|
42
|
+
[WindowHapiModuleName.modal]: WindowHapiStateModule<ModalState>
|
43
|
+
[WindowHapiModuleName.ats]: WindowHapiStateModule<ATSState>
|
44
|
+
getModuleByName: (
|
45
|
+
name: string,
|
46
|
+
) => WindowHapiStateModule<any> | undefined
|
47
|
+
handleDefaultStateFromQueryParams: (params: string | string[]) => void
|
48
|
+
shouldPreventStateDispatch: boolean
|
49
|
+
stores: {
|
50
|
+
alert: WindowHapiStateModule<AlertState>
|
51
|
+
basket: WindowHapiStateModule<BasketState>
|
52
|
+
campaign: WindowHapiStateModule<CampaignState>
|
53
|
+
contract: WindowHapiStateModule<ContractState>
|
54
|
+
debugging: WindowHapiStateModule<DebuggingState>
|
55
|
+
language: WindowHapiStateModule<LanguageState>
|
56
|
+
product: WindowHapiStateModule<ProductState>
|
57
|
+
theming: WindowHapiStateModule<ThemingState>
|
58
|
+
orderJourney: WindowHapiStateModule<OrderJourneyState>
|
59
|
+
wallet: WindowHapiStateModule<WalletState>
|
60
|
+
modal: WindowHapiStateModule<ModalState>
|
61
|
+
ats: WindowHapiStateModule<ATSState>
|
62
|
+
}
|
63
|
+
toJSON: Record<string, any>
|
64
|
+
},
|
65
|
+
{ readonly core: WindowHapiClassInterface }
|
66
|
+
>
|
67
|
+
|
68
|
+
export type WindowHapiStatesJSON = {
|
69
|
+
[WindowHapiModuleName.alert]: AlertState
|
70
|
+
[WindowHapiModuleName.basket]: BasketState
|
71
|
+
[WindowHapiModuleName.campaign]: CampaignState
|
72
|
+
[WindowHapiModuleName.contract]: ContractState
|
73
|
+
[WindowHapiModuleName.debugging]: DebuggingState
|
74
|
+
[WindowHapiModuleName.language]: LanguageState
|
75
|
+
[WindowHapiModuleName.product]: ProductState
|
76
|
+
[WindowHapiModuleName.theming]: ThemingState
|
77
|
+
[WindowHapiModuleName.orderJourney]: OrderJourneyState
|
78
|
+
[WindowHapiModuleName.wallet]: WalletState
|
79
|
+
[WindowHapiModuleName.modal]: ModalState
|
80
|
+
[WindowHapiModuleName.ats]: ATSState
|
81
|
+
}
|
82
|
+
|
83
|
+
export type WindowHapiStateBase = {
|
84
|
+
__stateName: string
|
85
|
+
toJSON: any
|
86
|
+
}
|
87
|
+
|
88
|
+
export type HapiStateValueWithListener<T> = {
|
89
|
+
on: (callback: WindowHapiEventCommandCallbackHandler) => void
|
90
|
+
value: T
|
91
|
+
}
|
92
|
+
|
93
|
+
export type WindowHapiStateModule<T> = WindowHapiStateBase & {
|
94
|
+
[P in keyof T]:
|
95
|
+
| T[P]
|
96
|
+
| HapiStateValueWithListener<T[P]>
|
97
|
+
| ((v: T[P]) => void)
|
98
|
+
}
|
99
|
+
|
100
|
+
export type StateValidationKey =
|
101
|
+
| keyof WindowHapiValidations
|
102
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsCommon}`
|
103
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsBasket}`
|
104
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsCampaign}`
|
105
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsContract}`
|
106
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsLanguage}`
|
107
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsProduct}`
|
108
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsTheming}`
|
109
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsOrderJourney}`
|
110
|
+
| `${keyof WindowHapiValidations}.${keyof WindowHapiValidationsWallet}`
|
111
|
+
|
112
|
+
export type StateValidations<State> = {
|
113
|
+
[P in keyof State]: StateValidationKey | undefined
|
114
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {
|
2
|
+
WindowHapiModuleWithConstructorArgs,
|
3
|
+
WindowHapiClassInterface,
|
4
|
+
} from "./window"
|
5
|
+
|
6
|
+
export type WindowHapiUI = WindowHapiModuleWithConstructorArgs<
|
7
|
+
{
|
8
|
+
addUIElementToBody: (
|
9
|
+
elementName: "he-ui-modals" | "he-ui-alertbar",
|
10
|
+
) => void
|
11
|
+
toggleModal: () => void
|
12
|
+
toggleAlertbar: () => void
|
13
|
+
},
|
14
|
+
{ readonly core: WindowHapiClassInterface }
|
15
|
+
>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { WindowHapiModuleName } from "../common/enums"
|
2
|
+
import { WindowHapiUtilsProduct } from "../product/utils.types"
|
3
|
+
import { WindowHapiUtilsContract } from "../contract/utils.types"
|
4
|
+
import { WindowHapiUtilsCampaign } from "../campaign/utils.types"
|
5
|
+
import { WindowHapiUtilsBasket } from "../basket/utils.types"
|
6
|
+
import { WindowHapiUtilsOrderJourney } from "../orderJourney/utils.types"
|
7
|
+
import {
|
8
|
+
WindowHapiModuleWithConstructorArgs,
|
9
|
+
WindowHapiClassInterface,
|
10
|
+
} from "./window"
|
11
|
+
|
12
|
+
export type WindowHapiUtils = WindowHapiModuleWithConstructorArgs<
|
13
|
+
{
|
14
|
+
isObject: (item: any) => boolean
|
15
|
+
mergeDeepOverwriteArrays: (
|
16
|
+
original: Record<string, any>,
|
17
|
+
overwrites: Record<string, any>,
|
18
|
+
) => Record<string, any>
|
19
|
+
getComponentNameIndexSuffix: (instanceName: string) => string
|
20
|
+
getIframeLoadingSpinner: () => HTMLDivElement
|
21
|
+
product: WindowHapiUtilsProduct
|
22
|
+
contract: WindowHapiUtilsContract
|
23
|
+
campaign: WindowHapiUtilsCampaign
|
24
|
+
basket: WindowHapiUtilsBasket
|
25
|
+
orderJourney: WindowHapiUtilsOrderJourney
|
26
|
+
|
27
|
+
utilities: {
|
28
|
+
[WindowHapiModuleName.basket]: WindowHapiUtilsBasket
|
29
|
+
[WindowHapiModuleName.campaign]: WindowHapiUtilsCampaign
|
30
|
+
[WindowHapiModuleName.contract]: WindowHapiUtilsContract
|
31
|
+
[WindowHapiModuleName.product]: WindowHapiUtilsProduct
|
32
|
+
[WindowHapiModuleName.orderJourney]: WindowHapiUtilsOrderJourney
|
33
|
+
}
|
34
|
+
},
|
35
|
+
{ readonly core: WindowHapiClassInterface }
|
36
|
+
>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { z } from "zod"
|
2
|
+
import { WindowHapiModuleName } from "../common/enums"
|
3
|
+
import {
|
4
|
+
WindowHapiModuleWithConstructorArgs,
|
5
|
+
WindowHapiClassInterface,
|
6
|
+
} from "./window"
|
7
|
+
import { WindowHapiValidationsCommon } from "../common/validations.types"
|
8
|
+
import { WindowHapiValidationsProduct } from "../product/validations.types"
|
9
|
+
import { WindowHapiValidationsContract } from "../contract/validations.types"
|
10
|
+
import { WindowHapiValidationsCampaign } from "../campaign/validations.types"
|
11
|
+
import { WindowHapiValidationsBasket } from "../basket/validations.types"
|
12
|
+
import { WindowHapiValidationsWallet } from "../wallet/validations.types"
|
13
|
+
import { WindowHapiValidationsTheming } from "../theming/validations.types"
|
14
|
+
import { WindowHapiValidationsLanguage } from "../language/validations.types"
|
15
|
+
import { WindowHapiValidationsOrderJourney } from "../orderJourney/validations.types"
|
16
|
+
|
17
|
+
export type WindowHapiValidations = WindowHapiModuleWithConstructorArgs<
|
18
|
+
{
|
19
|
+
validator: typeof z
|
20
|
+
messages: Record<string, string | Function>
|
21
|
+
[WindowHapiModuleName.common]: WindowHapiValidationsCommon
|
22
|
+
[WindowHapiModuleName.product]: WindowHapiValidationsProduct
|
23
|
+
[WindowHapiModuleName.contract]: WindowHapiValidationsContract
|
24
|
+
[WindowHapiModuleName.campaign]: WindowHapiValidationsCampaign
|
25
|
+
[WindowHapiModuleName.basket]: WindowHapiValidationsBasket
|
26
|
+
[WindowHapiModuleName.wallet]: WindowHapiValidationsWallet
|
27
|
+
[WindowHapiModuleName.theming]: WindowHapiValidationsTheming
|
28
|
+
[WindowHapiModuleName.language]: WindowHapiValidationsLanguage
|
29
|
+
[WindowHapiModuleName.orderJourney]: WindowHapiValidationsOrderJourney
|
30
|
+
throwError: (error: string | undefined) => void
|
31
|
+
throwHasNoSetterError: (propertyName: string) => void
|
32
|
+
checkAndThrowArgumentUndefinedOrInvalidTypeError: (
|
33
|
+
parameter: any,
|
34
|
+
parameterName: string,
|
35
|
+
typeString: string,
|
36
|
+
invalidator?: Function,
|
37
|
+
) => void
|
38
|
+
runSDKEventsValidations: (callback: Function) => void
|
39
|
+
},
|
40
|
+
{ readonly core: WindowHapiClassInterface }
|
41
|
+
>
|
42
|
+
|
43
|
+
export type ValidationSubmoduleConstructorArgs = {
|
44
|
+
readonly validation: WindowHapiValidations
|
45
|
+
}
|
@@ -0,0 +1,140 @@
|
|
1
|
+
import { WindowHapiUtils } from "./utils.types"
|
2
|
+
import { WindowHapiValidations } from "./validation.types"
|
3
|
+
import { WindowHapiState } from "./state.types"
|
4
|
+
import { WindowHapiInstance, WindowHapiInstances } from "./instances.types"
|
5
|
+
import { WindowHapiRouting } from "./routing.types"
|
6
|
+
import { WindowHapiAuth } from "./auth.types"
|
7
|
+
import { WindowHapiEvents } from "./events.types"
|
8
|
+
import { WindowHapiUI } from "./ui.types"
|
9
|
+
import { WindowHapiAPI } from "./api.types"
|
10
|
+
import { WindowHapiSDK } from "./sdk.types"
|
11
|
+
import { WindowHapiService } from "./service.types"
|
12
|
+
import { WindowHapiQA } from "./qa.types"
|
13
|
+
import { WindowHapiLogger } from "../common/logger/types"
|
14
|
+
import {
|
15
|
+
HapiWebComponent,
|
16
|
+
RecursivePartial,
|
17
|
+
WindowHapiSubmoduleName,
|
18
|
+
} from "../common"
|
19
|
+
import { DebugPanelPosition } from "./config.types"
|
20
|
+
|
21
|
+
export type WindowHapiModuleWithConstructorArgs<Module, ConstructorArgs> =
|
22
|
+
Module & ConstructorArgs
|
23
|
+
|
24
|
+
export type WindowHapiUtilsSubmodule = WindowHapiModuleWithConstructorArgs<
|
25
|
+
WindowHapiUtils,
|
26
|
+
{ readonly core: WindowHapiClassInterface }
|
27
|
+
>
|
28
|
+
|
29
|
+
export type WindowHapiValidationSubmodule = WindowHapiModuleWithConstructorArgs<
|
30
|
+
WindowHapiValidations,
|
31
|
+
{ readonly core: WindowHapiClassInterface }
|
32
|
+
>
|
33
|
+
|
34
|
+
export type WindowHapiStateSubmodule = WindowHapiModuleWithConstructorArgs<
|
35
|
+
WindowHapiState,
|
36
|
+
{ readonly core: WindowHapiClassInterface }
|
37
|
+
>
|
38
|
+
|
39
|
+
export type WindowHapiInstancesSubmodule = WindowHapiModuleWithConstructorArgs<
|
40
|
+
WindowHapiInstances,
|
41
|
+
{ readonly core: WindowHapiClassInterface }
|
42
|
+
>
|
43
|
+
|
44
|
+
export type WindowHapiRoutingSubmodule = WindowHapiModuleWithConstructorArgs<
|
45
|
+
WindowHapiRouting,
|
46
|
+
{ readonly core: WindowHapiClassInterface }
|
47
|
+
>
|
48
|
+
|
49
|
+
export type WindowHapiAuthSubmodule = WindowHapiModuleWithConstructorArgs<
|
50
|
+
WindowHapiAuth,
|
51
|
+
{ readonly core: WindowHapiClassInterface }
|
52
|
+
>
|
53
|
+
|
54
|
+
export type WindowHapiEventsSubmodule = WindowHapiModuleWithConstructorArgs<
|
55
|
+
WindowHapiEvents,
|
56
|
+
{ readonly core: WindowHapiClassInterface }
|
57
|
+
>
|
58
|
+
|
59
|
+
export type WindowHapiUISubmodule = WindowHapiModuleWithConstructorArgs<
|
60
|
+
WindowHapiUI,
|
61
|
+
{ readonly core: WindowHapiClassInterface }
|
62
|
+
>
|
63
|
+
|
64
|
+
export type WindowHapiAPISubmodule = WindowHapiModuleWithConstructorArgs<
|
65
|
+
WindowHapiAPI,
|
66
|
+
{ readonly core: WindowHapiClassInterface }
|
67
|
+
>
|
68
|
+
|
69
|
+
export type WindowHapiSDKSubmodule = WindowHapiModuleWithConstructorArgs<
|
70
|
+
WindowHapiSDK,
|
71
|
+
{ readonly core: WindowHapiClassInterface }
|
72
|
+
>
|
73
|
+
|
74
|
+
export type WindowHapiServiceSubmodule = WindowHapiModuleWithConstructorArgs<
|
75
|
+
WindowHapiService,
|
76
|
+
{ readonly core: WindowHapiClassInterface }
|
77
|
+
>
|
78
|
+
|
79
|
+
export type WindowHapiQASubmodule = WindowHapiModuleWithConstructorArgs<
|
80
|
+
WindowHapiQA,
|
81
|
+
{ readonly core: WindowHapiClassInterface }
|
82
|
+
>
|
83
|
+
|
84
|
+
export type WindowHapiConfigSubmodule = {
|
85
|
+
apiHost: string
|
86
|
+
initialState: RecursivePartial<any>
|
87
|
+
partnerId: string
|
88
|
+
clientId: string
|
89
|
+
clientToken: string
|
90
|
+
loadingSpinnerDefaultFillColor: string
|
91
|
+
appOrigin: string
|
92
|
+
enableLogs: boolean
|
93
|
+
webComponents: HapiWebComponent[]
|
94
|
+
isInvalidToken: boolean
|
95
|
+
useJWTAuthHeaders: boolean
|
96
|
+
addModal: boolean
|
97
|
+
addAlertBar: boolean
|
98
|
+
addDebugPanel: boolean
|
99
|
+
debugPanelPosition: DebugPanelPosition
|
100
|
+
datadogClientToken: string
|
101
|
+
env: string
|
102
|
+
appVersion: string
|
103
|
+
testMode: boolean
|
104
|
+
debugMode: boolean
|
105
|
+
htmlTemplates: Record<string, string>
|
106
|
+
}
|
107
|
+
|
108
|
+
export type WindowHapiClassInterface = {
|
109
|
+
logger: WindowHapiLogger
|
110
|
+
utils: WindowHapiUtilsSubmodule
|
111
|
+
validation: WindowHapiValidationSubmodule
|
112
|
+
state: WindowHapiStateSubmodule
|
113
|
+
instances: WindowHapiInstancesSubmodule
|
114
|
+
routing: WindowHapiRoutingSubmodule
|
115
|
+
auth: WindowHapiAuthSubmodule
|
116
|
+
events: WindowHapiEventsSubmodule
|
117
|
+
ui: WindowHapiUISubmodule
|
118
|
+
api: WindowHapiAPISubmodule
|
119
|
+
sdk: WindowHapiSDKSubmodule
|
120
|
+
service: WindowHapiServiceSubmodule
|
121
|
+
instance: WindowHapiInstance
|
122
|
+
qa: WindowHapiQASubmodule
|
123
|
+
}
|
124
|
+
|
125
|
+
export type WindowHapi = {
|
126
|
+
[WindowHapiSubmoduleName.api]: WindowHapiAPISubmodule
|
127
|
+
[WindowHapiSubmoduleName.auth]: WindowHapiAuthSubmodule
|
128
|
+
[WindowHapiSubmoduleName.config]: WindowHapiConfigSubmodule
|
129
|
+
[WindowHapiSubmoduleName.instances]: WindowHapiInstancesSubmodule
|
130
|
+
[WindowHapiSubmoduleName.qa]: WindowHapiQASubmodule
|
131
|
+
[WindowHapiSubmoduleName.routing]: WindowHapiRoutingSubmodule
|
132
|
+
[WindowHapiSubmoduleName.sdk]: WindowHapiSDKSubmodule
|
133
|
+
[WindowHapiSubmoduleName.service]: WindowHapiServiceSubmodule
|
134
|
+
[WindowHapiSubmoduleName.state]: WindowHapiStateSubmodule
|
135
|
+
[WindowHapiSubmoduleName.ui]: WindowHapiUISubmodule
|
136
|
+
[WindowHapiSubmoduleName.utils]: WindowHapiUtilsSubmodule
|
137
|
+
[WindowHapiSubmoduleName.validation]: WindowHapiValidationSubmodule
|
138
|
+
[WindowHapiSubmoduleName.events]: WindowHapiEventsSubmodule
|
139
|
+
[WindowHapiSubmoduleName.instance]: WindowHapiInstance
|
140
|
+
}
|
@@ -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,15 @@
|
|
1
|
+
import { AlertKey } from "./enums"
|
2
|
+
import { AlertOptions } from "./types"
|
3
|
+
import { WindowHapiService } from "../_window/service.types"
|
4
|
+
import { WindowHapiModuleWithConstructorArgs } from "../_window"
|
5
|
+
|
6
|
+
export type WindowHapiServiceAlert = WindowHapiModuleWithConstructorArgs<
|
7
|
+
{
|
8
|
+
show: (
|
9
|
+
key: AlertKey,
|
10
|
+
props: any | undefined,
|
11
|
+
options: AlertOptions,
|
12
|
+
) => void
|
13
|
+
},
|
14
|
+
{ readonly service: WindowHapiService }
|
15
|
+
>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Alert, AlertOptions } from "./types"
|
2
|
+
export type AlertState = {
|
3
|
+
alerts: Alert[]
|
4
|
+
defaultOptions: AlertOptions
|
5
|
+
successOptions: AlertOptions | null
|
6
|
+
infoOptions: AlertOptions | null
|
7
|
+
warningOptions: AlertOptions | null
|
8
|
+
errorOptions: AlertOptions | null
|
9
|
+
}
|
@@ -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 { WindowHapiModuleWithConstructorArgs } from "../_window"
|
5
|
+
|
6
|
+
export type WindowHapiAPIATSConfigs = {
|
7
|
+
getUserSettings: AxiosRequestConfig<any>
|
8
|
+
}
|
9
|
+
|
10
|
+
export type WindowHapiAPIATSRequests = {
|
11
|
+
getUserSettings: () => Promise<ATSSettings>
|
12
|
+
}
|
13
|
+
export type WindowHapiAPIATS = WindowHapiModuleWithConstructorArgs<
|
14
|
+
WindowHapiAPIModule<WindowHapiAPIATSRequests, WindowHapiAPIATSConfigs>,
|
15
|
+
{ readonly api: WindowHapiAPI }
|
16
|
+
>
|
package/src/ats/index.ts
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import {
|
2
|
+
HapiServiceFunctionWithLifecycleHooks,
|
3
|
+
WindowHapiService,
|
4
|
+
} from "../_window/service.types"
|
5
|
+
import { ATSSettings } from "./types"
|
6
|
+
import { WindowHapiModuleWithConstructorArgs } from "../_window"
|
7
|
+
|
8
|
+
export type ATSServiceGetUserSettingsHandler = () => Promise<
|
9
|
+
ATSSettings | undefined
|
10
|
+
>
|
11
|
+
|
12
|
+
export type WindowHapiServiceATS = WindowHapiModuleWithConstructorArgs<
|
13
|
+
{
|
14
|
+
getUserSettings: HapiServiceFunctionWithLifecycleHooks<ATSServiceGetUserSettingsHandler>
|
15
|
+
},
|
16
|
+
{ readonly service: WindowHapiService }
|
17
|
+
>
|
package/src/ats/types.ts
ADDED
@@ -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,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 { WindowHapiModuleWithConstructorArgs } from "../_window"
|
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 = WindowHapiModuleWithConstructorArgs<
|
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,34 @@
|
|
1
|
+
import { Product } from "../product/types"
|
2
|
+
import { BasketProduct } from "./types"
|
3
|
+
import { Contract } from "../contract/types"
|
4
|
+
|
5
|
+
export type BasketState = {
|
6
|
+
/**
|
7
|
+
* Array of `BasketProduct`s. The price or other properties of a Product or Contract may change therefore this variable only contains ID of Product or Contract and whether it is a Product or not; via the `isProduct: boolean` variable. Elements of this array then are fetched from the API with their latest information and then set as `products`.
|
8
|
+
*/
|
9
|
+
productsMeta: BasketProduct[]
|
10
|
+
/**
|
11
|
+
* Array of Products and/or Contracts. This variable is auto-populated with the response received from the API for the Products and Contracts inside `productsMeta`
|
12
|
+
*/
|
13
|
+
products: (Product | Contract)[]
|
14
|
+
/**
|
15
|
+
* Sum of prices of Products and/or Contracts in EUR currency. **This value is a computed getter meaning that it cannot be set from outside**
|
16
|
+
*/
|
17
|
+
totalInEUR: number
|
18
|
+
/**
|
19
|
+
* Sum of prices of Products and/or Contracts in USD currency. **This value is a computed getter meaning that it cannot be set from outside**
|
20
|
+
*/
|
21
|
+
totalInUSD: number
|
22
|
+
/**
|
23
|
+
* Sum of prices of Products and/or Contracts in GBP currency. **This value is a computed getter meaning that it cannot be set from outside**
|
24
|
+
*/
|
25
|
+
totalInGBP: number
|
26
|
+
/**
|
27
|
+
* Sum of prices of Products and/or Contracts in the current display currency that is used throughout the widgets. **This value is a computed getter meaning that it cannot be set from outside**
|
28
|
+
*/
|
29
|
+
totalInDisplayCurrency: number
|
30
|
+
/**
|
31
|
+
* Shows a spinner in Basket when the data for Products and/or Contracts is being fetched from the API
|
32
|
+
*/
|
33
|
+
productsAreLoading: boolean
|
34
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { BasketProduct } from "./types"
|
2
|
+
import { WindowHapiUtils } from "../_window/utils.types"
|
3
|
+
import { WindowHapiModuleWithConstructorArgs } from "../_window"
|
4
|
+
|
5
|
+
export type WindowHapiUtilsBasket = WindowHapiModuleWithConstructorArgs<
|
6
|
+
{
|
7
|
+
getInitialBasketProductsMeta: () => BasketProduct[]
|
8
|
+
},
|
9
|
+
{ readonly utils: WindowHapiUtils }
|
10
|
+
>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import {
|
2
|
+
ZodArray,
|
3
|
+
ZodBoolean,
|
4
|
+
ZodNumber,
|
5
|
+
ZodObject,
|
6
|
+
ZodString,
|
7
|
+
ZodUnion,
|
8
|
+
} from "zod"
|
9
|
+
import { ZodProduct } from "../product/validations.types"
|
10
|
+
import { ZodContract } from "../contract/validations.types"
|
11
|
+
|
12
|
+
export type ZodContractsOrProducts = ZodArray<
|
13
|
+
ZodUnion<[ZodProduct, ZodContract]>
|
14
|
+
>
|
15
|
+
export type ZodBasketProductMeta = ZodObject<{
|
16
|
+
id: ZodUnion<[ZodString, ZodNumber]>
|
17
|
+
isProduct: ZodBoolean
|
18
|
+
}>
|
19
|
+
export type ZodBasketProductsMeta = ZodArray<ZodBasketProductMeta>
|
20
|
+
|
21
|
+
export type WindowHapiValidationsBasket = {
|
22
|
+
contractsOrProducts: ZodContractsOrProducts
|
23
|
+
productMeta: ZodBasketProductMeta
|
24
|
+
productsMeta: ZodBasketProductsMeta
|
25
|
+
}
|