@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/enums.ts
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
export enum WindowHapiCoreModuleName {
|
2
|
+
"api" = "hapiApi",
|
3
|
+
auth = "hapiAuth",
|
4
|
+
config = "hapiConfig",
|
5
|
+
instances = "hapiInstances",
|
6
|
+
qa = "hapiQA",
|
7
|
+
routing = "hapiRouting",
|
8
|
+
sdk = "hapi",
|
9
|
+
service = "hapiService",
|
10
|
+
state = "hapiState",
|
11
|
+
ui = "hapiUI",
|
12
|
+
utils = "hapiUtils",
|
13
|
+
validation = "hapiValidation",
|
14
|
+
instance = "hapiInstance",
|
15
|
+
}
|
16
|
+
|
17
|
+
export enum WindowHapiModuleName {
|
18
|
+
ats = "ats",
|
19
|
+
basket = "basket",
|
20
|
+
campaign = "campaign",
|
21
|
+
contract = "contract",
|
22
|
+
product = "product",
|
23
|
+
"common" = "common",
|
24
|
+
wallet = "wallet",
|
25
|
+
debugging = "debugging",
|
26
|
+
language = "language",
|
27
|
+
theming = "theming",
|
28
|
+
orderJourney = "orderJourney",
|
29
|
+
userJourney = "userJourney",
|
30
|
+
alert = "alert",
|
31
|
+
modal = "modal",
|
32
|
+
"ui" = "ui",
|
33
|
+
}
|
34
|
+
|
35
|
+
export enum WindowHapiSDKModuleName {
|
36
|
+
api = "api",
|
37
|
+
state = "state",
|
38
|
+
validation = "validation",
|
39
|
+
service = "service",
|
40
|
+
utils = "utils",
|
41
|
+
}
|
package/package.json
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"private": false,
|
3
3
|
"name": "@vonq/hapi-elements-types",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.5.0",
|
5
5
|
"description": "This package contains Typescript definitions for HAPI Elements",
|
6
6
|
"author": "VONQ HAPI Team",
|
7
7
|
"license": "BSD-3-Clause",
|
8
8
|
"type": "module",
|
9
9
|
"scripts": {
|
10
|
-
"build:types": "tsc -d --declarationMap --emitDeclarationOnly",
|
11
10
|
"version:minor": "npm version minor",
|
12
|
-
"publish:types": "npm publish --access public"
|
11
|
+
"publish:types": "npm publish --access public",
|
12
|
+
"generate:index": "cti create ./src"
|
13
13
|
},
|
14
|
-
"
|
15
|
-
"files": [
|
16
|
-
"index.d.ts"
|
17
|
-
],
|
14
|
+
"main": "src/index.ts",
|
18
15
|
"devDependencies": {
|
19
16
|
"color": "^4.2.3",
|
17
|
+
"create-ts-index": "^1.14.0",
|
20
18
|
"mobx": "^6.8.0",
|
21
19
|
"react": "^18.2.0",
|
22
20
|
"typescript": "^4.9.5",
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { Logger } from "../common/logger/Logger"
|
2
|
+
import {
|
3
|
+
AxiosRequestConfig,
|
4
|
+
AxiosResponse,
|
5
|
+
RawAxiosRequestConfig,
|
6
|
+
RawAxiosRequestHeaders,
|
7
|
+
} from "axios"
|
8
|
+
import { ModuleWithConstructorArgs } from "../types"
|
9
|
+
import { WindowHapiModuleName } from "../../enums"
|
10
|
+
import { WindowHapiAPIATS } from "../ats/api.types"
|
11
|
+
import { WindowHapiAPICampaign } from "../campaign/api.types"
|
12
|
+
import { WindowHapiAPIContract } from "../contract/api.types"
|
13
|
+
import { WindowHapiAPIProduct } from "../product/api.types"
|
14
|
+
import { WindowHapiAPIWallet } from "../wallet/api.types"
|
15
|
+
import { WindowHapi } from "./window"
|
16
|
+
|
17
|
+
export type WindowHapiAPIModule<ModuleType, ModuleConfig> = {
|
18
|
+
logger: Logger
|
19
|
+
configs: ModuleConfig
|
20
|
+
setBaseURL: (url: string) => void
|
21
|
+
setBaseConfig: (config: Record<string, RawAxiosRequestConfig>) => void
|
22
|
+
setResourceConfig: (
|
23
|
+
resourceKey: keyof ModuleConfig,
|
24
|
+
config: RawAxiosRequestConfig,
|
25
|
+
) => void
|
26
|
+
} & ModuleType
|
27
|
+
export type HapiRequestConfig<T> = Omit<AxiosRequestConfig<T>, "headers"> & {
|
28
|
+
headers?: any
|
29
|
+
}
|
30
|
+
export type WindowHapiAPI = ModuleWithConstructorArgs<
|
31
|
+
{
|
32
|
+
/* Common */
|
33
|
+
request: <T = any, R = AxiosResponse<T>, D = any>(
|
34
|
+
config: Partial<HapiRequestConfig<D>>,
|
35
|
+
) => Promise<R>
|
36
|
+
baseURL: string
|
37
|
+
setBaseURL: (url: string) => void
|
38
|
+
setBaseConfig: (params: Record<string, Record<string, string>>) => void
|
39
|
+
baseTimeout: number
|
40
|
+
setBaseTimeout: (timeout: number) => void
|
41
|
+
baseHeaders: RawAxiosRequestHeaders
|
42
|
+
headers: RawAxiosRequestHeaders
|
43
|
+
setHeaders: (headers: RawAxiosRequestHeaders) => void
|
44
|
+
baseRequestConfig: RawAxiosRequestConfig<any>
|
45
|
+
[WindowHapiModuleName.contract]: WindowHapiAPIContract
|
46
|
+
[WindowHapiModuleName.wallet]: WindowHapiAPIWallet
|
47
|
+
[WindowHapiModuleName.product]: WindowHapiAPIProduct
|
48
|
+
[WindowHapiModuleName.campaign]: WindowHapiAPICampaign
|
49
|
+
[WindowHapiModuleName.ats]: WindowHapiAPIATS
|
50
|
+
modules: {
|
51
|
+
[WindowHapiModuleName.contract]: WindowHapiAPIContract
|
52
|
+
[WindowHapiModuleName.wallet]: WindowHapiAPIWallet
|
53
|
+
[WindowHapiModuleName.product]: WindowHapiAPIProduct
|
54
|
+
[WindowHapiModuleName.campaign]: WindowHapiAPICampaign
|
55
|
+
[WindowHapiModuleName.ats]: WindowHapiAPIATS
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{ readonly core: WindowHapi }
|
59
|
+
>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ModuleWithConstructorArgs } from "../types"
|
2
|
+
import { WindowHapi } from "./window"
|
3
|
+
|
4
|
+
export type WindowHapiAuth = ModuleWithConstructorArgs<
|
5
|
+
{
|
6
|
+
partnerId: string | undefined
|
7
|
+
clientId: string | undefined
|
8
|
+
clientToken: string | undefined
|
9
|
+
},
|
10
|
+
{ readonly core: WindowHapi }
|
11
|
+
>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { HapiWebComponent, RecursivePartial } from "../common/types"
|
2
|
+
|
3
|
+
export type DebugPanelPosition =
|
4
|
+
| "bottom-left"
|
5
|
+
| "bottom-right"
|
6
|
+
| "top-left"
|
7
|
+
| "top-right"
|
8
|
+
export type WindowHapiConfig = {
|
9
|
+
apiHost: string
|
10
|
+
initialState: RecursivePartial<any>
|
11
|
+
partnerId: string
|
12
|
+
clientId: string
|
13
|
+
clientToken: string
|
14
|
+
loadingSpinnerDefaultFillColor: string
|
15
|
+
appOrigin: string
|
16
|
+
enableLogs: boolean
|
17
|
+
webComponents: HapiWebComponent[]
|
18
|
+
isInvalidToken: boolean
|
19
|
+
useJWTAuthHeaders: boolean
|
20
|
+
addModal: boolean
|
21
|
+
addAlertBar: boolean
|
22
|
+
addDebugPanel: boolean
|
23
|
+
debugPanelPosition: DebugPanelPosition
|
24
|
+
datadogClientToken: string
|
25
|
+
env: string
|
26
|
+
appVersion: string
|
27
|
+
testMode: boolean
|
28
|
+
debugMode: boolean
|
29
|
+
htmlTemplates: Record<string, string>
|
30
|
+
}
|
@@ -0,0 +1,157 @@
|
|
1
|
+
import { ModuleWithConstructorArgs } from "../types"
|
2
|
+
import {
|
3
|
+
WindowHapiEventCommandNames,
|
4
|
+
WindowHapiEventCommandStatus,
|
5
|
+
WindowHapiEventCommandData,
|
6
|
+
} from "../common/events/EventCommand/types"
|
7
|
+
import {
|
8
|
+
WindowHapiEventCommandCallbackHandler,
|
9
|
+
WindowHapiEventMediatorGetInstancesHandler,
|
10
|
+
WindowHapiEventMediatorInstances,
|
11
|
+
WindowHapiEventCommand,
|
12
|
+
WindowHapiEventStrategy,
|
13
|
+
} from "../common/events/types"
|
14
|
+
import { WindowHapi } from "./window"
|
15
|
+
import WindowHapiInstance from "../common/instances/Instance"
|
16
|
+
import { WindowHapiCoreModuleName } from "../../enums"
|
17
|
+
import EventListener from "../../../common/events/EventListener"
|
18
|
+
import WindowHapiEventListener from "../../../common/events/EventListener"
|
19
|
+
|
20
|
+
export type WindowHapiEventFactory = ModuleWithConstructorArgs<
|
21
|
+
{
|
22
|
+
findEventsPendingResolveOrReject: (
|
23
|
+
events: WindowHapiEventCommand[],
|
24
|
+
id: string,
|
25
|
+
) => WindowHapiEventCommand | undefined
|
26
|
+
findOrCreate: (
|
27
|
+
events: WindowHapiEventCommand[],
|
28
|
+
name: WindowHapiEventCommandNames,
|
29
|
+
value: WindowHapiEventCommandData,
|
30
|
+
instances: WindowHapiEventMediatorInstances,
|
31
|
+
id?: string,
|
32
|
+
) => WindowHapiEventCommand
|
33
|
+
create: (
|
34
|
+
name: WindowHapiEventCommandNames,
|
35
|
+
data: WindowHapiEventCommandData,
|
36
|
+
getInstances: WindowHapiEventMediatorGetInstancesHandler,
|
37
|
+
id?: string,
|
38
|
+
status?: WindowHapiEventCommandStatus,
|
39
|
+
) => WindowHapiEventCommand
|
40
|
+
},
|
41
|
+
{ readonly getInstances: WindowHapiEventMediatorGetInstancesHandler }
|
42
|
+
>
|
43
|
+
|
44
|
+
export type WindowHapiEventMediatorCreateAndDispatchHandler = (
|
45
|
+
name: WindowHapiEventCommandNames,
|
46
|
+
data?: WindowHapiEventCommandData,
|
47
|
+
id?: string,
|
48
|
+
status?: WindowHapiEventCommandStatus,
|
49
|
+
) => Promise<WindowHapiEventCommand | undefined>
|
50
|
+
|
51
|
+
export type WindowHapiEventMediator = ModuleWithConstructorArgs<
|
52
|
+
{
|
53
|
+
createAndDispatch: WindowHapiEventMediatorCreateAndDispatchHandler
|
54
|
+
createAndDispatchDebounced: (
|
55
|
+
leading: boolean,
|
56
|
+
) => WindowHapiEventMediatorCreateAndDispatchHandler
|
57
|
+
removeListener: (name: WindowHapiEventCommandNames) => void
|
58
|
+
onMessageReceived: (
|
59
|
+
eventCommand: WindowHapiEventCommand,
|
60
|
+
) => Promise<WindowHapiEventCommand>
|
61
|
+
onMessage: (messageEvent: MessageEvent) => Promise<void>
|
62
|
+
runCallbacks: (eventCommand: WindowHapiEventCommand) => void
|
63
|
+
onRequestFullfilledOrTimedOut: (
|
64
|
+
resolve: any,
|
65
|
+
reject: any,
|
66
|
+
request: WindowHapiEventCommand,
|
67
|
+
) => void
|
68
|
+
dispatchEvent: (
|
69
|
+
eventCommand: WindowHapiEventCommand,
|
70
|
+
) => Promise<WindowHapiEventCommand | undefined>
|
71
|
+
retryEvent: (
|
72
|
+
eventCommand: WindowHapiEventCommand,
|
73
|
+
) => Promise<WindowHapiEventCommand | undefined>
|
74
|
+
acknowledgeEvent: (event: WindowHapiEventCommand) => void
|
75
|
+
rejectEvent: (event: WindowHapiEventCommand) => Promise<void>
|
76
|
+
resolveEvent: (event: WindowHapiEventCommand) => Promise<void>
|
77
|
+
removeMessageEventListener: (_window: Window) => void
|
78
|
+
addMessageEventListener: (_window: Window) => void
|
79
|
+
getEventListener: (
|
80
|
+
name: WindowHapiEventCommandNames,
|
81
|
+
id?: string,
|
82
|
+
) => EventListener | undefined
|
83
|
+
addEventListener: (
|
84
|
+
name: WindowHapiEventCommandNames,
|
85
|
+
callback: WindowHapiEventCommandCallbackHandler,
|
86
|
+
id?: string,
|
87
|
+
) => EventListener
|
88
|
+
removeEventListener: (eventId: string) => void
|
89
|
+
},
|
90
|
+
{
|
91
|
+
readonly getInstances: WindowHapiEventMediatorGetInstancesHandler
|
92
|
+
readonly eventStorage: WindowHapiEventStorage
|
93
|
+
readonly eventFactory: WindowHapiEventFactory
|
94
|
+
readonly eventStateStrategy?: WindowHapiEventStrategy
|
95
|
+
readonly eventRoutingStrategy?: WindowHapiEventStrategy
|
96
|
+
readonly eventDOMStrategy?: WindowHapiEventStrategy
|
97
|
+
readonly eventConfigStrategy?: WindowHapiEventStrategy
|
98
|
+
readonly eventAppStrategy?: WindowHapiEventStrategy
|
99
|
+
readonly eventApiStrategy?: WindowHapiEventStrategy
|
100
|
+
readonly eventServiceStrategy?: WindowHapiEventStrategy
|
101
|
+
readonly eventQAStrategy?: WindowHapiEventStrategy
|
102
|
+
}
|
103
|
+
>
|
104
|
+
|
105
|
+
export type WindowHapiEventStorage = ModuleWithConstructorArgs<
|
106
|
+
{
|
107
|
+
cache: (WindowHapiEventCommand | WindowHapiEventListener)[]
|
108
|
+
listeners: WindowHapiEventListener[]
|
109
|
+
getFullfilledRequest: (eventCommandId: string) => WindowHapiEventCommand
|
110
|
+
replaceById: (eventCommand: WindowHapiEventCommand) => void
|
111
|
+
getEventById: (
|
112
|
+
eventCommandId: string,
|
113
|
+
) => WindowHapiEventCommand | WindowHapiEventListener | undefined
|
114
|
+
add: (
|
115
|
+
eventCommand: WindowHapiEventCommand | WindowHapiEventListener,
|
116
|
+
) => void
|
117
|
+
remove: (id: string) => void
|
118
|
+
removeByName: (name: string) => void
|
119
|
+
getEventsByName: (name: string) => WindowHapiEventCommand[]
|
120
|
+
},
|
121
|
+
{ readonly getInstances: WindowHapiEventMediatorGetInstancesHandler }
|
122
|
+
>
|
123
|
+
|
124
|
+
export type WindowHapiEvents = ModuleWithConstructorArgs<
|
125
|
+
{
|
126
|
+
hasAddedWindowMessageEvent: boolean
|
127
|
+
addInternalEventListeners: () => void
|
128
|
+
removeInternalEventListeners: () => void
|
129
|
+
createSDKEventListener: (
|
130
|
+
property: string,
|
131
|
+
callback: (data: any) => void,
|
132
|
+
) => void
|
133
|
+
sdkEventListenerCallback: (
|
134
|
+
data: WindowHapiEventCommandData,
|
135
|
+
_property: string,
|
136
|
+
callback: (data: WindowHapiEventCommandData) => void,
|
137
|
+
) => void
|
138
|
+
eventFactory: WindowHapiEventFactory
|
139
|
+
eventMediator: WindowHapiEventMediator
|
140
|
+
eventStorage: WindowHapiEventStorage
|
141
|
+
eventRoutingStrategy: WindowHapiEventStrategy
|
142
|
+
eventAppStrategy: WindowHapiEventStrategy
|
143
|
+
eventApiStrategy: WindowHapiEventStrategy
|
144
|
+
eventStateStrategy: WindowHapiEventStrategy
|
145
|
+
eventServiceStrategy: WindowHapiEventStrategy
|
146
|
+
eventQAStrategy: WindowHapiEventStrategy
|
147
|
+
getInstances: () => {
|
148
|
+
source: WindowHapiInstance
|
149
|
+
targets: WindowHapiInstance[]
|
150
|
+
}
|
151
|
+
handleEventWithDataRequest: (
|
152
|
+
event: WindowHapiEventCommand,
|
153
|
+
coreModuleName: WindowHapiCoreModuleName,
|
154
|
+
) => Promise<void>
|
155
|
+
},
|
156
|
+
{ readonly core: WindowHapi }
|
157
|
+
>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// created from 'create-ts-index'
|
2
|
+
|
3
|
+
export * from './api.types';
|
4
|
+
export * from './auth.types';
|
5
|
+
export * from './config.types';
|
6
|
+
export * from './events.types';
|
7
|
+
export * from './instances.types';
|
8
|
+
export * from './qa.types';
|
9
|
+
export * from './routing.types';
|
10
|
+
export * from './sdk.types';
|
11
|
+
export * from './service.types';
|
12
|
+
export * from './state.types';
|
13
|
+
export * from './ui.types';
|
14
|
+
export * from './utils.types';
|
15
|
+
export * from './validation.types';
|
16
|
+
export * from './window';
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import HapiInstance from "../common/instances/Instance"
|
2
|
+
import { ModuleWithConstructorArgs } from "../types"
|
3
|
+
import { WindowHapi } from "./window"
|
4
|
+
|
5
|
+
export type WindowHapiInstances = ModuleWithConstructorArgs<
|
6
|
+
{
|
7
|
+
instances: HapiInstance[]
|
8
|
+
getFrameWindowByName: (name: string) => Window | undefined
|
9
|
+
hasInstance: (instanceName: string) => boolean
|
10
|
+
getInstanceByName: (instanceName: string) => HapiInstance | undefined
|
11
|
+
addInstanceByName: (instanceName: string, window: Window) => void
|
12
|
+
addInstance: (instance: HapiInstance) => void
|
13
|
+
removeInstance: (instanceName: string) => void
|
14
|
+
onAfterAddInstance: (instance: HapiInstance) => void
|
15
|
+
onAfterRemoveInstance: (instance: HapiInstance) => void
|
16
|
+
},
|
17
|
+
{ readonly core: WindowHapi }
|
18
|
+
>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { WindowHapiModuleName } from "../../enums"
|
2
|
+
import { ModuleWithConstructorArgs } from "../types"
|
3
|
+
import { WindowHapi } from "./window"
|
4
|
+
import { WindowHapiQACampaign } from "../campaign/qa.types"
|
5
|
+
import { WindowHapiQACommon } from "../common/qa.types"
|
6
|
+
import { WindowHapiQAOrderJourney } from "../orderJourney/qa.types"
|
7
|
+
import { WindowHapiQAContract } from "../contract/qa.types"
|
8
|
+
import { WindowHapiQATheming } from "../theming/qa.types"
|
9
|
+
import { WindowHapiQALanguage } from "../language/qa.types"
|
10
|
+
import { WindowHapiQAProduct } from "../product/qa.types"
|
11
|
+
|
12
|
+
export type WindowHapiQA = ModuleWithConstructorArgs<
|
13
|
+
{
|
14
|
+
[WindowHapiModuleName.campaign]: WindowHapiQACampaign
|
15
|
+
[WindowHapiModuleName.product]: WindowHapiQAProduct
|
16
|
+
[WindowHapiModuleName.contract]: WindowHapiQAContract
|
17
|
+
[WindowHapiModuleName.orderJourney]: WindowHapiQAOrderJourney
|
18
|
+
[WindowHapiModuleName.theming]: WindowHapiQATheming
|
19
|
+
[WindowHapiModuleName.language]: WindowHapiQALanguage
|
20
|
+
[WindowHapiModuleName.common]: WindowHapiQACommon
|
21
|
+
|
22
|
+
isDebugPanelOpen: boolean
|
23
|
+
getDebugPanelButtonEl: () => HTMLElement | null
|
24
|
+
addDebugPanelToDOM: () => void
|
25
|
+
setDebugPanelPosition: (buttonEl: HTMLElement | null) => void
|
26
|
+
},
|
27
|
+
{ readonly core: WindowHapi }
|
28
|
+
>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ModuleWithConstructorArgs } from "../types"
|
2
|
+
import { WindowHapi } from "./window"
|
3
|
+
|
4
|
+
export type WindowHapiRoutingQueryParams = Record<string, string | string[]>
|
5
|
+
|
6
|
+
export type WindowHapiRouting = ModuleWithConstructorArgs<
|
7
|
+
{
|
8
|
+
locationChangeInterval: number | undefined
|
9
|
+
currentPathname: string
|
10
|
+
startingPathname: string
|
11
|
+
origin: string
|
12
|
+
queryParams: WindowHapiRoutingQueryParams
|
13
|
+
setCurrentPathname: (pathname: string) => void
|
14
|
+
setStartingPathname: (pathname: string) => void
|
15
|
+
changeHref: (href: string) => void
|
16
|
+
setOrigin: (origin: string) => void
|
17
|
+
setQueryParams: (params: WindowHapiRoutingQueryParams) => void
|
18
|
+
onRouteChange: () => void
|
19
|
+
},
|
20
|
+
{ readonly core: WindowHapi }
|
21
|
+
>
|
@@ -0,0 +1,147 @@
|
|
1
|
+
import { WindowHapiModuleName } from "../../enums"
|
2
|
+
import { ModuleWithConstructorArgs } from "../types"
|
3
|
+
import { WindowHapiServiceAlert } from "../alert/service.types"
|
4
|
+
import { WindowHapiStateModule } from "./state.types"
|
5
|
+
import { AlertStoreState } from "../alert/state.types"
|
6
|
+
import { WindowHapiServiceBasket } from "../basket/service.types"
|
7
|
+
import { BasketStoreState } from "../basket/state.types"
|
8
|
+
import { WindowHapiUtilsBasket } from "../basket/utils.types"
|
9
|
+
import { WindowHapiServiceCampaign } from "../campaign/service.types"
|
10
|
+
import { CampaignStoreState } from "../campaign/state.types"
|
11
|
+
import { WindowHapiUtilsCampaign } from "../campaign/utils.types"
|
12
|
+
import { WindowHapiServiceContract } from "../contract/service.types"
|
13
|
+
import { ContractStoreState } from "../contract/state.types"
|
14
|
+
import { WindowHapiUtilsContract } from "../contract/utils.types"
|
15
|
+
import { DebuggingStoreState } from "../debugging/state.types"
|
16
|
+
import { LanguageStoreState } from "../language/state.types"
|
17
|
+
import { WindowHapiServiceModal } from "../modal/service.types"
|
18
|
+
import { ModalStoreState } from "../modal/state.types"
|
19
|
+
import { OrderJourneyStoreState } from "../orderJourney/state.types"
|
20
|
+
import { WindowHapiUtilsOrderJourney } from "../orderJourney/utils.types"
|
21
|
+
import { WindowHapiServiceProduct } from "../product/service.types"
|
22
|
+
import { ProductStoreState } from "../product/state.types"
|
23
|
+
import { WindowHapiUtilsProduct } from "../product/utils.types"
|
24
|
+
import { ThemeStoreState } from "../theming/state.types"
|
25
|
+
import { WindowHapiServiceWallet } from "../wallet/service.types"
|
26
|
+
import { WalletStoreState } from "../wallet/state.types"
|
27
|
+
import { WindowHapiValidationsBasket } from "../basket/validations.types"
|
28
|
+
import { WindowHapiValidationsCampaign } from "../campaign/validations.types"
|
29
|
+
import { WindowHapiValidationsContract } from "../contract/validations.types"
|
30
|
+
import { WindowHapiValidationsLanguage } from "../language/validations.types"
|
31
|
+
import { WindowHapiValidationsOrderJourney } from "../orderJourney/validations.types"
|
32
|
+
import { WindowHapiValidationsProduct } from "../product/validations.types"
|
33
|
+
import { WindowHapiValidationsTheming } from "../theming/validations.types"
|
34
|
+
import { WindowHapiValidationsWallet } from "../wallet/validations.types"
|
35
|
+
import { WindowHapiAPICampaign } from "../campaign/api.types"
|
36
|
+
import { WindowHapiAPIContract } from "../contract/api.types"
|
37
|
+
import { WindowHapiAPIProduct } from "../product/api.types"
|
38
|
+
import { WindowHapiAPIWallet } from "../wallet/api.types"
|
39
|
+
import { WindowHapi } from "./window"
|
40
|
+
import { WindowHapiServiceUI } from "../ui/service.types"
|
41
|
+
|
42
|
+
export type WindowHapiSDKModule<
|
43
|
+
APIModule,
|
44
|
+
ServiceModule,
|
45
|
+
ValidationModule,
|
46
|
+
StateModule,
|
47
|
+
UtilsModule = any,
|
48
|
+
> = {
|
49
|
+
api?: APIModule
|
50
|
+
state?: StateModule
|
51
|
+
service?: ServiceModule
|
52
|
+
validation?: ValidationModule
|
53
|
+
utils?: UtilsModule
|
54
|
+
}
|
55
|
+
|
56
|
+
export type WindowHapiSDKAlert = WindowHapiSDKModule<
|
57
|
+
undefined,
|
58
|
+
WindowHapiServiceAlert,
|
59
|
+
undefined,
|
60
|
+
WindowHapiStateModule<AlertStoreState>
|
61
|
+
>
|
62
|
+
export type WindowHapiSDKBasket = WindowHapiSDKModule<
|
63
|
+
undefined,
|
64
|
+
WindowHapiServiceBasket,
|
65
|
+
WindowHapiValidationsBasket,
|
66
|
+
WindowHapiStateModule<BasketStoreState>,
|
67
|
+
WindowHapiUtilsBasket
|
68
|
+
>
|
69
|
+
export type WindowHapiSDKCampaign = WindowHapiSDKModule<
|
70
|
+
WindowHapiAPICampaign,
|
71
|
+
WindowHapiServiceCampaign,
|
72
|
+
WindowHapiValidationsCampaign,
|
73
|
+
WindowHapiStateModule<CampaignStoreState>,
|
74
|
+
WindowHapiUtilsCampaign
|
75
|
+
>
|
76
|
+
export type WindowHapiSDKContract = WindowHapiSDKModule<
|
77
|
+
WindowHapiAPIContract,
|
78
|
+
WindowHapiServiceContract,
|
79
|
+
WindowHapiValidationsContract,
|
80
|
+
WindowHapiStateModule<ContractStoreState>,
|
81
|
+
WindowHapiUtilsContract
|
82
|
+
>
|
83
|
+
export type WindowHapiSDKDebugging = WindowHapiSDKModule<
|
84
|
+
undefined,
|
85
|
+
undefined,
|
86
|
+
undefined,
|
87
|
+
WindowHapiStateModule<DebuggingStoreState>
|
88
|
+
>
|
89
|
+
export type WindowHapiSDKLanguage = WindowHapiSDKModule<
|
90
|
+
undefined,
|
91
|
+
undefined,
|
92
|
+
WindowHapiValidationsLanguage,
|
93
|
+
WindowHapiStateModule<LanguageStoreState>
|
94
|
+
>
|
95
|
+
export type WindowHapiSDKOrderJourney = WindowHapiSDKModule<
|
96
|
+
undefined,
|
97
|
+
undefined,
|
98
|
+
WindowHapiValidationsOrderJourney,
|
99
|
+
WindowHapiStateModule<OrderJourneyStoreState>,
|
100
|
+
WindowHapiUtilsOrderJourney
|
101
|
+
>
|
102
|
+
export type WindowHapiSDKProduct = WindowHapiSDKModule<
|
103
|
+
WindowHapiAPIProduct,
|
104
|
+
WindowHapiServiceProduct,
|
105
|
+
WindowHapiValidationsProduct,
|
106
|
+
WindowHapiStateModule<ProductStoreState>,
|
107
|
+
WindowHapiUtilsProduct
|
108
|
+
>
|
109
|
+
export type WindowHapiSDKTheming = WindowHapiSDKModule<
|
110
|
+
undefined,
|
111
|
+
undefined,
|
112
|
+
WindowHapiValidationsTheming,
|
113
|
+
WindowHapiStateModule<ThemeStoreState>
|
114
|
+
>
|
115
|
+
export type WindowHapiSDKWallet = WindowHapiSDKModule<
|
116
|
+
WindowHapiAPIWallet,
|
117
|
+
WindowHapiServiceWallet,
|
118
|
+
WindowHapiValidationsWallet,
|
119
|
+
WindowHapiStateModule<WalletStoreState>
|
120
|
+
>
|
121
|
+
export type WindowHapiSDKUI = WindowHapiSDKModule<
|
122
|
+
undefined,
|
123
|
+
WindowHapiServiceUI,
|
124
|
+
undefined,
|
125
|
+
undefined
|
126
|
+
>
|
127
|
+
export type WindowHapiSDK = ModuleWithConstructorArgs<
|
128
|
+
{
|
129
|
+
[WindowHapiModuleName.contract]: WindowHapiSDKContract
|
130
|
+
[WindowHapiModuleName.basket]: WindowHapiSDKBasket
|
131
|
+
[WindowHapiModuleName.campaign]: WindowHapiSDKCampaign
|
132
|
+
[WindowHapiModuleName.wallet]: WindowHapiSDKWallet
|
133
|
+
[WindowHapiModuleName.product]: WindowHapiSDKProduct
|
134
|
+
[WindowHapiModuleName.orderJourney]: WindowHapiSDKOrderJourney
|
135
|
+
[WindowHapiModuleName.theming]: WindowHapiSDKTheming
|
136
|
+
[WindowHapiModuleName.language]: WindowHapiSDKLanguage
|
137
|
+
[WindowHapiModuleName.debugging]: WindowHapiSDKDebugging
|
138
|
+
[WindowHapiModuleName.alert]: WindowHapiSDKAlert
|
139
|
+
},
|
140
|
+
{ readonly core: WindowHapi }
|
141
|
+
>
|
142
|
+
export type WindowHapiSDKModal = WindowHapiSDKModule<
|
143
|
+
undefined,
|
144
|
+
WindowHapiServiceModal,
|
145
|
+
undefined,
|
146
|
+
WindowHapiStateModule<ModalStoreState>
|
147
|
+
>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { WindowHapiModuleName } from "../../enums"
|
2
|
+
import { ModuleWithConstructorArgs } from "../types"
|
3
|
+
import { WindowHapiServiceAlert } from "../alert/service.types"
|
4
|
+
import { WindowHapiServiceBasket } from "../basket/service.types"
|
5
|
+
import { WindowHapiServiceCampaign } from "../campaign/service.types"
|
6
|
+
import { WindowHapiServiceContract } from "../contract/service.types"
|
7
|
+
import { WindowHapiServiceProduct } from "../product/service.types"
|
8
|
+
import { WindowHapiServiceWallet } from "../wallet/service.types"
|
9
|
+
import { WindowHapiServiceModal } from "../modal/service.types"
|
10
|
+
import { WindowHapiServiceUI } from "../ui/service.types"
|
11
|
+
import { WindowHapiServiceATS } from "../ats/service.types"
|
12
|
+
import { Logger } from "../common/logger/Logger"
|
13
|
+
import { WindowHapi } from "./window"
|
14
|
+
|
15
|
+
export type HapiServiceFunctionLifecycleHookCallbackHandler = () =>
|
16
|
+
| void
|
17
|
+
| never
|
18
|
+
| Promise<void | never>
|
19
|
+
|
20
|
+
export type HapiServiceFunctionLifecycleHookHandler = (
|
21
|
+
callback: HapiServiceFunctionLifecycleHookCallbackHandler,
|
22
|
+
) => void
|
23
|
+
|
24
|
+
export type HapiServiceFunctionWithLifecycleHooks<HandlerType> = {
|
25
|
+
run: HandlerType
|
26
|
+
onStart: HapiServiceFunctionLifecycleHookHandler
|
27
|
+
onSuccess: HapiServiceFunctionLifecycleHookHandler
|
28
|
+
onFailure: HapiServiceFunctionLifecycleHookHandler
|
29
|
+
onFinish: HapiServiceFunctionLifecycleHookHandler
|
30
|
+
}
|
31
|
+
|
32
|
+
export type HapiServiceBase = {
|
33
|
+
__serviceName: WindowHapiModuleName
|
34
|
+
logger: Logger
|
35
|
+
init: () => void
|
36
|
+
}
|
37
|
+
export type WindowHapiService = ModuleWithConstructorArgs<
|
38
|
+
{
|
39
|
+
[WindowHapiModuleName.alert]: WindowHapiServiceAlert
|
40
|
+
[WindowHapiModuleName.basket]: WindowHapiServiceBasket
|
41
|
+
[WindowHapiModuleName.campaign]: WindowHapiServiceCampaign
|
42
|
+
[WindowHapiModuleName.contract]: WindowHapiServiceContract
|
43
|
+
[WindowHapiModuleName.product]: WindowHapiServiceProduct
|
44
|
+
[WindowHapiModuleName.wallet]: WindowHapiServiceWallet
|
45
|
+
[WindowHapiModuleName.modal]: WindowHapiServiceModal
|
46
|
+
[WindowHapiModuleName.ui]: WindowHapiServiceUI
|
47
|
+
[WindowHapiModuleName.ats]: WindowHapiServiceATS
|
48
|
+
services: {
|
49
|
+
[WindowHapiModuleName.alert]: WindowHapiServiceAlert
|
50
|
+
[WindowHapiModuleName.basket]: WindowHapiServiceBasket
|
51
|
+
[WindowHapiModuleName.campaign]: WindowHapiServiceCampaign
|
52
|
+
[WindowHapiModuleName.contract]: WindowHapiServiceContract
|
53
|
+
[WindowHapiModuleName.product]: WindowHapiServiceProduct
|
54
|
+
[WindowHapiModuleName.wallet]: WindowHapiServiceWallet
|
55
|
+
[WindowHapiModuleName.modal]: WindowHapiServiceModal
|
56
|
+
[WindowHapiModuleName.ui]: WindowHapiServiceUI
|
57
|
+
[WindowHapiModuleName.ats]: WindowHapiServiceATS
|
58
|
+
}
|
59
|
+
|
60
|
+
decorateFunctionWithLifecycleEvents: <HandlerType extends Function>(
|
61
|
+
service: HapiServiceBase,
|
62
|
+
propertyName: string,
|
63
|
+
fn: HandlerType,
|
64
|
+
) => HapiServiceFunctionWithLifecycleHooks<HandlerType>
|
65
|
+
},
|
66
|
+
{ readonly core: WindowHapi }
|
67
|
+
>
|