trane-thermostat-api 1.0.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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/dist/client/auth.d.ts +50 -0
  4. package/dist/client/auth.d.ts.map +1 -0
  5. package/dist/client/auth.js +236 -0
  6. package/dist/client/auth.js.map +1 -0
  7. package/dist/client/nexia-client.d.ts +48 -0
  8. package/dist/client/nexia-client.d.ts.map +1 -0
  9. package/dist/client/nexia-client.js +311 -0
  10. package/dist/client/nexia-client.js.map +1 -0
  11. package/dist/devices/nexia-automation.d.ts +15 -0
  12. package/dist/devices/nexia-automation.d.ts.map +1 -0
  13. package/dist/devices/nexia-automation.js +39 -0
  14. package/dist/devices/nexia-automation.js.map +1 -0
  15. package/dist/devices/nexia-sensor.d.ts +34 -0
  16. package/dist/devices/nexia-sensor.d.ts.map +1 -0
  17. package/dist/devices/nexia-sensor.js +152 -0
  18. package/dist/devices/nexia-sensor.js.map +1 -0
  19. package/dist/devices/nexia-thermostat.d.ts +73 -0
  20. package/dist/devices/nexia-thermostat.d.ts.map +1 -0
  21. package/dist/devices/nexia-thermostat.js +357 -0
  22. package/dist/devices/nexia-thermostat.js.map +1 -0
  23. package/dist/devices/nexia-zone.d.ts +61 -0
  24. package/dist/devices/nexia-zone.d.ts.map +1 -0
  25. package/dist/devices/nexia-zone.js +370 -0
  26. package/dist/devices/nexia-zone.js.map +1 -0
  27. package/dist/index.d.ts +15 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +41 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/types/api.d.ts +277 -0
  32. package/dist/types/api.d.ts.map +1 -0
  33. package/dist/types/api.js +3 -0
  34. package/dist/types/api.js.map +1 -0
  35. package/dist/types/constants.d.ts +137 -0
  36. package/dist/types/constants.d.ts.map +1 -0
  37. package/dist/types/constants.js +160 -0
  38. package/dist/types/constants.js.map +1 -0
  39. package/dist/types/interfaces.d.ts +211 -0
  40. package/dist/types/interfaces.d.ts.map +1 -0
  41. package/dist/types/interfaces.js +3 -0
  42. package/dist/types/interfaces.js.map +1 -0
  43. package/dist/utils/errors.d.ts +94 -0
  44. package/dist/utils/errors.d.ts.map +1 -0
  45. package/dist/utils/errors.js +231 -0
  46. package/dist/utils/errors.js.map +1 -0
  47. package/dist/utils/http-utils.d.ts +59 -0
  48. package/dist/utils/http-utils.d.ts.map +1 -0
  49. package/dist/utils/http-utils.js +273 -0
  50. package/dist/utils/http-utils.js.map +1 -0
  51. package/dist/utils/json-utils.d.ts +32 -0
  52. package/dist/utils/json-utils.d.ts.map +1 -0
  53. package/dist/utils/json-utils.js +389 -0
  54. package/dist/utils/json-utils.js.map +1 -0
  55. package/dist/utils/validation.d.ts +52 -0
  56. package/dist/utils/validation.d.ts.map +1 -0
  57. package/dist/utils/validation.js +272 -0
  58. package/dist/utils/validation.js.map +1 -0
  59. package/package.json +69 -0
