@vizbeetv/homesso-sdk-qa 1.0.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/README.md +319 -0
- package/es5/index.cjs +1821 -0
- package/es5/index.mjs +1811 -0
- package/es6/index.cjs +1722 -0
- package/es6/index.mjs +1712 -0
- package/package.json +36 -0
- package/types/VizbeeHomeSSOManager.d.ts +186 -0
- package/types/VizbeeSignInStatusCallback.d.ts +34 -0
- package/types/index.d.ts +63 -0
- package/types/metrics/IVizbeeAttributesProvider.d.ts +3 -0
- package/types/metrics/VizbeeMetricsConstants.d.ts +27 -0
- package/types/metrics/VizbeeMetricsManager.d.ts +15 -0
- package/types/model/VizbeeSenderSignInInfo.d.ts +20 -0
- package/types/model/VizbeeSignInInfo.d.ts +11 -0
- package/types/model/VizbeeSignInStatus.d.ts +31 -0
- package/types/types.d.ts +77 -0
- package/types/ui/VizbeeHomeSSOUIConfig.d.ts +156 -0
- package/types/ui/VizbeeHomeSSOUIManager.d.ts +105 -0
- package/types/ui/VizbeeSnackBar.d.ts +100 -0
- package/types/utils/Logger.d.ts +208 -0
- package/types/utils/constants.d.ts +27 -0
- package/types/utils/http-client.d.ts +114 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Manages UI configuration for Vizbee Home SSO implementation
|
|
3
|
+
* Handles theme customization and modal preferences for different sign-in states
|
|
4
|
+
*/
|
|
5
|
+
import { CommonModalPreferenceOptions, InformationalSignInPreferenceOptions, ProgressSignInPreferenceOptions, SuccessSignInPreferenceOptions, VizbeeHomeSSOTheme } from './VizbeeHomeSSOUIConfig';
|
|
6
|
+
/**
|
|
7
|
+
* Singleton class responsible for managing UI configurations for Home SSO experience
|
|
8
|
+
* Handles theme customization and specific modal configurations for different sign-in states
|
|
9
|
+
*/
|
|
10
|
+
export declare class VizbeeHomeSSOUIManager {
|
|
11
|
+
private static instance;
|
|
12
|
+
private themeConfig;
|
|
13
|
+
private commonModalConfig;
|
|
14
|
+
private informationalModalConfig;
|
|
15
|
+
private progressModalConfig;
|
|
16
|
+
private successModalConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Private constructor to enforce singleton pattern
|
|
19
|
+
* Initializes configurations with default values using deep merge
|
|
20
|
+
*/
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Gets the singleton instance of VizbeeHomeSSOUIManager
|
|
24
|
+
* Creates a new instance if one doesn't exist
|
|
25
|
+
* @returns The singleton instance of VizbeeHomeSSOUIManager
|
|
26
|
+
*/
|
|
27
|
+
static getInstance(): VizbeeHomeSSOUIManager;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a deep clone of an object or array
|
|
30
|
+
* @param obj - Object to clone
|
|
31
|
+
* @returns Deep cloned copy of the input
|
|
32
|
+
*/
|
|
33
|
+
private deepClone;
|
|
34
|
+
private fallbackDeepClone;
|
|
35
|
+
/**
|
|
36
|
+
* Performs a deep merge of multiple objects
|
|
37
|
+
* @param target - Base object to merge into
|
|
38
|
+
* @param sources - Array of objects to merge from
|
|
39
|
+
* @returns Merged object combining all sources into target
|
|
40
|
+
*/
|
|
41
|
+
private deepMerge;
|
|
42
|
+
/**
|
|
43
|
+
* Maps theme configuration to modal configuration properties
|
|
44
|
+
* @param theme - Current theme configuration
|
|
45
|
+
* @returns Partial modal configuration based on theme
|
|
46
|
+
*/
|
|
47
|
+
private mapThemeToModalConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Returns default configurations for all modal types
|
|
50
|
+
* @returns Object containing default configs for informational, progress, and success modals
|
|
51
|
+
*/
|
|
52
|
+
getDefaultConfig(): {
|
|
53
|
+
informational: InformationalSignInPreferenceOptions;
|
|
54
|
+
progress: ProgressSignInPreferenceOptions;
|
|
55
|
+
success: SuccessSignInPreferenceOptions;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Updates the current theme configuration
|
|
59
|
+
* @param theme - Partial theme configuration to merge with current theme
|
|
60
|
+
*/
|
|
61
|
+
setTheme(theme: Partial<VizbeeHomeSSOTheme>): void;
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves current theme configuration
|
|
64
|
+
* @returns Deep clone of current theme configuration
|
|
65
|
+
*/
|
|
66
|
+
getTheme(): VizbeeHomeSSOTheme;
|
|
67
|
+
/**
|
|
68
|
+
* Updates common modal configuration applied to all modal types
|
|
69
|
+
* @param config - Partial configuration to merge with current common config
|
|
70
|
+
*/
|
|
71
|
+
setCommonModalConfig(config: Partial<CommonModalPreferenceOptions>): void;
|
|
72
|
+
/**
|
|
73
|
+
* Updates informational sign-in modal configuration
|
|
74
|
+
* @param config - Partial configuration to merge with current informational config
|
|
75
|
+
*/
|
|
76
|
+
setInformationalSignInModalConfig(config: Partial<InformationalSignInPreferenceOptions>): void;
|
|
77
|
+
/**
|
|
78
|
+
* Updates progress sign-in modal configuration
|
|
79
|
+
* @param config - Partial configuration to merge with current progress config
|
|
80
|
+
*/
|
|
81
|
+
setProgressSignInModalConfig(config: Partial<ProgressSignInPreferenceOptions>): void;
|
|
82
|
+
/**
|
|
83
|
+
* Updates success sign-in modal configuration
|
|
84
|
+
* @param config - Partial configuration to merge with current success config
|
|
85
|
+
*/
|
|
86
|
+
setSuccessSignInModalConfig(config: Partial<SuccessSignInPreferenceOptions>): void;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves complete configuration for informational sign-in modal
|
|
89
|
+
* Combines default, theme-based, common, and specific configurations
|
|
90
|
+
* @returns Complete informational modal configuration
|
|
91
|
+
*/
|
|
92
|
+
getInformationalSignInModalConfig(): InformationalSignInPreferenceOptions;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves complete configuration for progress sign-in modal
|
|
95
|
+
* Combines default, theme-based, common, and specific configurations
|
|
96
|
+
* @returns Complete progress modal configuration
|
|
97
|
+
*/
|
|
98
|
+
getProgressSignInModalConfig(): ProgressSignInPreferenceOptions;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieves complete configuration for success sign-in modal
|
|
101
|
+
* Combines default, theme-based, common, and specific configurations
|
|
102
|
+
* @returns Complete success modal configuration
|
|
103
|
+
*/
|
|
104
|
+
getSuccessSignInModalConfig(): SuccessSignInPreferenceOptions;
|
|
105
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview A customizable snackbar component that displays messages with icons and animations.
|
|
3
|
+
* Supports multiple positions, animations, and responsive design based on screen size.
|
|
4
|
+
* Integrates with VizbeeHomeSSOUIManager for consistent theming and styling.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Available positions for the snackbar on the screen
|
|
8
|
+
* Supports all four corners of the viewport
|
|
9
|
+
*/
|
|
10
|
+
export type SnackbarPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
|
11
|
+
/**
|
|
12
|
+
* Reading/layout direction for the snackbar content.
|
|
13
|
+
* `'ltr'` (default) renders left-to-right with the icon leading on the left;
|
|
14
|
+
* `'rtl'` mirrors the layout for right-to-left locales — the icon moves to the
|
|
15
|
+
* trailing (right) side and text is right-aligned.
|
|
16
|
+
*/
|
|
17
|
+
export type ModalDirection = 'ltr' | 'rtl';
|
|
18
|
+
/**
|
|
19
|
+
* Configuration options for displaying a snackbar
|
|
20
|
+
*/
|
|
21
|
+
export interface SnackbarOptions {
|
|
22
|
+
direction?: ModalDirection;
|
|
23
|
+
width?: string;
|
|
24
|
+
height?: string;
|
|
25
|
+
minHeight?: string;
|
|
26
|
+
padding?: string;
|
|
27
|
+
borderRadius?: string;
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
edgeMargin?: string;
|
|
30
|
+
marginTop?: string;
|
|
31
|
+
marginRight?: string;
|
|
32
|
+
marginBottom?: string;
|
|
33
|
+
marginLeft?: string;
|
|
34
|
+
borderColor?: string;
|
|
35
|
+
borderWidth?: string;
|
|
36
|
+
boxShadow?: string;
|
|
37
|
+
iconBase64String?: string;
|
|
38
|
+
iconBase64Strings?: string[];
|
|
39
|
+
iconWidth?: string;
|
|
40
|
+
iconHeight?: string;
|
|
41
|
+
iconMarginRight?: string;
|
|
42
|
+
titleText?: string;
|
|
43
|
+
titleTextFontFamily?: string;
|
|
44
|
+
titleTextFontColor?: string;
|
|
45
|
+
titleTextFontSize?: string;
|
|
46
|
+
titleTextFontWeight?: string;
|
|
47
|
+
titleTextLineHeight?: string;
|
|
48
|
+
titleMarginBottom?: string;
|
|
49
|
+
descriptionText: string;
|
|
50
|
+
descriptionTextFontFamily?: string;
|
|
51
|
+
descriptionTextFontColor?: string;
|
|
52
|
+
descriptionTextFontSize?: string;
|
|
53
|
+
descriptionTextFontWeight?: string;
|
|
54
|
+
descriptionTextLineHeight?: string;
|
|
55
|
+
duration?: number;
|
|
56
|
+
position: SnackbarPosition;
|
|
57
|
+
shouldAnimateIcon?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A class that manages the display of snackbar notifications with customizable styling and animations
|
|
61
|
+
*/
|
|
62
|
+
export declare class VizbeeSnackbar {
|
|
63
|
+
private container;
|
|
64
|
+
private timeoutId?;
|
|
65
|
+
private showSnackbarTimerId?;
|
|
66
|
+
private currentSnackbar?;
|
|
67
|
+
private animationInterval?;
|
|
68
|
+
private currentIconElement?;
|
|
69
|
+
private readonly uiManager;
|
|
70
|
+
private readonly BASE_DIMENSIONS;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new instance of VizbeeSnackbar
|
|
73
|
+
*/
|
|
74
|
+
constructor();
|
|
75
|
+
/**
|
|
76
|
+
* Shows the snackbar with the specified options
|
|
77
|
+
*/
|
|
78
|
+
show(options: SnackbarOptions): void;
|
|
79
|
+
/**
|
|
80
|
+
* Hides the currently displayed snackbar
|
|
81
|
+
*/
|
|
82
|
+
hide(): void;
|
|
83
|
+
private getScreenScale;
|
|
84
|
+
private scaleValue;
|
|
85
|
+
private setupContainer;
|
|
86
|
+
private getSlideTransform;
|
|
87
|
+
private getPositionStyles;
|
|
88
|
+
private startIconAnimation;
|
|
89
|
+
private stopIconAnimation;
|
|
90
|
+
/**
|
|
91
|
+
* Whether the snackbar should render right-to-left.
|
|
92
|
+
* Defaults to LTR when no direction is provided.
|
|
93
|
+
*/
|
|
94
|
+
private isRtl;
|
|
95
|
+
private createSnackbar;
|
|
96
|
+
private getSnackbarStyles;
|
|
97
|
+
private createContentWrapper;
|
|
98
|
+
private createIconWrapper;
|
|
99
|
+
private createTextWrapper;
|
|
100
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger
|
|
3
|
+
* A flexible logging system for TypeScript SDK with
|
|
4
|
+
* enable/disable capabilities and different log levels.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Multiple severity levels from ERROR to TRACE
|
|
8
|
+
* - Colored console output with timestamps
|
|
9
|
+
* - Local storage persistence with size management
|
|
10
|
+
* - Environment-aware execution (handles environments without localStorage)
|
|
11
|
+
* - Export and clearing capabilities
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Defines logging severity levels in ascending order of verbosity.
|
|
15
|
+
* Lower values indicate higher severity. This hierarchy ensures
|
|
16
|
+
* that when a specific level is set, all logs of that level and
|
|
17
|
+
* higher severity (lower enum value) will be captured.
|
|
18
|
+
*/
|
|
19
|
+
export declare enum LogLevel {
|
|
20
|
+
/** Critical application errors that prevent proper functioning */
|
|
21
|
+
ERROR = 0,
|
|
22
|
+
/** Important issues that don't stop execution but require attention */
|
|
23
|
+
WARN = 1,
|
|
24
|
+
/** General operational information about system behavior */
|
|
25
|
+
INFO = 2,
|
|
26
|
+
/** Detailed diagnostic information for troubleshooting */
|
|
27
|
+
DEBUG = 3,
|
|
28
|
+
/** Extremely verbose execution flow information */
|
|
29
|
+
TRACE = 4
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Configuration interface for customizing logger behavior.
|
|
33
|
+
* All settings can be modified at runtime through the setConfig method.
|
|
34
|
+
*/
|
|
35
|
+
export interface LoggerConfig {
|
|
36
|
+
/** Master switch to enable/disable all logging activity */
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
/** Minimum severity threshold for capturing logs */
|
|
39
|
+
level: LogLevel;
|
|
40
|
+
/** Whether to include ISO timestamps in log messages */
|
|
41
|
+
useTimestamp: boolean;
|
|
42
|
+
/** Whether to apply color styling to console output when supported */
|
|
43
|
+
useColors: boolean;
|
|
44
|
+
/** Whether to output logs to the console */
|
|
45
|
+
logToConsole: boolean;
|
|
46
|
+
/** Whether to persist logs to localStorage (when available) */
|
|
47
|
+
logToStorage?: boolean;
|
|
48
|
+
/** Maximum number of entries to keep in storage (oldest removed first) */
|
|
49
|
+
maxStorageLogs?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Type for additional data that can be attached to log entries.
|
|
53
|
+
* Using 'unknown' instead of 'any' for better type safety.
|
|
54
|
+
*/
|
|
55
|
+
export type LogData = unknown;
|
|
56
|
+
/**
|
|
57
|
+
* Core logger implementation that provides multiple severity levels,
|
|
58
|
+
* configurable outputs, and flexible message formatting.
|
|
59
|
+
*
|
|
60
|
+
* The logger handles both console output and storage persistence,
|
|
61
|
+
* with environment detection to gracefully handle different contexts.
|
|
62
|
+
*/
|
|
63
|
+
export declare class Logger {
|
|
64
|
+
/**
|
|
65
|
+
* Current configuration controlling logger behavior.
|
|
66
|
+
* Modified through enable(), setLevel(), and setConfig() methods.
|
|
67
|
+
*/
|
|
68
|
+
private config;
|
|
69
|
+
/**
|
|
70
|
+
* Storage key used for persisting logs in localStorage.
|
|
71
|
+
* Prefixed with 'vizbee_homesso_' to avoid collisions.
|
|
72
|
+
*/
|
|
73
|
+
private storageKey;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new logger instance with optional custom configuration.
|
|
76
|
+
* The provided configuration is merged with default settings.
|
|
77
|
+
*
|
|
78
|
+
* @param config - Partial configuration to override default values
|
|
79
|
+
*/
|
|
80
|
+
constructor(config?: Partial<LoggerConfig>);
|
|
81
|
+
/**
|
|
82
|
+
* Enables or disables all logging functionality.
|
|
83
|
+
* When disabled, no logs will be output regardless of level.
|
|
84
|
+
*
|
|
85
|
+
* @param enabled - Whether logging should be active (defaults to true)
|
|
86
|
+
*/
|
|
87
|
+
enable(enabled?: boolean): void;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the minimum severity level for capturing logs.
|
|
90
|
+
* Only logs at this level and more severe levels will be processed.
|
|
91
|
+
*
|
|
92
|
+
* @param level - The minimum LogLevel to capture
|
|
93
|
+
*/
|
|
94
|
+
setLevel(level: LogLevel): void;
|
|
95
|
+
/**
|
|
96
|
+
* Returns a copy of the current logger configuration.
|
|
97
|
+
* Returns a new object to prevent accidental modification.
|
|
98
|
+
*
|
|
99
|
+
* @returns The complete current configuration
|
|
100
|
+
*/
|
|
101
|
+
getConfig(): LoggerConfig;
|
|
102
|
+
/**
|
|
103
|
+
* Updates logger configuration with new settings.
|
|
104
|
+
* Merges the provided settings with the existing configuration.
|
|
105
|
+
*
|
|
106
|
+
* @param config - Partial configuration to apply
|
|
107
|
+
*/
|
|
108
|
+
setConfig(config: Partial<LoggerConfig>): void;
|
|
109
|
+
/**
|
|
110
|
+
* Logs an error message (highest severity).
|
|
111
|
+
* Use for critical failures that prevent proper operation.
|
|
112
|
+
*
|
|
113
|
+
* @param message - The error message to log
|
|
114
|
+
* @param data - Optional supplementary information
|
|
115
|
+
*/
|
|
116
|
+
error(message: string, ...data: LogData[]): void;
|
|
117
|
+
/**
|
|
118
|
+
* Logs a warning message.
|
|
119
|
+
* Use for potential issues that don't stop execution.
|
|
120
|
+
*
|
|
121
|
+
* @param message - The warning message to log
|
|
122
|
+
* @param data - Optional supplementary information
|
|
123
|
+
*/
|
|
124
|
+
warn(message: string, ...data: LogData[]): void;
|
|
125
|
+
/**
|
|
126
|
+
* Logs an informational message.
|
|
127
|
+
* Use for general application state and noteworthy events.
|
|
128
|
+
*
|
|
129
|
+
* @param message - The info message to log
|
|
130
|
+
* @param data - Optional supplementary information
|
|
131
|
+
*/
|
|
132
|
+
info(message: string, ...data: LogData[]): void;
|
|
133
|
+
/**
|
|
134
|
+
* Logs a debug message.
|
|
135
|
+
* Use for detailed information helpful during development.
|
|
136
|
+
*
|
|
137
|
+
* @param message - The debug message to log
|
|
138
|
+
* @param data - Optional supplementary information
|
|
139
|
+
*/
|
|
140
|
+
debug(message: string, ...data: LogData[]): void;
|
|
141
|
+
/**
|
|
142
|
+
* Logs a trace message (lowest severity/highest verbosity).
|
|
143
|
+
* Use for extremely detailed execution path tracking.
|
|
144
|
+
*
|
|
145
|
+
* @param message - The trace message to log
|
|
146
|
+
* @param data - Optional supplementary information
|
|
147
|
+
*/
|
|
148
|
+
trace(message: string, ...data: LogData[]): void;
|
|
149
|
+
/**
|
|
150
|
+
* Core logging method that handles level filtering and message routing.
|
|
151
|
+
* Formats the message and sends it to appropriate outputs based on configuration.
|
|
152
|
+
*
|
|
153
|
+
* @param level - Log severity level
|
|
154
|
+
* @param message - The message to log
|
|
155
|
+
* @param data - Additional data to include with the log
|
|
156
|
+
*/
|
|
157
|
+
private log;
|
|
158
|
+
/**
|
|
159
|
+
* Handles console output with optional color styling.
|
|
160
|
+
* Applies different colors based on log level for better readability.
|
|
161
|
+
*
|
|
162
|
+
* @param level - Log severity level
|
|
163
|
+
* @param message - Formatted message to output
|
|
164
|
+
* @param data - Additional data to log
|
|
165
|
+
*/
|
|
166
|
+
private logToConsole;
|
|
167
|
+
/**
|
|
168
|
+
* Determines CSS styling for console output based on log level.
|
|
169
|
+
* Returns different colors to visually distinguish log levels.
|
|
170
|
+
*
|
|
171
|
+
* @param level - Log severity level
|
|
172
|
+
* @returns CSS style string for console output
|
|
173
|
+
*/
|
|
174
|
+
private getConsoleStyles;
|
|
175
|
+
/**
|
|
176
|
+
* Sets up localStorage for persisting logs if available.
|
|
177
|
+
* Creates the initial empty logs array if not already present.
|
|
178
|
+
* Gracefully handles environments without localStorage access.
|
|
179
|
+
*/
|
|
180
|
+
private initializeStorage;
|
|
181
|
+
/**
|
|
182
|
+
* Persists a log entry to localStorage with rotation management.
|
|
183
|
+
* Removes oldest entries when the maximum count is exceeded.
|
|
184
|
+
* Handles storage errors gracefully.
|
|
185
|
+
*
|
|
186
|
+
* @param message - Formatted message to store
|
|
187
|
+
* @param data - Additional data to include
|
|
188
|
+
*/
|
|
189
|
+
private logToStorage;
|
|
190
|
+
/**
|
|
191
|
+
* Exports all stored logs as a JSON string.
|
|
192
|
+
* Returns an empty array string if storage is unavailable.
|
|
193
|
+
*
|
|
194
|
+
* @returns JSON string containing all stored logs
|
|
195
|
+
*/
|
|
196
|
+
exportLogs(): string;
|
|
197
|
+
/**
|
|
198
|
+
* Clears all logs from storage.
|
|
199
|
+
* Replaces the current logs with an empty array.
|
|
200
|
+
*/
|
|
201
|
+
clearLogs(): void;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Default singleton logger instance with standard configuration.
|
|
205
|
+
* Available as a ready-to-use logger throughout the application.
|
|
206
|
+
* For custom configurations, create additional Logger instances.
|
|
207
|
+
*/
|
|
208
|
+
export declare const logger: Logger;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @const VizbeeConstants
|
|
3
|
+
* @description Constants used throughout the Vizbee Home SSO implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare const VizbeeConstants: {
|
|
6
|
+
readonly EVENT_SSO_NAME: "tv.vizbee.homesso.signin";
|
|
7
|
+
readonly KEY_SUB_TYPE: "sub_type";
|
|
8
|
+
readonly KEY_SIGN_IN_STATUS: "sstatus";
|
|
9
|
+
readonly KEY_STATE: "sstate";
|
|
10
|
+
readonly KEY_CUSTOM_DATA: "custom_data";
|
|
11
|
+
readonly KEY_REG_CODE: "regcode";
|
|
12
|
+
readonly KEY_START_SIGN_IN_INFO: "sinfo";
|
|
13
|
+
readonly KEY_IS_SIGNED_IN: "is_signed_in";
|
|
14
|
+
readonly KEY_SIGN_IN_TYPE: "stype";
|
|
15
|
+
readonly KEY_DEVICE_MODEL: "device_model";
|
|
16
|
+
readonly KEY_DEVICE_OS: "device_os";
|
|
17
|
+
readonly EVENT_SUBTYPE_START_SIGN_IN: "start_sign_in";
|
|
18
|
+
readonly EVENT_SUBTYPE_SIGN_IN_STATUS: "sign_in_status";
|
|
19
|
+
readonly VIZBEE_SESSION_READY: "vizbee-bicast-session-ready";
|
|
20
|
+
};
|
|
21
|
+
export declare enum VizbeeSignInState {
|
|
22
|
+
SIGN_IN_NOT_STARTED = "not_started",
|
|
23
|
+
SIGN_IN_IN_PROGRESS = "in_progress",
|
|
24
|
+
SIGN_IN_COMPLETED = "completed",
|
|
25
|
+
SIGN_IN_FAILED = "failed",
|
|
26
|
+
SIGN_IN_CANCELLED = "cancelled"
|
|
27
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview A robust HTTP client implementation with retry mechanism, timeout handling,
|
|
3
|
+
* and type safety. Provides a wrapper around the Fetch API with additional features.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for HTTP requests, extending the native RequestInit interface
|
|
7
|
+
*/
|
|
8
|
+
export interface RequestConfig extends RequestInit {
|
|
9
|
+
/** Timeout in milliseconds */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
/** Number of retry attempts */
|
|
12
|
+
retries?: number;
|
|
13
|
+
/** Delay between retries in milliseconds */
|
|
14
|
+
retryDelay?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Standard HTTP response format with type safety
|
|
18
|
+
*/
|
|
19
|
+
export interface HttpResponse<T = any> {
|
|
20
|
+
/** Response data of type T */
|
|
21
|
+
data: T;
|
|
22
|
+
/** HTTP status code */
|
|
23
|
+
status: number;
|
|
24
|
+
/** Response headers */
|
|
25
|
+
headers: Headers;
|
|
26
|
+
/** Whether the request was successful */
|
|
27
|
+
ok: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Custom error class for HTTP-related errors
|
|
31
|
+
*/
|
|
32
|
+
export declare class HttpError extends Error {
|
|
33
|
+
message: string;
|
|
34
|
+
status?: number | undefined;
|
|
35
|
+
response?: any | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new HttpError instance
|
|
38
|
+
* @param message Error message
|
|
39
|
+
* @param status HTTP status code
|
|
40
|
+
* @param response Raw response data
|
|
41
|
+
*/
|
|
42
|
+
constructor(message: string, status?: number | undefined, response?: any | undefined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A feature-rich HTTP client with support for timeouts, retries, and type safety
|
|
46
|
+
*/
|
|
47
|
+
export declare class HttpClient {
|
|
48
|
+
private readonly baseUrl;
|
|
49
|
+
private readonly defaultConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new HttpClient instance
|
|
52
|
+
* @param baseUrl Base URL for all requests
|
|
53
|
+
* @param defaultConfig Default configuration for all requests
|
|
54
|
+
*/
|
|
55
|
+
constructor(baseUrl?: string, defaultConfig?: RequestConfig);
|
|
56
|
+
/**
|
|
57
|
+
* Performs a GET request
|
|
58
|
+
* @param endpoint API endpoint
|
|
59
|
+
* @param config Request configuration
|
|
60
|
+
* @returns Promise resolving to typed response
|
|
61
|
+
*/
|
|
62
|
+
get<T = any>(endpoint: string, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
63
|
+
/**
|
|
64
|
+
* Performs a POST request
|
|
65
|
+
* @param endpoint API endpoint
|
|
66
|
+
* @param data Request body data
|
|
67
|
+
* @param config Request configuration
|
|
68
|
+
* @returns Promise resolving to typed response
|
|
69
|
+
*/
|
|
70
|
+
post<T = any>(endpoint: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
71
|
+
/**
|
|
72
|
+
* Performs a PUT request
|
|
73
|
+
* @param endpoint API endpoint
|
|
74
|
+
* @param data Request body data
|
|
75
|
+
* @param config Request configuration
|
|
76
|
+
* @returns Promise resolving to typed response
|
|
77
|
+
*/
|
|
78
|
+
put<T = any>(endpoint: string, data?: any, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
79
|
+
/**
|
|
80
|
+
* Performs a DELETE request
|
|
81
|
+
* @param endpoint API endpoint
|
|
82
|
+
* @param config Request configuration
|
|
83
|
+
* @returns Promise resolving to typed response
|
|
84
|
+
*/
|
|
85
|
+
delete<T = any>(endpoint: string, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
86
|
+
/**
|
|
87
|
+
* Executes a fetch request with timeout handling
|
|
88
|
+
* @throws {HttpError} When request times out
|
|
89
|
+
*/
|
|
90
|
+
private fetchWithTimeout;
|
|
91
|
+
/**
|
|
92
|
+
* Processes the response and handles errors
|
|
93
|
+
* @throws {HttpError} When response is not OK
|
|
94
|
+
*/
|
|
95
|
+
private handleResponse;
|
|
96
|
+
/**
|
|
97
|
+
* Implements retry logic for failed requests
|
|
98
|
+
* @throws {HttpError} When all retry attempts fail
|
|
99
|
+
*/
|
|
100
|
+
private retryRequest;
|
|
101
|
+
/**
|
|
102
|
+
* Determines if a request should be retried
|
|
103
|
+
*/
|
|
104
|
+
private shouldRetry;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a delay using Promise
|
|
107
|
+
*/
|
|
108
|
+
private delay;
|
|
109
|
+
/**
|
|
110
|
+
* Builds the complete URL from base URL and endpoint
|
|
111
|
+
*/
|
|
112
|
+
private buildUrl;
|
|
113
|
+
}
|
|
114
|
+
export declare const httpClient: HttpClient;
|