@maestro_io/maestro-web-sdk 2.1.3 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MaestroEventDelegate.d.ts +1 -0
- package/dist/components/atoms/SvgIcon/Icon.d.ts +0 -2
- package/dist/components/core/PanelManager/PanelManager.d.ts +3 -0
- package/dist/components/core/ScrollableContainer/ScrollableContainer.d.ts +3 -1
- package/dist/external/spatial-navigation/spatialNavigation.d.ts +1 -1
- package/dist/helpers/url.d.ts +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/interfaces/IMaestroEvent.d.ts +27 -0
- package/dist/interfaces/IMaestroEventDelegate.d.ts +19 -6
- package/dist/interfaces/IMaestroManager.d.ts +8 -1
- package/dist/interfaces/IUserSettings.d.ts +36 -0
- package/dist/maestro-web-sdk.umd.js +3 -3
- package/dist/maestro-web-sdk.umd.js.map +1 -1
- package/dist/models/IPanel.d.ts +1 -2
- package/dist/modules/bets/view/BetsView.d.ts +4 -0
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.d.ts +1 -0
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.d.ts +1 -0
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.d.ts +2 -1
- package/dist/modules/bets/view/UserBets/Boost/Boost.d.ts +2 -1
- package/dist/modules/bets/view/UserBets/Parlay/Parlay.d.ts +2 -1
- package/dist/modules/bets/view/UserBets/Straight/Straight.d.ts +2 -1
- package/dist/modules/bets/view/UserBets/Teaser/Teaser.d.ts +2 -1
- package/dist/modules/bets/view/components/Bet/Bet.d.ts +7 -0
- package/dist/modules/bets/view-model/BetsViewModel.d.ts +15 -0
- package/dist/modules/key-plays/interfaces/IKeyPlays.d.ts +1 -0
- package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.d.ts +6 -6
- package/dist/modules/key-plays/view/KeyPlayCardView.d.ts +4 -1
- package/dist/modules/key-plays/view/KeyPlayErrorStateView.d.ts +2 -0
- package/dist/modules/key-plays/view-model/KeyPlaysViewModel.d.ts +5 -1
- package/dist/modules/stats/interfaces/IStats.d.ts +38 -12
- package/dist/modules/stats/mocks.d.ts +0 -80
- package/dist/modules/stats/utils/driveSummaryUtils.d.ts +18 -0
- package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.d.ts +6 -19
- package/dist/modules/stats/view/DriveSummary/DrivePlayCard.d.ts +26 -0
- package/dist/modules/stats/view/DriveSummary/DriveSummary.d.ts +24 -0
- package/dist/modules/stats/view/DriveSummary/index.d.ts +2 -0
- package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +15 -4
- package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +13 -48
- package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +10 -21
- package/dist/modules/stats/view/StatsItemView.d.ts +19 -0
- package/dist/modules/stats/view/StatsView.d.ts +3 -3
- package/dist/modules/stats/view/TeamStats/TeamStatsView.d.ts +2 -4
- package/dist/modules/stats/view/Teams/Teams.d.ts +10 -26
- package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +10 -21
- package/dist/modules/stats/view-model/StatsViewModel.d.ts +149 -5
- package/dist/services/BetsService.d.ts +2 -2
- package/dist/services/NetworkManager/NetworkManager.d.ts +1 -3
- package/dist/services/NetworkManager/NetworkManagerFactory.d.ts +42 -0
- package/dist/services/NetworkManager/types.d.ts +77 -0
- package/dist/services/StatsService.d.ts +2 -2
- package/dist/services/UserSettingsManager.d.ts +63 -0
- package/dist/view-models/MaestroEventViewModel.d.ts +5 -0
- package/dist/view-models/PanelManagerViewModel.d.ts +24 -0
- package/dist/view-models/index.d.ts +4 -0
- package/package.json +1 -1
- package/dist/MaestroEventDelegate.js +0 -60
- package/dist/components/atoms/BaseButton/BaseButton.js +0 -11
- package/dist/components/atoms/BaseButton/index.js +0 -2
- package/dist/components/atoms/Image/index.js +0 -30
- package/dist/components/atoms/Rive/index.js +0 -53
- package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +0 -9
- package/dist/components/atoms/SvgIcon/BetsIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/CollapseIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/ExpandIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/FantasyIcon.d.ts +0 -6
- package/dist/components/atoms/SvgIcon/FantasyIcon.js +0 -8
- package/dist/components/atoms/SvgIcon/FlameIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/Icon.js +0 -42
- package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +0 -10
- package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/PlayIcon.js +0 -8
- package/dist/components/atoms/SvgIcon/StatsIcon.js +0 -12
- package/dist/components/atoms/SvgIcon/TimesIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/WarningIcon.js +0 -8
- package/dist/components/atoms/SvgIcon/index.js +0 -2
- package/dist/components/core/App/App.js +0 -41
- package/dist/components/core/App/index.js +0 -2
- package/dist/components/core/OverlayContainer.js +0 -58
- package/dist/components/core/PanelManager/PanelManager.js +0 -80
- package/dist/components/core/PanelManager/index.js +0 -2
- package/dist/components/core/ScrollableContainer/FocusableItem.js +0 -38
- package/dist/components/core/ScrollableContainer/ScrollableContainer.js +0 -166
- package/dist/components/core/ScrollableContainer/index.js +0 -2
- package/dist/components/molecules/ActionButton/ActionButton.js +0 -10
- package/dist/components/molecules/ActionButton/index.js +0 -2
- package/dist/components/molecules/Overlay/Overlay.js +0 -139
- package/dist/components/molecules/Overlay/index.js +0 -2
- package/dist/components/molecules/PanelNavButton/PanelNavButton.js +0 -40
- package/dist/components/molecules/PanelNavButton/index.js +0 -2
- package/dist/components/molecules/SegmentButton/SegmentButton.js +0 -10
- package/dist/components/molecules/SegmentButton/index.js +0 -2
- package/dist/components/molecules/WatchButton/WatchButton.js +0 -15
- package/dist/components/molecules/WatchButton/index.js +0 -2
- package/dist/components/organisms/PanelNavigation/PanelNavigation.js +0 -71
- package/dist/components/organisms/PanelNavigation/index.js +0 -2
- package/dist/components/organisms/SegmentController/SegmentController.js +0 -68
- package/dist/components/organisms/SegmentController/index.js +0 -2
- package/dist/external/AxiosNetworkClient.js +0 -83
- package/dist/external/LocalStorageCacheManager.js +0 -213
- package/dist/external/ReactRenderer.js +0 -86
- package/dist/external/mocks/MockExternalNetworkClient.js +0 -161
- package/dist/external/ports/cacheManager.js +0 -1
- package/dist/external/ports/networkClient.js +0 -1
- package/dist/external/ports/renderer.js +0 -1
- package/dist/external/spatial-navigation/index.js +0 -3
- package/dist/external/spatial-navigation/measureLayout.js +0 -30
- package/dist/external/spatial-navigation/spatialNavigation.js +0 -864
- package/dist/external/spatial-navigation/utils.js +0 -6
- package/dist/external/spatial-navigation/visualDebugger.js +0 -76
- package/dist/external/spatial-navigation/withFocusable.js +0 -245
- package/dist/helpers/Observable.js +0 -37
- package/dist/helpers/deliver-focus.d.ts +0 -5
- package/dist/helpers/deliver-focus.js +0 -12
- package/dist/index.js +0 -192
- package/dist/interfaces/IMaestroEvent.js +0 -6
- package/dist/interfaces/IMaestroEventDelegate.js +0 -1
- package/dist/interfaces/IMaestroManager.js +0 -1
- package/dist/models/IModel.js +0 -1
- package/dist/models/IPanel.js +0 -53
- package/dist/models/ITheme.js +0 -20
- package/dist/models/IWinningBet.js +0 -1
- package/dist/modules/bets/interfaces/IBets.js +0 -1
- package/dist/modules/bets/mocks.js +0 -572
- package/dist/modules/bets/view/BetsView.js +0 -116
- package/dist/modules/bets/view/HotProps/HotPropsView.js +0 -139
- package/dist/modules/bets/view/SixPack/SixPackView.js +0 -103
- package/dist/modules/bets/view/TabLoadFailureView.js +0 -12
- package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +0 -6
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +0 -122
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +0 -34
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +0 -22
- package/dist/modules/bets/view/UserBets/Boost/Boost.js +0 -6
- package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +0 -9
- package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +0 -13
- package/dist/modules/bets/view/UserBets/Straight/Straight.js +0 -6
- package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +0 -13
- package/dist/modules/bets/view/UserBets/UserBetsView.js +0 -114
- package/dist/modules/bets/view/components/Bet/Bet.js +0 -32
- package/dist/modules/bets/view/components/BetPill/BetPill.js +0 -6
- package/dist/modules/bets/view/components/BetsCard/BetsCard.js +0 -15
- package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +0 -20
- package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +0 -14
- package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +0 -16
- package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +0 -63
- package/dist/modules/bets/view/components/PromoCodeBanner/index.js +0 -1
- package/dist/modules/bets/view-model/BetsViewModel.js +0 -767
- package/dist/modules/key-plays/constants.js +0 -292
- package/dist/modules/key-plays/interfaces/IKeyPlays.js +0 -14
- package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +0 -1
- package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +0 -13
- package/dist/modules/key-plays/view/KeyPlayCardView.js +0 -120
- package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +0 -58
- package/dist/modules/key-plays/view/KeyPlaysView.js +0 -166
- package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +0 -182
- package/dist/modules/stats/interfaces/IStats.js +0 -1
- package/dist/modules/stats/mocks.js +0 -686
- package/dist/modules/stats/utils/renderTeamStatistic.js +0 -16
- package/dist/modules/stats/utils.js +0 -62
- package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.js +0 -78
- package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +0 -27
- package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.js +0 -15
- package/dist/modules/stats/view/ActiveAthletes/index.js +0 -2
- package/dist/modules/stats/view/GameLeaders/GameLeaders.js +0 -9
- package/dist/modules/stats/view/GameLeaders/index.js +0 -2
- package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +0 -55
- package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +0 -1
- package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +0 -66
- package/dist/modules/stats/view/MatchPredictor/index.js +0 -2
- package/dist/modules/stats/view/RecentGames/RecentGames.js +0 -22
- package/dist/modules/stats/view/RecentGames/index.js +0 -2
- package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +0 -38
- package/dist/modules/stats/view/StatsQRCode/index.js +0 -1
- package/dist/modules/stats/view/StatsView.js +0 -107
- package/dist/modules/stats/view/TeamStats/TeamStatsView.js +0 -69
- package/dist/modules/stats/view/TeamStats/index.js +0 -1
- package/dist/modules/stats/view/Teams/StatsCarousel.js +0 -14
- package/dist/modules/stats/view/Teams/StatsProgressBar.js +0 -18
- package/dist/modules/stats/view/Teams/Teams.js +0 -42
- package/dist/modules/stats/view/Teams/index.js +0 -2
- package/dist/modules/stats/view/WinProbability/WinProbability.js +0 -27
- package/dist/modules/stats/view/WinProbability/index.js +0 -2
- package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +0 -29
- package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +0 -12
- package/dist/modules/stats/view/components/AthletesStatistics/index.js +0 -2
- package/dist/modules/stats/view/index.js +0 -2
- package/dist/modules/stats/view-model/StatsViewModel.js +0 -90
- package/dist/services/BetsService.js +0 -102
- package/dist/services/NetworkManager/NetworkManager.js +0 -410
- package/dist/services/NetworkManager/errors.js +0 -45
- package/dist/services/StatsService.js +0 -68
- package/dist/services/ThemeManager/constants.js +0 -47
- package/dist/test-polyfills.js +0 -15
- package/dist/types/OverlayTypes.js +0 -4
- package/dist/view-models/MaestroEventViewModel.js +0 -168
- package/dist/view-models/OverlayViewModel.js +0 -222
- package/dist/view-models/PanelManagerViewModel.js +0 -80
- package/dist/view-models/ViewModel.js +0 -32
- package/dist/view-models/index.js +0 -59
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import AxiosNetworkClient from '../../external/AxiosNetworkClient';
|
|
2
|
-
import LocalStorageCacheManager from '../../external/LocalStorageCacheManager';
|
|
3
|
-
import { AuthError, BadRequestError, NetworkError, NotFoundError, ServerError, } from './errors';
|
|
4
|
-
// Environment configuration
|
|
5
|
-
export const WorkingEnvironment = {
|
|
6
|
-
DEVELOPMENT: 'development',
|
|
7
|
-
STAGING: 'staging',
|
|
8
|
-
PRODUCTION: 'production',
|
|
9
|
-
};
|
|
10
|
-
// URL configurations based on environment
|
|
11
|
-
export const MAESTRO_BASE_URLS = {
|
|
12
|
-
[WorkingEnvironment.DEVELOPMENT]: 'https://dev.api.maestro.io',
|
|
13
|
-
[WorkingEnvironment.STAGING]: 'https://api.us-central1-staging.gcp.maestro.io',
|
|
14
|
-
[WorkingEnvironment.PRODUCTION]: 'https://api.maestro.io',
|
|
15
|
-
};
|
|
16
|
-
export const SDK_FLAVOR = 'MaestroKit_Web';
|
|
17
|
-
// Common endpoints
|
|
18
|
-
export const ENDPOINTS = {
|
|
19
|
-
CAN_I_PLAY: '/caniplay/v1',
|
|
20
|
-
STREAM: '/stream/v1',
|
|
21
|
-
USER_PROFILE: '/userprofile/v1',
|
|
22
|
-
ACTIVE_USER: '/active/v2',
|
|
23
|
-
// Add more endpoints as needed
|
|
24
|
-
};
|
|
25
|
-
// HTTP methods
|
|
26
|
-
export const HttpMethod = {
|
|
27
|
-
GET: 'GET',
|
|
28
|
-
POST: 'POST',
|
|
29
|
-
PUT: 'PUT',
|
|
30
|
-
DELETE: 'DELETE',
|
|
31
|
-
};
|
|
32
|
-
class NetworkManager {
|
|
33
|
-
constructor(options = {}, localStorageOverride) {
|
|
34
|
-
Object.defineProperty(this, "cacheManager", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: void 0
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(this, "maestroClient", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true,
|
|
44
|
-
value: void 0
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(this, "externalClient", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: void 0
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(this, "environment", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true,
|
|
56
|
-
value: void 0
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(this, "pollingTasks", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
configurable: true,
|
|
61
|
-
writable: true,
|
|
62
|
-
value: void 0
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(this, "localStorage", {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
configurable: true,
|
|
67
|
-
writable: true,
|
|
68
|
-
value: void 0
|
|
69
|
-
});
|
|
70
|
-
this.environment = options.environment || WorkingEnvironment.PRODUCTION;
|
|
71
|
-
this.pollingTasks = new Map();
|
|
72
|
-
// Initialize cache manager
|
|
73
|
-
this.cacheManager =
|
|
74
|
-
options.cacheManager ||
|
|
75
|
-
new LocalStorageCacheManager(options.defaultCacheDuration);
|
|
76
|
-
// Initialize Maestro API client
|
|
77
|
-
this.maestroClient =
|
|
78
|
-
options.networkClient ||
|
|
79
|
-
new AxiosNetworkClient({
|
|
80
|
-
baseURL: MAESTRO_BASE_URLS[this.environment],
|
|
81
|
-
retries: 3,
|
|
82
|
-
delay: 1000,
|
|
83
|
-
backoff: 2,
|
|
84
|
-
});
|
|
85
|
-
// Initialize External API client
|
|
86
|
-
this.externalClient =
|
|
87
|
-
options.externalNetworkClient ||
|
|
88
|
-
new AxiosNetworkClient({
|
|
89
|
-
baseURL: options.externalBaseURL || '',
|
|
90
|
-
retries: 3,
|
|
91
|
-
delay: 1000,
|
|
92
|
-
backoff: 2,
|
|
93
|
-
});
|
|
94
|
-
this.localStorage = localStorageOverride ||
|
|
95
|
-
(typeof globalThis !== 'undefined' && globalThis.localStorage) || {
|
|
96
|
-
length: 0,
|
|
97
|
-
clear: () => { },
|
|
98
|
-
getItem: () => null,
|
|
99
|
-
key: () => null,
|
|
100
|
-
removeItem: () => { },
|
|
101
|
-
setItem: () => { },
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
static getInstance(options, localStorageOverride) {
|
|
105
|
-
if (!this.instance) {
|
|
106
|
-
this.instance = new NetworkManager(options, localStorageOverride);
|
|
107
|
-
}
|
|
108
|
-
else if (options) {
|
|
109
|
-
// Update environment if provided
|
|
110
|
-
if (options.environment) {
|
|
111
|
-
this.instance.setEnvironment(options.environment);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return this.instance;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Sets the working environment (development, staging, production)
|
|
118
|
-
*/
|
|
119
|
-
setEnvironment(environment) {
|
|
120
|
-
this.environment = environment;
|
|
121
|
-
// Update base URLs for clients if they have a client property
|
|
122
|
-
// This is needed for testing and for real clients
|
|
123
|
-
try {
|
|
124
|
-
if (this.maestroClient.client?.defaults) {
|
|
125
|
-
this.maestroClient.client.defaults.baseURL =
|
|
126
|
-
MAESTRO_BASE_URLS[environment];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
throw new Error(`Failed to update client base URLs: ${error}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Get current environment
|
|
135
|
-
*/
|
|
136
|
-
getEnvironment() {
|
|
137
|
-
return this.environment;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Set authentication for Maestro APIs
|
|
141
|
-
*/
|
|
142
|
-
setAuthentication(token, apiKey) {
|
|
143
|
-
this.maestroClient.setAuthentication(token, apiKey);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Handle errors from network requests
|
|
147
|
-
*/
|
|
148
|
-
handleError(error) {
|
|
149
|
-
// Check if it's an Axios error with a response
|
|
150
|
-
if (error.response) {
|
|
151
|
-
const status = error.response.status;
|
|
152
|
-
const message = error.response.data?.message || error.message;
|
|
153
|
-
if (status === 401 || status === 403) {
|
|
154
|
-
throw new AuthError(message);
|
|
155
|
-
}
|
|
156
|
-
else if (status === 404) {
|
|
157
|
-
throw new NotFoundError(message);
|
|
158
|
-
}
|
|
159
|
-
else if (status >= 500) {
|
|
160
|
-
throw new ServerError(status, message);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
throw new BadRequestError(status, message);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else if (error.request) {
|
|
167
|
-
// Request was made but no response received
|
|
168
|
-
throw new NetworkError('Network request failed');
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
// Something else happened while setting up the request
|
|
172
|
-
throw error;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Make a request to the Maestro API
|
|
177
|
-
*/
|
|
178
|
-
async maestroApiRequest({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, maestroDefaultHeaders = null, skipResponseBodyDeserialization = false, }) {
|
|
179
|
-
// Add SDK flavor to headers
|
|
180
|
-
const requestHeaders = {
|
|
181
|
-
'x-maestro-maestro-kit-flavor': SDK_FLAVOR,
|
|
182
|
-
...headers,
|
|
183
|
-
};
|
|
184
|
-
// Add Maestro default headers if provided
|
|
185
|
-
if (maestroDefaultHeaders) {
|
|
186
|
-
requestHeaders['x-maestro-client-id'] = maestroDefaultHeaders.siteId;
|
|
187
|
-
requestHeaders['Authorization'] = `Bearer ${maestroDefaultHeaders.jwt}`;
|
|
188
|
-
requestHeaders['Content-type'] = 'application/json';
|
|
189
|
-
}
|
|
190
|
-
// Check cache if using GET and cache is enabled
|
|
191
|
-
if (method === HttpMethod.GET && useCache) {
|
|
192
|
-
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
193
|
-
endpoint,
|
|
194
|
-
params,
|
|
195
|
-
data: null,
|
|
196
|
-
}));
|
|
197
|
-
const cachedData = this.cacheManager.getCache(cacheKey);
|
|
198
|
-
if (cachedData) {
|
|
199
|
-
return cachedData;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
try {
|
|
203
|
-
let response;
|
|
204
|
-
if (method === HttpMethod.GET) {
|
|
205
|
-
response = await this.maestroClient.get(endpoint, params, requestHeaders);
|
|
206
|
-
}
|
|
207
|
-
else if (method === HttpMethod.POST) {
|
|
208
|
-
response = await this.maestroClient.post(endpoint, data);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
throw new Error(`Method ${method} not implemented`);
|
|
212
|
-
}
|
|
213
|
-
// Handle empty response if needed
|
|
214
|
-
if (skipResponseBodyDeserialization && !response) {
|
|
215
|
-
response = {};
|
|
216
|
-
}
|
|
217
|
-
// Cache the response for GET requests
|
|
218
|
-
if (method === HttpMethod.GET && useCache) {
|
|
219
|
-
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
220
|
-
endpoint,
|
|
221
|
-
params,
|
|
222
|
-
data: null,
|
|
223
|
-
}));
|
|
224
|
-
this.cacheManager.setCache(cacheKey, response);
|
|
225
|
-
}
|
|
226
|
-
return response;
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
return this.handleError(error);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Make a request to an external API
|
|
234
|
-
*/
|
|
235
|
-
async externalApiRequest({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, skipResponseBodyDeserialization = false, }) {
|
|
236
|
-
// Check cache if using GET and cache is enabled
|
|
237
|
-
if (method === HttpMethod.GET && useCache) {
|
|
238
|
-
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
239
|
-
endpoint,
|
|
240
|
-
params,
|
|
241
|
-
data: null,
|
|
242
|
-
}));
|
|
243
|
-
const cachedData = this.cacheManager.getCache(cacheKey);
|
|
244
|
-
if (cachedData) {
|
|
245
|
-
return cachedData;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
try {
|
|
249
|
-
let response;
|
|
250
|
-
if (method === HttpMethod.GET) {
|
|
251
|
-
response = await this.externalClient.get(endpoint, params, headers);
|
|
252
|
-
}
|
|
253
|
-
else if (method === HttpMethod.POST) {
|
|
254
|
-
response = await this.externalClient.post(endpoint, data);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
throw new Error(`Method ${method} not implemented`);
|
|
258
|
-
}
|
|
259
|
-
// Handle empty response if needed
|
|
260
|
-
if (skipResponseBodyDeserialization && !response) {
|
|
261
|
-
response = {};
|
|
262
|
-
}
|
|
263
|
-
// Cache the response for GET requests
|
|
264
|
-
if (method === HttpMethod.GET && useCache) {
|
|
265
|
-
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
266
|
-
endpoint,
|
|
267
|
-
params,
|
|
268
|
-
data: null,
|
|
269
|
-
}));
|
|
270
|
-
this.cacheManager.setCache(cacheKey, response);
|
|
271
|
-
}
|
|
272
|
-
return response;
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
return this.handleError(error);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Start polling a Maestro API endpoint at specified interval
|
|
280
|
-
*/
|
|
281
|
-
pollMaestroApiRequest({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, maestroDefaultHeaders = null, skipResponseBodyDeserialization = false, onData, onError, }) {
|
|
282
|
-
// Create a unique key for this polling task
|
|
283
|
-
const taskKey = `${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
|
|
284
|
-
// Stop existing polling for this endpoint if it exists
|
|
285
|
-
if (this.pollingTasks.has(taskKey)) {
|
|
286
|
-
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
287
|
-
this.pollingTasks.delete(taskKey);
|
|
288
|
-
}
|
|
289
|
-
// Create a new abort controller for cancellation
|
|
290
|
-
const controller = new AbortController();
|
|
291
|
-
const signal = controller.signal;
|
|
292
|
-
// Start the polling
|
|
293
|
-
(async () => {
|
|
294
|
-
while (!signal.aborted) {
|
|
295
|
-
try {
|
|
296
|
-
const response = await this.maestroApiRequest({
|
|
297
|
-
endpoint,
|
|
298
|
-
method,
|
|
299
|
-
params,
|
|
300
|
-
data,
|
|
301
|
-
headers,
|
|
302
|
-
maestroDefaultHeaders,
|
|
303
|
-
skipResponseBodyDeserialization,
|
|
304
|
-
useCache: false, // Don't use cache for polling
|
|
305
|
-
});
|
|
306
|
-
// Call the callback with the data
|
|
307
|
-
onData(response);
|
|
308
|
-
}
|
|
309
|
-
catch (error) {
|
|
310
|
-
// Call the error callback if provided
|
|
311
|
-
if (onError) {
|
|
312
|
-
onError(error);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
// Wait for the interval before next poll
|
|
316
|
-
if (!signal.aborted) {
|
|
317
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
})();
|
|
321
|
-
// Store the controller for later cancellation
|
|
322
|
-
this.pollingTasks.set(taskKey, { controller, interval });
|
|
323
|
-
// Return a function to stop polling
|
|
324
|
-
return {
|
|
325
|
-
stop: () => {
|
|
326
|
-
if (this.pollingTasks.has(taskKey)) {
|
|
327
|
-
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
328
|
-
this.pollingTasks.delete(taskKey);
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Start polling an external API endpoint at specified interval
|
|
335
|
-
*/
|
|
336
|
-
pollExternalApiRequest({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, skipResponseBodyDeserialization = false, onData, onError, }) {
|
|
337
|
-
// Create a unique key for this polling task
|
|
338
|
-
const taskKey = `external-${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
|
|
339
|
-
// Stop existing polling for this endpoint if it exists
|
|
340
|
-
if (this.pollingTasks.has(taskKey)) {
|
|
341
|
-
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
342
|
-
this.pollingTasks.delete(taskKey);
|
|
343
|
-
}
|
|
344
|
-
// Create a new abort controller for cancellation
|
|
345
|
-
const controller = new AbortController();
|
|
346
|
-
const signal = controller.signal;
|
|
347
|
-
// Start the polling
|
|
348
|
-
(async () => {
|
|
349
|
-
while (!signal.aborted) {
|
|
350
|
-
try {
|
|
351
|
-
const response = await this.externalApiRequest({
|
|
352
|
-
endpoint,
|
|
353
|
-
method,
|
|
354
|
-
params,
|
|
355
|
-
data,
|
|
356
|
-
headers,
|
|
357
|
-
skipResponseBodyDeserialization,
|
|
358
|
-
useCache: false, // Don't use cache for polling
|
|
359
|
-
});
|
|
360
|
-
// Call the callback with the data
|
|
361
|
-
onData(response);
|
|
362
|
-
}
|
|
363
|
-
catch (error) {
|
|
364
|
-
// Call the error callback if provided
|
|
365
|
-
if (onError) {
|
|
366
|
-
onError(error);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
// Wait for the interval before next poll
|
|
370
|
-
if (!signal.aborted) {
|
|
371
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
})();
|
|
375
|
-
// Store the controller for later cancellation
|
|
376
|
-
this.pollingTasks.set(taskKey, { controller, interval });
|
|
377
|
-
// Return a function to stop polling
|
|
378
|
-
return {
|
|
379
|
-
stop: () => {
|
|
380
|
-
if (this.pollingTasks.has(taskKey)) {
|
|
381
|
-
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
382
|
-
this.pollingTasks.delete(taskKey);
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Stop all polling tasks
|
|
389
|
-
*/
|
|
390
|
-
stopAllPolling() {
|
|
391
|
-
for (const [key, { controller }] of this.pollingTasks.entries()) {
|
|
392
|
-
controller.abort();
|
|
393
|
-
this.pollingTasks.delete(key);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Clear all cached data
|
|
398
|
-
*/
|
|
399
|
-
clearAllCache() {
|
|
400
|
-
const originalLength = this.localStorage.length;
|
|
401
|
-
for (let i = 0; i < originalLength; i++) {
|
|
402
|
-
const key = this.localStorage.key(i);
|
|
403
|
-
if (key && key.startsWith('maestro-cache-')) {
|
|
404
|
-
this.localStorage.removeItem(key);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
// Export singleton instance as default
|
|
410
|
-
export default NetworkManager;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Network error types
|
|
2
|
-
export class NetworkError extends Error {
|
|
3
|
-
constructor(message) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.name = 'NetworkError';
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export class AuthError extends Error {
|
|
9
|
-
constructor(message) {
|
|
10
|
-
super(message);
|
|
11
|
-
this.name = 'AuthError';
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export class NotFoundError extends Error {
|
|
15
|
-
constructor(message) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = 'NotFoundError';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export class ServerError extends Error {
|
|
21
|
-
constructor(statusCode, message) {
|
|
22
|
-
super(message);
|
|
23
|
-
Object.defineProperty(this, "statusCode", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: void 0
|
|
28
|
-
});
|
|
29
|
-
this.name = 'ServerError';
|
|
30
|
-
this.statusCode = statusCode;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export class BadRequestError extends Error {
|
|
34
|
-
constructor(statusCode, message) {
|
|
35
|
-
super(message);
|
|
36
|
-
Object.defineProperty(this, "statusCode", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
this.name = 'BadRequestError';
|
|
43
|
-
this.statusCode = statusCode;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import NetworkManager, { HttpMethod } from './NetworkManager/NetworkManager';
|
|
2
|
-
/**
|
|
3
|
-
* Service for handling stats-related API calls
|
|
4
|
-
*/
|
|
5
|
-
class StatsService {
|
|
6
|
-
constructor(delegate) {
|
|
7
|
-
Object.defineProperty(this, "networkManager", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: void 0
|
|
12
|
-
});
|
|
13
|
-
this.networkManager = NetworkManager.getInstance({
|
|
14
|
-
externalBaseURL: delegate.getBettingAPIBaseURL(),
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get stats for an event
|
|
19
|
-
*
|
|
20
|
-
* @param eventID - The ID of the event
|
|
21
|
-
* @param gameState - Optional game state filter (e.g., 'pre', 'in', 'post')
|
|
22
|
-
* @returns Promise with the stats data
|
|
23
|
-
*/
|
|
24
|
-
async getStats(eventID, gameState) {
|
|
25
|
-
const params = {};
|
|
26
|
-
if (gameState) {
|
|
27
|
-
params.gameState = gameState;
|
|
28
|
-
}
|
|
29
|
-
return this.networkManager.externalApiRequest({
|
|
30
|
-
endpoint: this.statsEndpoint(eventID),
|
|
31
|
-
method: HttpMethod.GET,
|
|
32
|
-
params,
|
|
33
|
-
headers: {},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Start polling for stats
|
|
38
|
-
*
|
|
39
|
-
* @param eventID - The ID of the event
|
|
40
|
-
* @param gameState - Optional game state filter (e.g., 'pre', 'in', 'post')
|
|
41
|
-
* @param interval - The polling interval in milliseconds
|
|
42
|
-
* @param onData - Callback for successful data fetch
|
|
43
|
-
* @param onError - Callback for errors
|
|
44
|
-
* @returns Object with a stop function to stop polling
|
|
45
|
-
*/
|
|
46
|
-
pollStats(eventID, gameState, interval, onData, onError) {
|
|
47
|
-
const params = {};
|
|
48
|
-
if (gameState) {
|
|
49
|
-
params.gameState = gameState;
|
|
50
|
-
}
|
|
51
|
-
return this.networkManager.pollExternalApiRequest({
|
|
52
|
-
endpoint: this.statsEndpoint(eventID),
|
|
53
|
-
interval,
|
|
54
|
-
method: HttpMethod.GET,
|
|
55
|
-
params,
|
|
56
|
-
headers: {},
|
|
57
|
-
onData,
|
|
58
|
-
onError,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get the endpoint for stats
|
|
63
|
-
*/
|
|
64
|
-
statsEndpoint(eventID) {
|
|
65
|
-
return `/v4/events/${eventID}/stats`;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
export default StatsService;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { BORDER_RADIUS, TEXT_CAPITALIZATION, THEME_MODES, THEME_TYPES, } from '@/models/ITheme';
|
|
2
|
-
const FONT_FAMILY = 'BentonSans-Medium';
|
|
3
|
-
export const DARK_THEME = {
|
|
4
|
-
_id: '6274067af74b66a544018dac',
|
|
5
|
-
button: {
|
|
6
|
-
borderRadius: BORDER_RADIUS.rounded,
|
|
7
|
-
textCapitalization: TEXT_CAPITALIZATION.uppercase,
|
|
8
|
-
},
|
|
9
|
-
colors: {
|
|
10
|
-
// Accent colors
|
|
11
|
-
accentPrimary: '#FFFFFF',
|
|
12
|
-
// Secondary accent colors
|
|
13
|
-
accentSecondary: '#3C3F47',
|
|
14
|
-
// Tertiary accent colors
|
|
15
|
-
accentTertiary: '#0C0C0E',
|
|
16
|
-
// Surface Colors
|
|
17
|
-
surface1: '#080A0C',
|
|
18
|
-
surface2: '#12141A',
|
|
19
|
-
surface3: '#1B1E26',
|
|
20
|
-
surface4: '#242833',
|
|
21
|
-
surface5: '#363C4D',
|
|
22
|
-
surface6: '#3E4759',
|
|
23
|
-
// Highlight colors
|
|
24
|
-
highlightPrimary: '#FFFFFF',
|
|
25
|
-
highlightSecondary: '#9A9EA9',
|
|
26
|
-
highlightTertiary: '#0A0C0F',
|
|
27
|
-
// Alert colors
|
|
28
|
-
alertConfirmation: '#43D48F',
|
|
29
|
-
alertWarning: '#F58B00',
|
|
30
|
-
alertError: '#FF0000',
|
|
31
|
-
// Text colors
|
|
32
|
-
text100: '#F8F9FA',
|
|
33
|
-
text200: '#C2C5CB',
|
|
34
|
-
text300: '#8D919D',
|
|
35
|
-
text400: '#5C606B',
|
|
36
|
-
text500: '#0C0C0E',
|
|
37
|
-
},
|
|
38
|
-
creator: '016901e60000000000000000',
|
|
39
|
-
name: 'Dark Mode',
|
|
40
|
-
type: THEME_TYPES.CLASSIC,
|
|
41
|
-
mode: THEME_MODES.DARK,
|
|
42
|
-
owner: '016901e60000000000000000',
|
|
43
|
-
typography: {
|
|
44
|
-
body: FONT_FAMILY,
|
|
45
|
-
headline: FONT_FAMILY,
|
|
46
|
-
},
|
|
47
|
-
};
|
package/dist/test-polyfills.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// This file must be the first import in test files
|
|
2
|
-
// Handle globalThis for Node.js < 12
|
|
3
|
-
if (typeof globalThis === 'undefined') {
|
|
4
|
-
global.globalThis = global;
|
|
5
|
-
}
|
|
6
|
-
// Polyfill for FinalizationRegistry in Node.js < 14.6.0
|
|
7
|
-
const globalWithFR = globalThis;
|
|
8
|
-
if (typeof globalWithFR.FinalizationRegistry === 'undefined') {
|
|
9
|
-
globalWithFR.FinalizationRegistry = class FinalizationRegistry {
|
|
10
|
-
constructor(_callback) { }
|
|
11
|
-
register(_target, _heldValue, _unregisterToken) { }
|
|
12
|
-
unregister(_unregisterToken) { }
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export {};
|