fleeta-api-lib
Version:
A comprehensive library for fleet management applications - API, Auth, Device management
85 lines • 3.52 kB
TypeScript
/**
* Event WebSocket API Type Definitions
* Defines all types for WebPush WebSocket communication
*/
/**
* WebPush message interface from server
*/
export interface WebPushMessage {
type: 'webpush';
code: WebPushEventCode;
message: string;
image?: string;
file?: string;
}
/**
* WebPush event codes - Message only events
*/
export type MessageOnlyEventCode = 'ALARM_FOTA_SUCCESS' | 'ALARM_FOTA_FAIL' | 'ALARM_GEOFENCE_ENTER' | 'ALARM_GEOFENCE_EXIT' | 'ALARM_GEOFENCE_PASS' | 'DEVICE_CONNECT' | 'DEVICE_DISCONNECT' | 'ALARM_PARK_MOTION' | 'ALARM_PARK_IN' | 'ALARM_PARK_OUT' | 'ALARM_TEMPERATURE_OVER' | 'ALARM_TEMPERATURE_LTE_OVER' | 'ALARM_LOW_VOLTAGE' | 'ALARM_SETTING_SAVED' | 'SERVER_RESTART';
/**
* WebPush event codes - Image included events
*/
export type ImageIncludedEventCode = 'ALARM_SPEED' | 'ALARM_EVENT' | 'ALARM_PARK_EVENT' | 'ALARM_ACCELERATION' | 'ALARM_HARSHBRAKING' | 'ALARM_SHARPTURN' | 'ALARM_MANUAL' | 'ALARM_DROWSY' | 'ALARM_DROWSY_SECOND' | 'ALARM_MASK_OFF' | 'ALARM_CALLING' | 'ALARM_SMOKING' | 'ALARM_DISTRACTED' | 'ALARM_UNDETECTED' | 'ALARM_DETECTED';
/**
* All WebPush event codes
*/
export type WebPushEventCode = MessageOnlyEventCode | ImageIncludedEventCode;
/**
* WebPush connection states
*/
export type EventConnectionState = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'reconnecting';
/**
* Event WebSocket event types
*/
export type EventWsEvent = 'open' | 'close' | 'error' | 'message' | 'webpush' | 'raw';
/**
* Event handler type
*/
export type EventWsEventHandler<T = any> = (data: T) => void;
/**
* Event WebSocket SDK configuration
*/
export interface EventWebSocketSDKOptions {
baseUrl?: string;
maxReconnectAttempts?: number;
reconnectDelay?: number;
heartbeatInterval?: number;
psnFilters?: string[];
enablePsnFiltering?: boolean;
}
/**
* PSN filter configuration
*/
export interface PsnFilterConfig {
enableFiltering: boolean;
allowedPsns: Set<string>;
extractPsnFromMessage: (message: string) => string | null;
}
/**
* Default configuration values
*/
export declare const DEFAULT_EVENT_WEBSOCKET_CONFIG: Required<EventWebSocketSDKOptions>;
/**
* WebPush event code descriptions
*/
export declare const WEBPUSH_EVENT_DESCRIPTIONS: Record<WebPushEventCode, string>;
/**
* Check if event code includes image
*/
export declare function isImageIncludedEvent(code: WebPushEventCode): code is ImageIncludedEventCode;
/**
* Categorize WebPush events by type
*/
export declare const WEBPUSH_EVENT_CATEGORIES: {
readonly device: readonly ["DEVICE_CONNECT", "DEVICE_DISCONNECT"];
readonly fota: readonly ["ALARM_FOTA_SUCCESS", "ALARM_FOTA_FAIL"];
readonly geofence: readonly ["ALARM_GEOFENCE_ENTER", "ALARM_GEOFENCE_EXIT", "ALARM_GEOFENCE_PASS"];
readonly parking: readonly ["ALARM_PARK_MOTION", "ALARM_PARK_IN", "ALARM_PARK_OUT", "ALARM_PARK_EVENT"];
readonly temperature: readonly ["ALARM_TEMPERATURE_OVER", "ALARM_TEMPERATURE_LTE_OVER"];
readonly voltage: readonly ["ALARM_LOW_VOLTAGE"];
readonly driving: readonly ["ALARM_SPEED", "ALARM_EVENT", "ALARM_ACCELERATION", "ALARM_HARSHBRAKING", "ALARM_SHARPTURN"];
readonly driver: readonly ["ALARM_DROWSY", "ALARM_DROWSY_SECOND", "ALARM_MASK_OFF", "ALARM_CALLING", "ALARM_SMOKING", "ALARM_DISTRACTED", "ALARM_UNDETECTED", "ALARM_DETECTED"];
readonly manual: readonly ["ALARM_MANUAL"];
readonly system: readonly ["ALARM_SETTING_SAVED", "SERVER_RESTART"];
};
//# sourceMappingURL=types.d.ts.map