@vonq/hapi-elements-types 1.4.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.
- package/enums.ts +41 -0
- package/package.json +5 -7
- package/src/_window/api.types.ts +59 -0
- package/src/_window/auth.types.ts +11 -0
- package/src/_window/config.types.ts +30 -0
- package/src/_window/events.types.ts +157 -0
- package/src/_window/index.ts +16 -0
- package/src/_window/instances.types.ts +18 -0
- package/src/_window/qa.types.ts +28 -0
- package/src/_window/routing.types.ts +21 -0
- package/src/_window/sdk.types.ts +147 -0
- package/src/_window/service.types.ts +67 -0
- package/src/_window/state.types.ts +112 -0
- package/src/_window/ui.types.ts +13 -0
- package/src/_window/utils.types.ts +34 -0
- package/src/_window/validation.types.ts +43 -0
- package/src/_window/window.ts +56 -0
- package/src/alert/enums.ts +22 -0
- package/src/alert/functions.types.ts +13 -0
- package/src/alert/index.ts +9 -0
- package/src/alert/service.types.ts +15 -0
- package/src/alert/state.initial.ts +16 -0
- package/src/alert/state.types.ts +27 -0
- package/src/alert/state.validations.ts +11 -0
- package/src/alert/types.ts +63 -0
- package/src/ats/api.types.ts +16 -0
- package/src/ats/functions.types.ts +7 -0
- package/src/ats/index.ts +9 -0
- package/src/ats/service.types.ts +17 -0
- package/src/ats/state.initial.ts +5 -0
- package/src/ats/state.types.ts +5 -0
- package/src/ats/state.validations.ts +6 -0
- package/src/ats/types.ts +19 -0
- package/src/basket/consts.ts +1 -0
- package/src/basket/functions.types.ts +40 -0
- package/src/basket/index.ts +12 -0
- package/src/basket/service.types.ts +32 -0
- package/src/basket/state.initial.ts +11 -0
- package/src/basket/state.types.ts +34 -0
- package/src/basket/state.validations.ts +12 -0
- package/src/basket/types.ts +4 -0
- package/src/basket/utils.ts +79 -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/consts.ts +1 -0
- package/src/campaign/enums.ts +17 -0
- package/src/campaign/functions.types.ts +90 -0
- package/src/campaign/index.ts +15 -0
- package/src/campaign/qa.types.ts +12 -0
- package/src/campaign/service.types.ts +48 -0
- package/src/campaign/state.initial.ts +84 -0
- package/src/campaign/state.types.ts +55 -0
- package/src/campaign/state.validations.ts +16 -0
- package/src/campaign/types.ts +237 -0
- package/src/campaign/utils.ts +53 -0
- package/src/campaign/utils.types.ts +59 -0
- package/src/campaign/validations.types.ts +215 -0
- package/src/common/LocalStorage.ts +123 -0
- package/src/common/browser.ts +2 -0
- package/src/common/color.ts +9 -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/immutable.ts +28 -0
- package/src/common/index.ts +22 -0
- package/src/common/instances/Instance.ts +13 -0
- package/src/common/instances/consts.ts +1 -0
- package/src/common/instances/index.ts +4 -0
- package/src/common/json.ts +25 -0
- package/src/common/logger/Logger.ts +70 -0
- package/src/common/logger/enums.ts +12 -0
- package/src/common/logger/index.ts +5 -0
- package/src/common/logger/types.ts +7 -0
- package/src/common/logger-datadog/LoggerDatadog.ts +42 -0
- package/src/common/logger-datadog/index.ts +3 -0
- package/src/common/misc.ts +114 -0
- package/src/common/promise.ts +161 -0
- package/src/common/proxy.ts +77 -0
- package/src/common/qa.types.ts +9 -0
- package/src/common/regExTest.ts +12 -0
- package/src/common/tree.ts +148 -0
- package/src/common/types.ts +110 -0
- package/src/common/utm.ts +19 -0
- package/src/common/validations.types.ts +89 -0
- package/src/common/validators.ts +21 -0
- package/src/common/webComponents.ts +26 -0
- package/src/config/functions.types.ts +23 -0
- package/src/config/index.ts +5 -0
- package/src/config/state.initial.ts +11 -0
- package/src/config/state.types.ts +15 -0
- package/src/consts.ts +980 -0
- package/src/contract/api.types.ts +47 -0
- package/src/contract/consts.ts +1 -0
- package/src/contract/functions.types.ts +112 -0
- package/src/contract/index.ts +14 -0
- package/src/contract/qa.types.ts +12 -0
- package/src/contract/service.types.ts +54 -0
- package/src/contract/state.initial.ts +39 -0
- package/src/contract/state.types.ts +74 -0
- package/src/contract/state.validations.ts +21 -0
- package/src/contract/types.ts +145 -0
- package/src/contract/utils.ts +36 -0
- package/src/contract/utils.types.ts +11 -0
- package/src/contract/validations.types.ts +104 -0
- package/src/debugging/functions.types.ts +34 -0
- package/src/debugging/index.ts +6 -0
- package/src/debugging/state.initial.ts +10 -0
- package/src/debugging/state.types.ts +18 -0
- package/src/debugging/state.validations.ts +10 -0
- package/src/index.ts +22 -0
- package/src/language/consts.ts +6 -0
- package/src/language/en.ts +530 -0
- package/src/language/functions.types.ts +29 -0
- package/src/language/index.ts +11 -0
- package/src/language/qa.types.ts +19 -0
- package/src/language/state.initial.ts +13 -0
- package/src/language/state.types.ts +25 -0
- package/src/language/state.validations.ts +10 -0
- package/src/language/utils.ts +17 -0
- package/src/language/validations.types.ts +13 -0
- package/src/modal/consts.ts +6 -0
- package/src/modal/enums.ts +14 -0
- package/src/modal/functions.types.ts +22 -0
- package/src/modal/index.ts +11 -0
- package/src/modal/service.types.ts +32 -0
- package/src/modal/state.initial.ts +9 -0
- package/src/modal/state.types.ts +8 -0
- package/src/modal/state.validations.ts +6 -0
- package/src/modal/store.types.ts +5 -0
- package/src/modal/types.ts +44 -0
- package/src/orderJourney/consts.ts +289 -0
- package/src/orderJourney/enums.ts +25 -0
- package/src/orderJourney/functions.types.ts +140 -0
- package/src/orderJourney/index.ts +13 -0
- package/src/orderJourney/qa.types.ts +16 -0
- package/src/orderJourney/state.initial.ts +401 -0
- package/src/orderJourney/state.types.ts +99 -0
- package/src/orderJourney/state.validations.ts +78 -0
- package/src/orderJourney/types.ts +31 -0
- package/src/orderJourney/utils.ts +7 -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/consts.ts +1 -0
- package/src/product/enums.ts +11 -0
- package/src/product/functions.types.ts +156 -0
- package/src/product/index.ts +14 -0
- package/src/product/qa.types.ts +11 -0
- package/src/product/service.types.ts +68 -0
- package/src/product/state.initial.ts +28 -0
- package/src/product/state.types.ts +93 -0
- package/src/product/state.validations.ts +25 -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/functions.types.ts +48 -0
- package/src/routing/index.ts +5 -0
- package/src/routing/state.initial.ts +10 -0
- package/src/routing/state.types.ts +30 -0
- package/src/theming/consts.ts +7727 -0
- package/src/theming/functions.types.ts +13 -0
- package/src/theming/index.ts +11 -0
- package/src/theming/qa.types.ts +11 -0
- package/src/theming/state.initial.ts +16 -0
- package/src/theming/state.types.ts +6 -0
- package/src/theming/state.validations.ts +8 -0
- package/src/theming/types.ts +123 -0
- package/src/theming/utils.ts +581 -0
- package/src/theming/validations.types.ts +62 -0
- package/src/types.ts +229 -0
- package/src/ui/index.ts +3 -0
- package/src/ui/service.types.ts +26 -0
- package/src/utils.ts +3 -0
- package/src/wallet/api.types.ts +33 -0
- package/src/wallet/consts.ts +3 -0
- package/src/wallet/functions.types.ts +58 -0
- package/src/wallet/index.ts +11 -0
- package/src/wallet/service.types.ts +26 -0
- package/src/wallet/state.initial.ts +18 -0
- package/src/wallet/state.types.ts +58 -0
- package/src/wallet/state.validations.ts +18 -0
- package/src/wallet/types.ts +65 -0
- package/src/wallet/validations.types.ts +18 -0
- package/tsconfig.json +41 -0
- package/index.d.ts +0 -5207
package/src/types.ts
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import { WindowHapiState } from "./_window/state.types"
|
3
|
+
import { WindowHapiAuth } from "./_window/auth.types"
|
4
|
+
import { WindowHapiUI } from "./_window/ui.types"
|
5
|
+
import HapiInstance from "./common/instances/Instance"
|
6
|
+
import { WindowHapiQA } from "./_window/qa.types"
|
7
|
+
import { ProductStoreState } from "./product/state.types"
|
8
|
+
import { ProductStoreFunctions } from "./product/functions.types"
|
9
|
+
import { BasketStoreState } from "./basket/state.types"
|
10
|
+
import { BasketStoreFunctions } from "./basket/functions.types"
|
11
|
+
import { ModalStore } from "./modal/store.types"
|
12
|
+
import { ModalStoreState } from "./modal/state.types"
|
13
|
+
import { ModalStoreFunctions } from "./modal/functions.types"
|
14
|
+
import { ContractStoreState } from "./contract/state.types"
|
15
|
+
import { ContractStoreFunctions } from "./contract/functions.types"
|
16
|
+
import { AlertStoreState } from "./alert/state.types"
|
17
|
+
import { AlertStoreFunctions } from "./alert/functions.types"
|
18
|
+
import { OrderJourneyStoreState } from "./orderJourney/state.types"
|
19
|
+
import { OrderJourneyStoreFunctions } from "./orderJourney/functions.types"
|
20
|
+
import { CampaignStoreState } from "./campaign/state.types"
|
21
|
+
import { CampaignStoreFunctions } from "./campaign/functions.types"
|
22
|
+
import { WalletStoreState } from "./wallet/state.types"
|
23
|
+
import { WalletStoreFunctions } from "./wallet/functions.types"
|
24
|
+
import { ThemeStoreState } from "./theming/state.types"
|
25
|
+
import { ThemeStoreFunctions } from "./theming/functions.types"
|
26
|
+
import { RouterStoreState } from "./routing/state.types"
|
27
|
+
import { RouterStoreFunctions } from "./routing/functions.types"
|
28
|
+
import { ConfigStoreState } from "./config/state.types"
|
29
|
+
import { ConfigStoreFunctions } from "./config/functions.types"
|
30
|
+
import { LanguageStoreState } from "./language/state.types"
|
31
|
+
import { LanguageStoreFunctions } from "./language/functions.types"
|
32
|
+
import { DebuggingStoreState } from "./debugging/state.types"
|
33
|
+
import { DebuggingStoreFunctions } from "./debugging/functions.types"
|
34
|
+
import { IntlShape } from "react-intl"
|
35
|
+
import { Logger } from "./common/logger/Logger"
|
36
|
+
import { IReactionDisposer } from "mobx"
|
37
|
+
import { ATSStoreState } from "./ats/state.types"
|
38
|
+
import { ATSStoreFunctions } from "./ats/functions.types"
|
39
|
+
import { WindowHapiValidations } from "./_window/validation.types"
|
40
|
+
import { WindowHapiUtils } from "./_window/utils.types"
|
41
|
+
import { WindowHapiRouting } from "./_window/routing.types"
|
42
|
+
import { WindowHapiInstances } from "./_window/instances.types"
|
43
|
+
import { WindowHapiSDK } from "./_window/sdk.types"
|
44
|
+
import { WindowHapiService } from "./_window/service.types"
|
45
|
+
import { WindowHapiEvents } from "./_window/events.types"
|
46
|
+
import { WindowHapiAPI } from "./_window/api.types"
|
47
|
+
import { WindowHapiConfig } from "./_window/config.types"
|
48
|
+
import { RecursivePartial } from "./common/types"
|
49
|
+
|
50
|
+
export type ComponentWithChildren = {
|
51
|
+
children?: React.ReactNode
|
52
|
+
}
|
53
|
+
|
54
|
+
export type WindowHAPIInterface = {
|
55
|
+
hapiState: WindowHapiState
|
56
|
+
hapiAuth: WindowHapiAuth
|
57
|
+
hapiConfig: WindowHapiConfig
|
58
|
+
hapiEvents: WindowHapiEvents
|
59
|
+
hapiInstances: WindowHapiInstances
|
60
|
+
hapiRouting: WindowHapiRouting
|
61
|
+
hapiUI: WindowHapiUI
|
62
|
+
hapiUtils: WindowHapiUtils
|
63
|
+
hapiInstance: HapiInstance
|
64
|
+
hapiValidation: WindowHapiValidations
|
65
|
+
hapi: WindowHapiSDK
|
66
|
+
hapiApi: WindowHapiAPI
|
67
|
+
hapiService: WindowHapiService
|
68
|
+
hapiQA: WindowHapiQA
|
69
|
+
__hapi: IRootStore
|
70
|
+
__mobxToJS: <T>(source: T, options?: any) => T
|
71
|
+
}
|
72
|
+
export type BaseStoreFunctions = {
|
73
|
+
init: () => void
|
74
|
+
}
|
75
|
+
export type CreateLoggerHandler = (
|
76
|
+
source?: string,
|
77
|
+
isEnabled?: boolean,
|
78
|
+
) => Logger
|
79
|
+
export type IRootStore = {
|
80
|
+
store: Stores
|
81
|
+
rehydrateStore: (
|
82
|
+
storeName: keyof Stores,
|
83
|
+
storeData: RecursivePartial<Stores[keyof Stores]>,
|
84
|
+
) => void
|
85
|
+
intl: IntlShape
|
86
|
+
createLogger: CreateLoggerHandler
|
87
|
+
|
88
|
+
sourceInstance: HapiInstance
|
89
|
+
targetInstances: HapiInstance[]
|
90
|
+
}
|
91
|
+
export type BaseStoreVariables = {
|
92
|
+
rootStore: IRootStore
|
93
|
+
}
|
94
|
+
export type BaseStoreVariablesAndFunctions = BaseStoreVariables &
|
95
|
+
BaseStoreFunctions
|
96
|
+
export type BaseStore<State, Functions> = BaseStoreVariablesAndFunctions &
|
97
|
+
State &
|
98
|
+
Functions
|
99
|
+
export type ConfigStore = BaseStore<ConfigStoreState, ConfigStoreFunctions>
|
100
|
+
export type ConfigStoreType = StoryFactoryType<
|
101
|
+
ConfigStore,
|
102
|
+
ConfigStoreState,
|
103
|
+
ConfigStoreFunctions
|
104
|
+
>
|
105
|
+
export type ATSStore = BaseStore<ATSStoreState, ATSStoreFunctions>
|
106
|
+
export type ATSStoreType = StoryFactoryType<
|
107
|
+
ATSStore,
|
108
|
+
ATSStoreState,
|
109
|
+
ATSStoreFunctions
|
110
|
+
>
|
111
|
+
export type LanguageStore = BaseStore<
|
112
|
+
LanguageStoreState,
|
113
|
+
LanguageStoreFunctions
|
114
|
+
>
|
115
|
+
export type LanguageStoreType = StoryFactoryType<
|
116
|
+
LanguageStore,
|
117
|
+
LanguageStoreState,
|
118
|
+
LanguageStoreFunctions
|
119
|
+
>
|
120
|
+
export type AlertStore = BaseStore<AlertStoreState, AlertStoreFunctions>
|
121
|
+
export type AlertStoreType = StoryFactoryType<
|
122
|
+
AlertStore,
|
123
|
+
AlertStoreState,
|
124
|
+
AlertStoreFunctions
|
125
|
+
>
|
126
|
+
export type ThemeStore = BaseStore<ThemeStoreState, ThemeStoreFunctions>
|
127
|
+
export type ThemeStoreType = StoryFactoryType<
|
128
|
+
ThemeStore,
|
129
|
+
ThemeStoreState,
|
130
|
+
ThemeStoreFunctions
|
131
|
+
>
|
132
|
+
export type RouterStore = BaseStore<RouterStoreState, RouterStoreFunctions>
|
133
|
+
export type RouterStoreType = StoryFactoryType<
|
134
|
+
RouterStore,
|
135
|
+
RouterStoreState,
|
136
|
+
RouterStoreFunctions
|
137
|
+
>
|
138
|
+
export type ContractStore = BaseStore<
|
139
|
+
ContractStoreState,
|
140
|
+
ContractStoreFunctions
|
141
|
+
>
|
142
|
+
export type ContractStoreType = StoryFactoryType<
|
143
|
+
ContractStore,
|
144
|
+
ContractStoreState,
|
145
|
+
ContractStoreFunctions
|
146
|
+
>
|
147
|
+
export type ProductStore = BaseStore<ProductStoreState, ProductStoreFunctions>
|
148
|
+
export type ProductStoreType = StoryFactoryType<
|
149
|
+
ProductStore,
|
150
|
+
ProductStoreState,
|
151
|
+
ProductStoreFunctions
|
152
|
+
>
|
153
|
+
export type CampaignStore = BaseStore<
|
154
|
+
CampaignStoreState,
|
155
|
+
CampaignStoreFunctions
|
156
|
+
>
|
157
|
+
export type CampaignStoreType = StoryFactoryType<
|
158
|
+
CampaignStore,
|
159
|
+
CampaignStoreState,
|
160
|
+
CampaignStoreFunctions
|
161
|
+
>
|
162
|
+
export type WalletStore = BaseStore<WalletStoreState, WalletStoreFunctions>
|
163
|
+
export type WalletStoreType = StoryFactoryType<
|
164
|
+
WalletStore,
|
165
|
+
WalletStoreState,
|
166
|
+
WalletStoreFunctions
|
167
|
+
>
|
168
|
+
export type BasketStore = BaseStore<BasketStoreState, BasketStoreFunctions>
|
169
|
+
export type BasketStoreType = StoryFactoryType<
|
170
|
+
BasketStore,
|
171
|
+
BasketStoreState,
|
172
|
+
BasketStoreFunctions
|
173
|
+
>
|
174
|
+
export type ModalStoreType = StoryFactoryType<
|
175
|
+
ModalStore,
|
176
|
+
ModalStoreState,
|
177
|
+
ModalStoreFunctions
|
178
|
+
>
|
179
|
+
export type OrderJourneyStore = BaseStore<
|
180
|
+
OrderJourneyStoreState,
|
181
|
+
OrderJourneyStoreFunctions
|
182
|
+
>
|
183
|
+
export type OrderJourneyStoreType = StoryFactoryType<
|
184
|
+
OrderJourneyStore,
|
185
|
+
OrderJourneyStoreState,
|
186
|
+
OrderJourneyStoreFunctions
|
187
|
+
>
|
188
|
+
export type DebuggingStore = BaseStore<
|
189
|
+
DebuggingStoreState,
|
190
|
+
DebuggingStoreFunctions
|
191
|
+
>
|
192
|
+
export type DebuggingStoreType = StoryFactoryType<
|
193
|
+
DebuggingStore,
|
194
|
+
DebuggingStoreState,
|
195
|
+
DebuggingStoreFunctions
|
196
|
+
>
|
197
|
+
export type Stores = {
|
198
|
+
atsStore: ATSStoreType
|
199
|
+
configStore: ConfigStoreType
|
200
|
+
languageStore: LanguageStoreType
|
201
|
+
alertStore: AlertStoreType
|
202
|
+
themeStore: ThemeStoreType
|
203
|
+
contractStore: ContractStoreType
|
204
|
+
productStore: ProductStoreType
|
205
|
+
routerStore: RouterStoreType
|
206
|
+
campaignStore: CampaignStoreType
|
207
|
+
modalStore: ModalStoreType
|
208
|
+
walletStore: WalletStoreType
|
209
|
+
basketStore: BasketStoreType
|
210
|
+
orderJourneyStore: OrderJourneyStoreType
|
211
|
+
debuggingStore: DebuggingStoreType
|
212
|
+
}
|
213
|
+
export type CommonStoreVariablesAndFunctions = {
|
214
|
+
init: (...args: any[]) => void | Promise<void>
|
215
|
+
logger: Logger
|
216
|
+
classObserver: StoreClassObserver | undefined
|
217
|
+
toJSON: JSON
|
218
|
+
}
|
219
|
+
export type StoreClassObserver = IReactionDisposer
|
220
|
+
export type StoreFactory<Store, _StoreState, _StoreFunctions> =
|
221
|
+
CommonStoreVariablesAndFunctions
|
222
|
+
export type StoryFactoryType<Store, _StoreState, _StoreFunctions> =
|
223
|
+
StoreFactory<Store, _StoreState, _StoreFunctions> &
|
224
|
+
_StoreState &
|
225
|
+
_StoreFunctions
|
226
|
+
export type DemoATSLayoutType = "technical" | "product-oriented"
|
227
|
+
|
228
|
+
export type ModuleWithConstructorArgs<Module, ConstructorArgs> = Module &
|
229
|
+
ConstructorArgs
|
package/src/ui/index.ts
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import { ModuleWithConstructorArgs } from "../types"
|
2
|
+
import { WindowHapiService } from "../_window/service.types"
|
3
|
+
|
4
|
+
export type WindowHapiServiceUI = ModuleWithConstructorArgs<
|
5
|
+
{
|
6
|
+
setStyleAttribute: (
|
7
|
+
selector: string,
|
8
|
+
attributeName: string,
|
9
|
+
attributeValue: any,
|
10
|
+
) => Promise<void>
|
11
|
+
setStyle: (selector: string, style: any) => Promise<void>
|
12
|
+
addClass: (selector: string, className: string) => Promise<void>
|
13
|
+
removeClass: (selector: string, className: string) => Promise<void>
|
14
|
+
appendChild: (
|
15
|
+
containerSelector: string,
|
16
|
+
element: HTMLElement,
|
17
|
+
) => Promise<void>
|
18
|
+
removeChild: (
|
19
|
+
containerSelector: string,
|
20
|
+
elementSelector: string,
|
21
|
+
) => Promise<void>
|
22
|
+
hideElement: (elementSelector: string) => Promise<void>
|
23
|
+
showElement: (elementSelector: string) => Promise<void>
|
24
|
+
},
|
25
|
+
{ readonly service: WindowHapiService }
|
26
|
+
>
|
package/src/utils.ts
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
import { RawAxiosRequestConfig } from "axios"
|
2
|
+
import {
|
3
|
+
Wallet,
|
4
|
+
WalletBillingPortalLinkResponse,
|
5
|
+
WalletCreateForm,
|
6
|
+
WalletPaymentIntentRequest,
|
7
|
+
} from "./types"
|
8
|
+
import { WindowHapiAPI, WindowHapiAPIModule } from "../_window/api.types"
|
9
|
+
import { ModuleWithConstructorArgs } from "../types"
|
10
|
+
|
11
|
+
export type WindowHapiAPIWalletConfigs = {
|
12
|
+
getWallet: RawAxiosRequestConfig
|
13
|
+
createWallet: RawAxiosRequestConfig
|
14
|
+
getBillingPortalLink: RawAxiosRequestConfig
|
15
|
+
createPaymentIntent: RawAxiosRequestConfig
|
16
|
+
}
|
17
|
+
export type WindowHapiAPIWalletRequests = {
|
18
|
+
getWallet: () => Promise<Wallet>
|
19
|
+
createWallet: (wallet: WalletCreateForm) => Promise<Wallet>
|
20
|
+
getBillingPortalLink: (
|
21
|
+
returnUrl: string,
|
22
|
+
) => Promise<WalletBillingPortalLinkResponse>
|
23
|
+
createPaymentIntent: (
|
24
|
+
paymentParams: WalletPaymentIntentRequest,
|
25
|
+
) => Promise<any>
|
26
|
+
}
|
27
|
+
export type WindowHapiAPIWallet = ModuleWithConstructorArgs<
|
28
|
+
WindowHapiAPIModule<
|
29
|
+
WindowHapiAPIWalletRequests,
|
30
|
+
WindowHapiAPIWalletConfigs
|
31
|
+
>,
|
32
|
+
{ readonly api: WindowHapiAPI }
|
33
|
+
>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { ProductPriceCurrency } from "../product/enums"
|
2
|
+
import { Wallet, WalletPaymentIntentPaymentMethod } from "./types"
|
3
|
+
|
4
|
+
export type WalletStoreSetWalletHandler = (wallet: Wallet) => void
|
5
|
+
export type WalletStoreSetIsWalletLoadingHandler = (isLoading: boolean) => void
|
6
|
+
export type WalletStoreSetTopUpIsLoadingHandler = (isLoading: boolean) => void
|
7
|
+
export type WalletStoreSetTopUpAmountHandler = (amount: number) => void
|
8
|
+
export type WalletStoreSetTopUpMinAmountHandler = (amount: number) => void
|
9
|
+
export type WalletStoreSetTopUpMinAmountCurrencyHandler = (
|
10
|
+
currency: ProductPriceCurrency,
|
11
|
+
) => void
|
12
|
+
export type WalletStoreSetTopUpTermsOfServiceIsAgreedHandler = (
|
13
|
+
isAgreed: boolean,
|
14
|
+
) => void
|
15
|
+
export type WalletStoreSetStripeClientSecretHandler = (client: string) => void
|
16
|
+
export type WalletStoreSetTopUpCurrentStepIndexHandler = (step: number) => void
|
17
|
+
export type WalletStoreSetTopUpPaymentMethodTypesHandler = (
|
18
|
+
type: WalletPaymentIntentPaymentMethod[],
|
19
|
+
) => void
|
20
|
+
|
21
|
+
export type WalletStoreFunctions = {
|
22
|
+
/**
|
23
|
+
* The function that sets the value of `wallet`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
24
|
+
*/
|
25
|
+
setWallet: WalletStoreSetWalletHandler
|
26
|
+
/**
|
27
|
+
* The function that sets the value of `walletIsLoading`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
28
|
+
*/
|
29
|
+
setWalletIsLoading: WalletStoreSetIsWalletLoadingHandler
|
30
|
+
/**
|
31
|
+
* The function that sets the value of `topUpIsLoading`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
32
|
+
*/
|
33
|
+
setTopUpIsLoading: WalletStoreSetTopUpIsLoadingHandler
|
34
|
+
/**
|
35
|
+
* The function that sets the value of `topUpAmount`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
36
|
+
*/
|
37
|
+
setTopUpAmount: WalletStoreSetTopUpAmountHandler
|
38
|
+
/**
|
39
|
+
* The function that sets the value of `topUpMinAmount`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
40
|
+
*/
|
41
|
+
setTopUpMinAmount: WalletStoreSetTopUpMinAmountHandler
|
42
|
+
/**
|
43
|
+
* The function that sets the value of `topUpMinAmountCurrency`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
44
|
+
*/
|
45
|
+
setTopUpMinAmountCurrency: WalletStoreSetTopUpMinAmountCurrencyHandler
|
46
|
+
/**
|
47
|
+
* The function that sets the value of `topUpTermsOfServiceIsAgreed`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
48
|
+
*/
|
49
|
+
setTopUpTermsOfServiceIsAgreed: WalletStoreSetTopUpTermsOfServiceIsAgreedHandler
|
50
|
+
/**
|
51
|
+
* The function that sets the value of `topUpCurrentStepIndex`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
52
|
+
*/
|
53
|
+
setTopUpCurrentStepIndex: WalletStoreSetTopUpCurrentStepIndexHandler
|
54
|
+
/**
|
55
|
+
* The function that sets the value of `topUpPaymentMethodTypes`. Refer to [WalletStoreState](/docs/sdk/wallet/#walletstorestate) for more details.
|
56
|
+
*/
|
57
|
+
setTopUpPaymentMethodTypes: WalletStoreSetTopUpPaymentMethodTypesHandler
|
58
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// created from 'create-ts-index'
|
2
|
+
|
3
|
+
export * from './api.types';
|
4
|
+
export * from './consts';
|
5
|
+
export * from './functions.types';
|
6
|
+
export * from './service.types';
|
7
|
+
export * from './state.initial';
|
8
|
+
export * from './state.types';
|
9
|
+
export * from './state.validations';
|
10
|
+
export * from './types';
|
11
|
+
export * from './validations.types';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Wallet, WalletATSSettings, WalletPaymentIntentRequest } from "./types"
|
2
|
+
import {
|
3
|
+
HapiServiceFunctionWithLifecycleHooks,
|
4
|
+
WindowHapiService,
|
5
|
+
} from "../_window/service.types"
|
6
|
+
import { ModuleWithConstructorArgs } from "../types"
|
7
|
+
|
8
|
+
export type WalletServiceGetATSSettingsHandler =
|
9
|
+
() => Promise<WalletATSSettings>
|
10
|
+
export type WalletServiceGetWalletHandler = (
|
11
|
+
preventSettingIsLoading?: boolean,
|
12
|
+
) => Promise<Wallet>
|
13
|
+
export type WalletServiceCreateWalletHandler = () => Promise<Wallet>
|
14
|
+
|
15
|
+
export type WindowHapiServiceWallet = ModuleWithConstructorArgs<
|
16
|
+
{
|
17
|
+
getATSSettings: HapiServiceFunctionWithLifecycleHooks<WalletServiceGetATSSettingsHandler>
|
18
|
+
getWallet: HapiServiceFunctionWithLifecycleHooks<WalletServiceGetWalletHandler>
|
19
|
+
createWallet: HapiServiceFunctionWithLifecycleHooks<WalletServiceCreateWalletHandler>
|
20
|
+
createPaymentIntent: (
|
21
|
+
paymentParams: WalletPaymentIntentRequest,
|
22
|
+
) => Promise<void>
|
23
|
+
resetTopUpState: () => void
|
24
|
+
},
|
25
|
+
{ readonly service: WindowHapiService }
|
26
|
+
>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { ProductPriceCurrency } from "../product/enums"
|
2
|
+
import { WalletStoreState } from "./state.types"
|
3
|
+
|
4
|
+
export const initialWalletStoreState: WalletStoreState = {
|
5
|
+
balanceIsEnoughToOrderCampaign: false,
|
6
|
+
balanceInUSD: null,
|
7
|
+
paymentIntentRequestBody: null,
|
8
|
+
paymentIntentClientSecret: null,
|
9
|
+
topUpPaymentMethodTypes: ["card"],
|
10
|
+
wallet: null,
|
11
|
+
walletIsLoading: false,
|
12
|
+
topUpIsLoading: false,
|
13
|
+
topUpAmount: 0,
|
14
|
+
topUpMinAmount: 0,
|
15
|
+
topUpMinAmountCurrency: ProductPriceCurrency.USD,
|
16
|
+
topUpTermsOfServiceIsAgreed: false,
|
17
|
+
topUpCurrentStepIndex: 0,
|
18
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { ProductPriceCurrency } from "../product/enums"
|
2
|
+
import {
|
3
|
+
Wallet,
|
4
|
+
WalletPaymentIntentPaymentMethod,
|
5
|
+
WalletPaymentIntentRequest,
|
6
|
+
} from "./types"
|
7
|
+
|
8
|
+
export type WalletStoreState = {
|
9
|
+
/**
|
10
|
+
* User's Wallet that can hold credits to be used on Creating/Ordering a Campaign
|
11
|
+
*/
|
12
|
+
wallet: Wallet | null
|
13
|
+
/**
|
14
|
+
* User's balance in dollars converted from cents through `wallet.balance`. **This value is a computed getter meaning that it cannot be set from outside**
|
15
|
+
*/
|
16
|
+
balanceInUSD: number | null
|
17
|
+
/**
|
18
|
+
* Indicates whether or not user has enough credits/balance to Order a Campaign
|
19
|
+
*/
|
20
|
+
balanceIsEnoughToOrderCampaign: boolean
|
21
|
+
/**
|
22
|
+
* Shows a loading spinner while wallet is loading
|
23
|
+
*/
|
24
|
+
walletIsLoading: boolean
|
25
|
+
/**
|
26
|
+
* The request body to be sent to HAPI Backend Service to create a payment intent. **This value is a computed getter meaning that it cannot be set from outside**
|
27
|
+
*/
|
28
|
+
paymentIntentRequestBody: WalletPaymentIntentRequest | null
|
29
|
+
paymentIntentClientSecret: string | null
|
30
|
+
/**
|
31
|
+
* Shows a loading spinner while PaymentIntent is creating
|
32
|
+
*/
|
33
|
+
topUpIsLoading: boolean
|
34
|
+
/**
|
35
|
+
* A custom amount to specify for the top up of balance
|
36
|
+
*/
|
37
|
+
topUpAmount: number
|
38
|
+
/**
|
39
|
+
* A minimum amount enforced by an ATS for the top up of balance
|
40
|
+
*/
|
41
|
+
topUpMinAmount: number
|
42
|
+
/**
|
43
|
+
* A minimum amount's currency enforced by an ATS for the top up of balance
|
44
|
+
*/
|
45
|
+
topUpMinAmountCurrency: ProductPriceCurrency
|
46
|
+
/**
|
47
|
+
* Indicates if user has agreed to terms of service
|
48
|
+
*/
|
49
|
+
topUpTermsOfServiceIsAgreed: boolean
|
50
|
+
/**
|
51
|
+
* Step of the popup. **Should not be edited from outside**
|
52
|
+
*/
|
53
|
+
topUpCurrentStepIndex: number
|
54
|
+
/**
|
55
|
+
* An array of payment method types that Stripe accepts https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_types to specify which types of payment methods the end user can use
|
56
|
+
*/
|
57
|
+
topUpPaymentMethodTypes: WalletPaymentIntentPaymentMethod[]
|
58
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { WalletStoreState } from "./state.types"
|
2
|
+
import { StateValidations } from "../_window/state.types"
|
3
|
+
|
4
|
+
export const walletStoreStateValidations: StateValidations<WalletStoreState> = {
|
5
|
+
wallet: "wallet.wallet",
|
6
|
+
walletIsLoading: "common.genericBoolean",
|
7
|
+
balanceInUSD: "throwHasNoSetterError",
|
8
|
+
balanceIsEnoughToOrderCampaign: "throwHasNoSetterError",
|
9
|
+
topUpPaymentMethodTypes: "common.genericStringArray",
|
10
|
+
paymentIntentRequestBody: "throwHasNoSetterError",
|
11
|
+
paymentIntentClientSecret: "common.genericNullableString",
|
12
|
+
topUpIsLoading: "common.genericBoolean",
|
13
|
+
topUpAmount: "common.genericNumber",
|
14
|
+
topUpMinAmount: "common.genericNumber",
|
15
|
+
topUpMinAmountCurrency: "product.currency",
|
16
|
+
topUpTermsOfServiceIsAgreed: "common.genericBoolean",
|
17
|
+
topUpCurrentStepIndex: "common.genericNumber",
|
18
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import { ProductPriceCurrency } from "../product/enums"
|
2
|
+
|
3
|
+
export type WalletBalanceInCents = {
|
4
|
+
USD: number
|
5
|
+
}
|
6
|
+
|
7
|
+
export type Wallet = {
|
8
|
+
balance: WalletBalanceInCents
|
9
|
+
created_date: string
|
10
|
+
has_billing_details: boolean
|
11
|
+
id: string
|
12
|
+
}
|
13
|
+
|
14
|
+
export type WalletATSSettings = {
|
15
|
+
topUpAmount: number
|
16
|
+
topUpMinAmount: number
|
17
|
+
topUpPaymentMethodTypes: WalletPaymentIntentPaymentMethod[]
|
18
|
+
topUpMinAmountCurrency: ProductPriceCurrency
|
19
|
+
}
|
20
|
+
|
21
|
+
export type WalletCreateForm = {
|
22
|
+
customerName: string
|
23
|
+
}
|
24
|
+
|
25
|
+
export type WalletBillingPortalLinkResponse = {
|
26
|
+
billingPortalLink: string
|
27
|
+
}
|
28
|
+
|
29
|
+
export type WalletPaymentIntentPaymentMethod =
|
30
|
+
| "card"
|
31
|
+
| "acss_debit"
|
32
|
+
| "affirm"
|
33
|
+
| "afterpay_clearpay"
|
34
|
+
| "alipay"
|
35
|
+
| "au_becs_debit"
|
36
|
+
| "bacs_debit"
|
37
|
+
| "bancontact"
|
38
|
+
| "blik"
|
39
|
+
| "boleto"
|
40
|
+
| "card_present"
|
41
|
+
| "eps"
|
42
|
+
| "fpx"
|
43
|
+
| "giropay"
|
44
|
+
| "grabpay"
|
45
|
+
| "ideal"
|
46
|
+
| "klarna"
|
47
|
+
| "konbini"
|
48
|
+
| "link"
|
49
|
+
| "oxxo"
|
50
|
+
| "p24"
|
51
|
+
| "paynow"
|
52
|
+
| "pix"
|
53
|
+
| "promptpay"
|
54
|
+
| "sepa_debit"
|
55
|
+
| "sofort"
|
56
|
+
| "us_bank_account"
|
57
|
+
| "wechat_pay"
|
58
|
+
|
59
|
+
export type WalletPaymentIntentRequest = {
|
60
|
+
walletId: string
|
61
|
+
partnerId: string
|
62
|
+
amount: number
|
63
|
+
agreeTerms: boolean
|
64
|
+
paymentMethodTypes?: WalletPaymentIntentPaymentMethod[]
|
65
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { ZodBoolean, ZodNullable, ZodNumber, ZodObject, ZodString } from "zod"
|
2
|
+
|
3
|
+
export type ZodWalletBalance = ZodObject<{
|
4
|
+
USD: ZodNumber
|
5
|
+
}>
|
6
|
+
export type ZodWallet = ZodObject<{
|
7
|
+
balance: ZodWalletBalance
|
8
|
+
created_date: ZodString
|
9
|
+
has_billing_details: ZodBoolean
|
10
|
+
id: ZodString
|
11
|
+
}>
|
12
|
+
export type ZodWalletCreateForm = ZodObject<{
|
13
|
+
customerName: ZodString
|
14
|
+
}>
|
15
|
+
export type WindowHapiValidationsWallet = {
|
16
|
+
wallet: ZodNullable<ZodWallet>
|
17
|
+
walletForm: ZodWalletCreateForm
|
18
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "es2015",
|
4
|
+
"lib": [
|
5
|
+
"dom",
|
6
|
+
"dom.iterable",
|
7
|
+
"esnext"
|
8
|
+
],
|
9
|
+
"allowJs": true,
|
10
|
+
"skipLibCheck": true,
|
11
|
+
"strict": true,
|
12
|
+
"noEmit": false,
|
13
|
+
"esModuleInterop": true,
|
14
|
+
"moduleResolution": "node",
|
15
|
+
"module": "commonjs",
|
16
|
+
"resolveJsonModule": true,
|
17
|
+
"isolatedModules": false,
|
18
|
+
"jsx": "preserve",
|
19
|
+
"incremental": false,
|
20
|
+
"experimentalDecorators": true,
|
21
|
+
"baseUrl": "./src",
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
23
|
+
"paths": {
|
24
|
+
"axios": ["../../node_modules/axios"],
|
25
|
+
"zod": ["../../node_modules/zod"],
|
26
|
+
"theming": ["../../node_modules/theming"],
|
27
|
+
"react-intl": ["../../node_modules/react-intl"],
|
28
|
+
"react": ["../../node_modules/react"],
|
29
|
+
"lodash": ["../../node_modules/lodash"]
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"include": [
|
33
|
+
"./src/**/*",
|
34
|
+
],
|
35
|
+
"exclude": [
|
36
|
+
"node_modules",
|
37
|
+
"../ats/**/*",
|
38
|
+
"../common/**/*",
|
39
|
+
"./dist/**/*"
|
40
|
+
]
|
41
|
+
}
|