@@ -0,0 +1,211 @@
1
+ import { BrandType, OperationMode, PresetMode, AirCleanerMode, TemperatureUnit, SensorType } from './constants';
2
+ import { TemperatureOptions, HumidityOptions, FanOptions, HoldOptions, UpdateOptions, SensorSelectionOptions, DeviceCapabilities, SystemStatusSummary, ZoneStatusSummary } from './api';
3
+ export interface INexiaClient {
4
+ login(): Promise<void>;
5
+ logout(): Promise<void>;
6
+ isAuthenticated(): boolean;
7
+ getThermostats(): Promise<INexiaThermostat[]>;
8
+ getAutomations(): Promise<INexiaAutomation[]>;
9
+ getThermostatById(id: string): INexiaThermostat | undefined;
10
+ getAutomationById(id: string): INexiaAutomation | undefined;
11
+ update(options?: UpdateOptions): Promise<void>;
12
+ readonly brand: BrandType;
13
+ readonly username: string;
14
+ getHouseId(): number | undefined;
15
+ readonly lastUpdate: Date | null;
16
+ }
17
+ export interface INexiaThermostat {
18
+ readonly id: string;
19
+ readonly name: string;
20
+ readonly model: string;
21
+ readonly firmware: string;
22
+ readonly isOnline: boolean;
23
+ readonly temperatureUnit: TemperatureUnit;
24
+ readonly deadband: number;
25
+ readonly capabilities: DeviceCapabilities;
26
+ readonly hasZones: boolean;
27
+ readonly hasOutdoorTemperature: boolean;
28
+ readonly hasRelativeHumidity: boolean;
29
+ readonly hasVariableSpeedCompressor: boolean;
30
+ readonly hasEmergencyHeat: boolean;
31
+ readonly hasVariableFanSpeed: boolean;
32
+ readonly hasDehumidifySupport: boolean;
33
+ readonly hasHumidifySupport: boolean;
34
+ readonly hasAirCleaner: boolean;
35
+ readonly systemStatus: SystemStatusSummary;
36
+ readonly isBlowerActive: boolean;
37
+ readonly isEmergencyHeatActive: boolean;
38
+ readonly currentCompressorSpeed: number;
39
+ readonly relativeHumidity: number | null;
40
+ readonly outdoorTemperature: number | null;
41
+ readonly setpointLimits: {
42
+ heatMin: number;
43
+ heatMax: number;
44
+ coolMin: number;
45
+ coolMax: number;
46
+ };
47
+ readonly availableFanModes: string[];
48
+ readonly currentFanMode: string | null;
49
+ readonly fanSpeedLimits: {
50
+ min: number;
51
+ max: number;
52
+ };
53
+ readonly currentFanSpeed: number;
54
+ setFanMode(mode: string): Promise<void>;
55
+ setFanSpeed(speed: number): Promise<void>;
56
+ setFanOptions(options: FanOptions): Promise<void>;
57
+ readonly humidifySetpoint: number;
58
+ readonly dehumidifySetpoint: number;
59
+ readonly humiditySetpoints: number[];
60
+ readonly dehumidifySetpoints: number[];
61
+ setHumiditySetpoints(options: HumidityOptions): Promise<void>;
62
+ setDehumidifySetpoint(value: number): Promise<void>;
63
+ setHumidifySetpoint(value: number): Promise<void>;
64
+ readonly airCleanerMode: string | null;
65
+ readonly availableAirCleanerModes: AirCleanerMode[];
66
+ setAirCleanerMode(mode: AirCleanerMode): Promise<void>;
67
+ setEmergencyHeat(enabled: boolean): Promise<void>;
68
+ setFollowSchedule(follow: boolean): Promise<void>;
69
+ readonly zones: INexiaZone[];
70
+ readonly zoneIds: string[];
71
+ getZoneById(zoneId: string): INexiaZone | undefined;
72
+ refresh(): Promise<void>;
73
+ }
74
+ export interface INexiaZone {
75
+ readonly id: string;
76
+ readonly name: string;
77
+ readonly isNativeZone: boolean;
78
+ readonly currentTemperature: number;
79
+ readonly heatingSetpoint: number;
80
+ readonly coolingSetpoint: number;
81
+ readonly currentMode: OperationMode;
82
+ readonly requestedMode: OperationMode;
83
+ readonly availableModes: OperationMode[];
84
+ setMode(mode: OperationMode): Promise<void>;
85
+ setTemperatures(options: TemperatureOptions): Promise<void>;
86
+ setHeatingSetpoint(temperature: number): Promise<void>;
87
+ setCoolingSetpoint(temperature: number): Promise<void>;
88
+ readonly status: ZoneStatusSummary;
89
+ readonly isCalling: boolean;
90
+ readonly setpointStatus: string;
91
+ readonly isInPermanentHold: boolean;
92
+ setPermanentHold(options?: HoldOptions): Promise<void>;
93
+ returnToSchedule(): Promise<void>;
94
+ readonly availablePresets: PresetMode[];
95
+ readonly currentPreset: PresetMode | null;
96
+ setPreset(preset: PresetMode): Promise<void>;
97
+ readonly sensors: INexiaSensor[];
98
+ readonly activeSensorIds: Set<number>;
99
+ readonly sensorIds: number[];
100
+ getSensorById(sensorId: number): INexiaSensor | undefined;
101
+ selectActiveSensors(options: SensorSelectionOptions): Promise<void>;
102
+ readonly thermostat: INexiaThermostat;
103
+ validateTemperatureSetpoints(heatTemp: number, coolTemp: number): boolean;
104
+ roundTemperature(temperature: number): number;
105
+ }
106
+ export interface INexiaSensor {
107
+ readonly id: number;
108
+ readonly name: string;
109
+ readonly type: SensorType;
110
+ readonly serialNumber: string;
111
+ readonly weight: number;
112
+ readonly isActive: boolean;
113
+ readonly isConnected: boolean | null;
114
+ readonly temperature: number;
115
+ readonly temperatureValid: boolean;
116
+ readonly humidity: number;
117
+ readonly humidityValid: boolean;
118
+ readonly hasBattery: boolean;
119
+ readonly batteryLevel: number | null;
120
+ readonly batteryLow: boolean | null;
121
+ readonly batteryValid: boolean | null;
122
+ readonly batteryStatus: 'good' | 'low' | 'critical' | 'unknown';
123
+ readonly hasOnlineStatus: boolean;
124
+ isDataValid(): boolean;
125
+ }
126
+ export interface INexiaAutomation {
127
+ readonly id: string;
128
+ readonly name: string;
129
+ readonly description: string;
130
+ readonly enabled: boolean;
131
+ setEnabled(enabled: boolean): Promise<void>;
132
+ activate(): Promise<void>;
133
+ }
134
+ export interface NexiaConfig {
135
+ username: string;
136
+ password: string;
137
+ brand?: BrandType;
138
+ deviceName?: string;
139
+ houseId?: number;
140
+ stateFile?: string;
141
+ timeout?: number;
142
+ retryAttempts?: number;
143
+ }
144
+ export interface NexiaEvent {
145
+ type: 'update' | 'error' | 'connected' | 'disconnected';
146
+ timestamp: Date;
147
+ data?: any;
148
+ error?: Error;
149
+ }
150
+ export interface INexiaEventListener {
151
+ onUpdate?(data: any): void;
152
+ onError?(error: Error): void;
153
+ onConnected?(): void;
154
+ onDisconnected?(): void;
155
+ }
156
+ export interface ITemperatureValidator {
157
+ validateSetpoints(heatTemp: number, coolTemp: number, deadband: number, unit: TemperatureUnit): void;
158
+ validateTemperature(temperature: number, unit: TemperatureUnit): void;
159
+ roundTemperature(temperature: number, unit: TemperatureUnit): number;
160
+ convertTemperature(temperature: number, fromUnit: TemperatureUnit, toUnit: TemperatureUnit): number;
161
+ }
162
+ export interface IHttpClient {
163
+ get<T>(url: string, headers?: Record<string, string>): Promise<T>;
164
+ post<T>(url: string, data: any, headers?: Record<string, string>): Promise<T>;
165
+ put<T>(url: string, data: any, headers?: Record<string, string>): Promise<T>;
166
+ delete<T>(url: string, headers?: Record<string, string>): Promise<T>;
167
+ }
168
+ export interface IAuthManager {
169
+ authenticate(): Promise<void>;
170
+ refreshSession(): Promise<void>;
171
+ isSessionValid(): boolean;
172
+ getApiKey(): string | null;
173
+ getMobileId(): string | null;
174
+ getDeviceUuid(): string;
175
+ }
176
+ export interface ICache {
177
+ get(key: string): string | undefined;
178
+ set(key: string, value: string): void;
179
+ clear(): void;
180
+ has(key: string): boolean;
181
+ }
182
+ export interface ILogger {
183
+ debug(message: string, ...args: any[]): void;
184
+ info(message: string, ...args: any[]): void;
185
+ warn(message: string, ...args: any[]): void;
186
+ error(message: string, error?: Error, ...args: any[]): void;
187
+ }
188
+ export interface IHomebridgePlatform {
189
+ readonly api: any;
190
+ readonly log: ILogger;
191
+ readonly config: any;
192
+ discoverDevices(): Promise<void>;
193
+ configureAccessory(accessory: any): void;
194
+ }
195
+ export interface IHomebridgeAccessory {
196
+ readonly platform: IHomebridgePlatform;
197
+ readonly accessory: any;
198
+ readonly device: INexiaThermostat | INexiaZone | INexiaSensor;
199
+ setupServices(): void;
200
+ updateCharacteristics(): void;
201
+ }
202
+ export interface INexiaTypeGuards {
203
+ isThermostat(device: any): device is INexiaThermostat;
204
+ isZone(device: any): device is INexiaZone;
205
+ isSensor(device: any): device is INexiaSensor;
206
+ isAutomation(device: any): device is INexiaAutomation;
207
+ isValidTemperature(value: any, unit: TemperatureUnit): boolean;
208
+ isValidHumidity(value: any): boolean;
209
+ isValidFanSpeed(value: any): boolean;
210
+ }
211
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,YAAY;IAE3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,eAAe,IAAI,OAAO,CAAC;IAG3B,cAAc,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC9C,cAAc,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAA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C,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;CACtC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,94 @@
1
+ export declare class NexiaError extends Error {
2
+ code: string;
3
+ readonly timestamp: Date;
4
+ constructor(message: string, code?: string);
5
+ }
6
+ export declare class AuthenticationError extends NexiaError {
7
+ constructor(message?: string);
8
+ }
9
+ export declare class RateLimitError extends AuthenticationError {
10
+ readonly retryAfter?: number;
11
+ constructor(message?: string, retryAfter?: number);
12
+ }
13
+ export declare class SessionExpiredError extends AuthenticationError {
14
+ constructor(message?: string);
15
+ }
16
+ export declare class ValidationError extends NexiaError {
17
+ readonly field?: string;
18
+ readonly value?: unknown;
19
+ constructor(message: string, field?: string, value?: unknown);
20
+ }
21
+ export declare class TemperatureValidationError extends ValidationError {
22
+ readonly unit?: string;
23
+ readonly limits?: {
24
+ min: number;
25
+ max: number;
26
+ };
27
+ constructor(message: string, field?: string, value?: number, unit?: string, limits?: {
28
+ min: number;
29
+ max: number;
30
+ });
31
+ }
32
+ export declare class DeadbandValidationError extends ValidationError {
33
+ readonly deadband: number;
34
+ readonly heatTemp: number;
35
+ readonly coolTemp: number;
36
+ constructor(message: string, deadband: number, heatTemp: number, coolTemp: number);
37
+ }
38
+ export declare class ApiError extends NexiaError {
39
+ readonly statusCode?: number;
40
+ readonly response?: unknown;
41
+ constructor(message: string, statusCode?: number, response?: unknown);
42
+ }
43
+ export declare class HttpError extends ApiError {
44
+ constructor(message: string, statusCode: number, response?: unknown);
45
+ }
46
+ export declare class NetworkError extends NexiaError {
47
+ readonly originalError?: Error;
48
+ constructor(message: string, originalError?: Error);
49
+ }
50
+ export declare class TimeoutError extends NetworkError {
51
+ readonly timeout: number;
52
+ constructor(message: string, timeout: number);
53
+ }
54
+ export declare class DeviceNotFoundError extends NexiaError {
55
+ readonly deviceId: string;
56
+ readonly deviceType: string;
57
+ constructor(message: string, deviceId: string, deviceType?: string);
58
+ }
59
+ export declare class FeatureNotSupportedError extends NexiaError {
60
+ readonly feature: string;
61
+ readonly deviceModel?: string;
62
+ constructor(feature: string, deviceModel?: string);
63
+ }
64
+ export declare class OperationNotAllowedError extends NexiaError {
65
+ readonly operation: string;
66
+ readonly reason?: string;
67
+ constructor(operation: string, reason?: string);
68
+ }
69
+ export declare class ConfigurationError extends NexiaError {
70
+ readonly configField?: string;
71
+ constructor(message: string, configField?: string);
72
+ }
73
+ export declare class ParseError extends NexiaError {
74
+ readonly data?: unknown;
75
+ constructor(message: string, data?: unknown);
76
+ }
77
+ export declare class ErrorFactory {
78
+ static createHttpError(statusCode: number, message?: string, response?: unknown): HttpError;
79
+ static createValidationError(field: string, value: unknown, expected: string): ValidationError;
80
+ static createTemperatureError(temperature: number, unit: string, min: number, max: number): TemperatureValidationError;
81
+ static createDeadbandError(heatTemp: number, coolTemp: number, deadband: number, unit: string): DeadbandValidationError;
82
+ private static getHttpStatusMessage;
83
+ }
84
+ export declare function isNexiaError(error: unknown): error is NexiaError;
85
+ export declare function isAuthenticationError(error: unknown): error is AuthenticationError;
86
+ export declare function isValidationError(error: unknown): error is ValidationError;
87
+ export declare function isApiError(error: unknown): error is ApiError;
88
+ export declare function isNetworkError(error: unknown): error is NetworkError;
89
+ export declare class ErrorHandler {
90
+ static handle(error: unknown): NexiaError;
91
+ static isRetryable(error: NexiaError): boolean;
92
+ static getRetryDelay(attempt: number, baseDelay?: number): number;
93
+ }
94
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAMA,qBAAa,UAAW,SAAQ,KAAK;IAC5B,IAAI,EAAE,MAAM,CAAC;IACpB,SAAgB,SAAS,EAAE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AAU;IAmBzC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAS9C,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,MAAM;CAKxE"}
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorHandler = exports.ErrorFactory = exports.ParseError = exports.ConfigurationError = exports.OperationNotAllowedError = exports.FeatureNotSupportedError = exports.DeviceNotFoundError = exports.TimeoutError = exports.NetworkError = exports.HttpError = exports.ApiError = exports.DeadbandValidationError = exports.TemperatureValidationError = exports.ValidationError = exports.SessionExpiredError = exports.RateLimitError = exports.AuthenticationError = exports.NexiaError = void 0;
4
+ exports.isNexiaError = isNexiaError;
5
+ exports.isAuthenticationError = isAuthenticationError;
6
+ exports.isValidationError = isValidationError;
7
+ exports.isApiError = isApiError;
8
+ exports.isNetworkError = isNetworkError;
9
+ class NexiaError extends Error {
10
+ constructor(message, code = 'UNKNOWN_ERROR') {
11
+ super(message);
12
+ this.name = 'NexiaError';
13
+ this.code = code;
14
+ this.timestamp = new Date();
15
+ if (Error.captureStackTrace) {
16
+ Error.captureStackTrace(this, NexiaError);
17
+ }
18
+ }
19
+ }
20
+ exports.NexiaError = NexiaError;
21
+ class AuthenticationError extends NexiaError {
22
+ constructor(message = 'Authentication failed') {
23
+ super(message, 'AUTH_ERROR');
24
+ this.name = 'AuthenticationError';
25
+ }
26
+ }
27
+ exports.AuthenticationError = AuthenticationError;
28
+ class RateLimitError extends AuthenticationError {
29
+ constructor(message = 'Rate limit exceeded', retryAfter) {
30
+ super(message);
31
+ this.name = 'RateLimitError';
32
+ this.code = 'RATE_LIMIT';
33
+ this.retryAfter = retryAfter;
34
+ }
35
+ }
36
+ exports.RateLimitError = RateLimitError;
37
+ class SessionExpiredError extends AuthenticationError {
38
+ constructor(message = 'Session has expired') {
39
+ super(message);
40
+ this.name = 'SessionExpiredError';
41
+ this.code = 'SESSION_EXPIRED';
42
+ }
43
+ }
44
+ exports.SessionExpiredError = SessionExpiredError;
45
+ class ValidationError extends NexiaError {
46
+ constructor(message, field, value) {
47
+ super(message, 'VALIDATION_ERROR');
48
+ this.name = 'ValidationError';
49
+ this.field = field;
50
+ this.value = value;
51
+ }
52
+ }
53
+ exports.ValidationError = ValidationError;
54
+ class TemperatureValidationError extends ValidationError {
55
+ constructor(message, field, value, unit, limits) {
56
+ super(message, field, value);
57
+ this.name = 'TemperatureValidationError';
58
+ this.code = 'TEMP_VALIDATION';
59
+ this.unit = unit;
60
+ this.limits = limits;
61
+ }
62
+ }
63
+ exports.TemperatureValidationError = TemperatureValidationError;
64
+ class DeadbandValidationError extends ValidationError {
65
+ constructor(message, deadband, heatTemp, coolTemp) {
66
+ super(message, 'deadband', { deadband, heatTemp, coolTemp });
67
+ this.name = 'DeadbandValidationError';
68
+ this.code = 'DEADBAND_ERROR';
69
+ this.deadband = deadband;
70
+ this.heatTemp = heatTemp;
71
+ this.coolTemp = coolTemp;
72
+ }
73
+ }
74
+ exports.DeadbandValidationError = DeadbandValidationError;
75
+ class ApiError extends NexiaError {
76
+ constructor(message, statusCode, response) {
77
+ super(message, 'API_ERROR');
78
+ this.name = 'ApiError';
79
+ this.statusCode = statusCode;
80
+ this.response = response;
81
+ }
82
+ }
83
+ exports.ApiError = ApiError;
84
+ class HttpError extends ApiError {
85
+ constructor(message, statusCode, response) {
86
+ super(message, statusCode, response);
87
+ this.name = 'HttpError';
88
+ this.code = `HTTP_${statusCode}`;
89
+ }
90
+ }
91
+ exports.HttpError = HttpError;
92
+ class NetworkError extends NexiaError {
93
+ constructor(message, originalError) {
94
+ super(message, 'NETWORK_ERROR');
95
+ this.name = 'NetworkError';
96
+ this.originalError = originalError;
97
+ }
98
+ }
99
+ exports.NetworkError = NetworkError;
100
+ class TimeoutError extends NetworkError {
101
+ constructor(message, timeout) {
102
+ super(message);
103
+ this.name = 'TimeoutError';
104
+ this.code = 'TIMEOUT';
105
+ this.timeout = timeout;
106
+ }
107
+ }
108
+ exports.TimeoutError = TimeoutError;
109
+ class DeviceNotFoundError extends NexiaError {
110
+ constructor(message, deviceId, deviceType = 'device') {
111
+ super(message, 'DEVICE_NOT_FOUND');
112
+ this.name = 'DeviceNotFoundError';
113
+ this.deviceId = deviceId;
114
+ this.deviceType = deviceType;
115
+ }
116
+ }
117
+ exports.DeviceNotFoundError = DeviceNotFoundError;
118
+ class FeatureNotSupportedError extends NexiaError {
119
+ constructor(feature, deviceModel) {
120
+ const message = deviceModel
121
+ ? `Feature '${feature}' is not supported on device model '${deviceModel}'`
122
+ : `Feature '${feature}' is not supported`;
123
+ super(message, 'FEATURE_NOT_SUPPORTED');
124
+ this.name = 'FeatureNotSupportedError';
125
+ this.feature = feature;
126
+ this.deviceModel = deviceModel;
127
+ }
128
+ }
129
+ exports.FeatureNotSupportedError = FeatureNotSupportedError;
130
+ class OperationNotAllowedError extends NexiaError {
131
+ constructor(operation, reason) {
132
+ const message = reason
133
+ ? `Operation '${operation}' is not allowed: ${reason}`
134
+ : `Operation '${operation}' is not allowed`;
135
+ super(message, 'OPERATION_NOT_ALLOWED');
136
+ this.name = 'OperationNotAllowedError';
137
+ this.operation = operation;
138
+ this.reason = reason;
139
+ }
140
+ }
141
+ exports.OperationNotAllowedError = OperationNotAllowedError;
142
+ class ConfigurationError extends NexiaError {
143
+ constructor(message, configField) {
144
+ super(message, 'CONFIG_ERROR');
145
+ this.name = 'ConfigurationError';
146
+ this.configField = configField;
147
+ }
148
+ }
149
+ exports.ConfigurationError = ConfigurationError;
150
+ class ParseError extends NexiaError {
151
+ constructor(message, data) {
152
+ super(message, 'PARSE_ERROR');
153
+ this.name = 'ParseError';
154
+ this.data = data;
155
+ }
156
+ }
157
+ exports.ParseError = ParseError;
158
+ class ErrorFactory {
159
+ static createHttpError(statusCode, message, response) {
160
+ const defaultMessage = this.getHttpStatusMessage(statusCode);
161
+ return new HttpError(message || defaultMessage, statusCode, response);
162
+ }
163
+ static createValidationError(field, value, expected) {
164
+ const message = `Invalid value for '${field}': got ${JSON.stringify(value)}, expected ${expected}`;
165
+ return new ValidationError(message, field, value);
166
+ }
167
+ static createTemperatureError(temperature, unit, min, max) {
168
+ const message = `Temperature ${temperature}°${unit} is outside valid range (${min}°${unit} - ${max}°${unit})`;
169
+ return new TemperatureValidationError(message, 'temperature', temperature, unit, { min, max });
170
+ }
171
+ static createDeadbandError(heatTemp, coolTemp, deadband, unit) {
172
+ const diff = coolTemp - heatTemp;
173
+ const message = `Temperature difference (${diff}°${unit}) is less than required deadband (${deadband}°${unit})`;
174
+ return new DeadbandValidationError(message, deadband, heatTemp, coolTemp);
175
+ }
176
+ static getHttpStatusMessage(statusCode) {
177
+ const statusMessages = {
178
+ 400: 'Bad Request',
179
+ 401: 'Unauthorized',
180
+ 403: 'Forbidden',
181
+ 404: 'Not Found',
182
+ 429: 'Too Many Requests',
183
+ 500: 'Internal Server Error',
184
+ 502: 'Bad Gateway',
185
+ 503: 'Service Unavailable',
186
+ 504: 'Gateway Timeout'
187
+ };
188
+ return statusMessages[statusCode] || `HTTP Error ${statusCode}`;
189
+ }
190
+ }
191
+ exports.ErrorFactory = ErrorFactory;
192
+ function isNexiaError(error) {
193
+ return error instanceof NexiaError;
194
+ }
195
+ function isAuthenticationError(error) {
196
+ return error instanceof AuthenticationError;
197
+ }
198
+ function isValidationError(error) {
199
+ return error instanceof ValidationError;
200
+ }
201
+ function isApiError(error) {
202
+ return error instanceof ApiError;
203
+ }
204
+ function isNetworkError(error) {
205
+ return error instanceof NetworkError;
206
+ }
207
+ class ErrorHandler {
208
+ static handle(error) {
209
+ if (isNexiaError(error)) {
210
+ return error;
211
+ }
212
+ if (error instanceof Error) {
213
+ return new NexiaError(error.message, 'UNKNOWN_ERROR');
214
+ }
215
+ if (typeof error === 'string') {
216
+ return new NexiaError(error, 'UNKNOWN_ERROR');
217
+ }
218
+ return new NexiaError('An unknown error occurred', 'UNKNOWN_ERROR');
219
+ }
220
+ static isRetryable(error) {
221
+ return (isNetworkError(error) ||
222
+ (isApiError(error) && error.statusCode !== undefined && error.statusCode >= 500) ||
223
+ error instanceof SessionExpiredError);
224
+ }
225
+ static getRetryDelay(attempt, baseDelay = 1000) {
226
+ const delay = Math.min(baseDelay * Math.pow(2, attempt), 30000);
227
+ return delay + Math.random() * 1000;
228
+ }
229
+ }
230
+ exports.ErrorHandler = ErrorHandler;
231
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;AAmRA,oCAEC;AAED,sDAEC;AAED,8CAEC;AAED,gCAEC;AAED,wCAEC;AA/RD,MAAa,UAAW,SAAQ,KAAK;IAInC,YAAY,OAAe,EAAE,OAAe,eAAe;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAG5B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AAfD,gCAeC;AAGD,MAAa,mBAAoB,SAAQ,UAAU;IACjD,YAAY,UAAkB,uBAAuB;QACnD,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAGD,MAAa,cAAe,SAAQ,mBAAmB;IAGrD,YAAY,UAAkB,qBAAqB,EAAE,UAAmB;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAA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Ae,CAAC,CAAC;QACxD,CAAC;QAGD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAChD,CAAC;QAGD,OAAO,IAAI,UAAU,CAAC,2BAA2B,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAiB;QAElC,OAAO,CACL,cAAc,CAAC,KAAK,CAAC;YACrB,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,IAAI,GAAG,CAAC;YAChF,KAAK,YAAY,mBAAmB,CACrC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,YAAoB,IAAI;QAE5D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;IACtC,CAAC;CACF;AAlCD,oCAkCC"}
@@ -0,0 +1,59 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ export interface HttpClientOptions {
3
+ baseURL: string;
4
+ timeout?: number;
5
+ retryAttempts?: number;
6
+ retryDelay?: number;
7
+ headers?: Record<string, string>;
8
+ }
9
+ export interface ETagCacheEntry {
10
+ etag: string;
11
+ data: any;
12
+ timestamp: number;
13
+ }
14
+ export interface HttpResponse<T> {
15
+ data: T;
16
+ status: number;
17
+ headers: Record<string, string>;
18
+ etag?: string;
19
+ }
20
+ export declare class HttpClient {
21
+ private axiosInstance;
22
+ private etagCache;
23
+ private readonly retryAttempts;
24
+ private readonly retryDelay;
25
+ constructor(options: HttpClientOptions);
26
+ private setupInterceptors;
27
+ private handleSuccessResponse;
28
+ private handleError;
29
+ private handleAxiosError;
30
+ get<T>(url: string, config?: AxiosRequestConfig): Promise<HttpResponse<T>>;
31
+ post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<HttpResponse<T>>;
32
+ put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<HttpResponse<T>>;
33
+ delete<T>(url: string, config?: AxiosRequestConfig): Promise<HttpResponse<T>>;
34
+ getWithETag<T>(url: string, config?: AxiosRequestConfig): Promise<{
35
+ data: T;
36
+ status: number;
37
+ headers: Record<string, string>;
38
+ fromCache: boolean;
39
+ }>;
40
+ private makeRequest;
41
+ private calculateRetryDelay;
42
+ private delay;
43
+ setAuthHeaders(apiKey: string, mobileId: string, brand: string): void;
44
+ clearAuthHeaders(): void;
45
+ clearETagCache(): void;
46
+ removeFromETagCache(url: string): void;
47
+ updateBaseURL(baseURL: string): void;
48
+ getBaseURL(): string | undefined;
49
+ }
50
+ export declare class HttpUtils {
51
+ static buildQueryString(params: Record<string, any>): string;
52
+ static joinUrls(...parts: string[]): string;
53
+ static isValidUrl(url: string): boolean;
54
+ static extractErrorMessage(response: any): string;
55
+ static createFormData(data: Record<string, any>): FormData;
56
+ static safeJsonParse<T>(data: any, fallback?: T): T | undefined;
57
+ }
58
+ export declare function createHttpClient(options: HttpClientOptions): HttpClient;
59
+ //# sourceMappingURL=http-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-utils.d.ts","sourceRoot":"","sources":["../../src/utils/http-utils.ts"],"names":[],"mappings":"AAKA,OAAc,EAAiB,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAW5F,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IA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