@pushflodev/sdk 1.0.5 → 1.0.6

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 CHANGED
@@ -48,6 +48,9 @@ const subscription = client.subscribe('notifications', {
48
48
  // 4. Cleanup when done
49
49
  subscription.unsubscribe();
50
50
  client.disconnect();
51
+
52
+ // 5. Clean up all resources (optional - for complete teardown)
53
+ client.destroy();
51
54
  ```
52
55
 
53
56
  ## Quick Start - Server (60 seconds)
@@ -1,4 +1,4 @@
1
- import { a as ConnectionInfo, M as Message, C as ClientOptions, b as ConnectionState, e as SubscriptionOptions, S as Subscription } from './message-CVgilLwz.js';
1
+ import { a as ConnectionInfo, M as Message, C as ClientOptions, b as ConnectionState, f as SubscriptionOptions, S as Subscription, e as PushFloError } from './ValidationError-izGOr1dF.js';
2
2
 
3
3
  /**
4
4
  * Type-safe event emitter with zero dependencies
@@ -101,4 +101,26 @@ declare class PushFloClient extends TypedEventEmitter<PushFloClientEvents> {
101
101
  private handleServerMessage;
102
102
  }
103
103
 
104
- export { PushFloClient as P };
104
+ /**
105
+ * Error thrown when connection to PushFlo fails
106
+ */
107
+ declare class ConnectionError extends PushFloError {
108
+ constructor(message: string, code?: string, options?: {
109
+ retryable?: boolean;
110
+ cause?: Error;
111
+ });
112
+ /**
113
+ * Create a connection timeout error
114
+ */
115
+ static timeout(timeoutMs: number): ConnectionError;
116
+ /**
117
+ * Create a connection closed error
118
+ */
119
+ static closed(reason?: string): ConnectionError;
120
+ /**
121
+ * Create a connection failed error
122
+ */
123
+ static failed(reason?: string, cause?: Error): ConnectionError;
124
+ }
125
+
126
+ export { ConnectionError as C, PushFloClient as P };
@@ -1,4 +1,4 @@
1
- import { a as ConnectionInfo, M as Message, C as ClientOptions, b as ConnectionState, e as SubscriptionOptions, S as Subscription } from './message-CVgilLwz.cjs';
1
+ import { a as ConnectionInfo, M as Message, C as ClientOptions, b as ConnectionState, f as SubscriptionOptions, S as Subscription, e as PushFloError } from './ValidationError-izGOr1dF.cjs';
2
2
 
3
3
  /**
4
4
  * Type-safe event emitter with zero dependencies
@@ -101,4 +101,26 @@ declare class PushFloClient extends TypedEventEmitter<PushFloClientEvents> {
101
101
  private handleServerMessage;
102
102
  }
103
103
 
104
- export { PushFloClient as P };
104
+ /**
105
+ * Error thrown when connection to PushFlo fails
106
+ */
107
+ declare class ConnectionError extends PushFloError {
108
+ constructor(message: string, code?: string, options?: {
109
+ retryable?: boolean;
110
+ cause?: Error;
111
+ });
112
+ /**
113
+ * Create a connection timeout error
114
+ */
115
+ static timeout(timeoutMs: number): ConnectionError;
116
+ /**
117
+ * Create a connection closed error
118
+ */
119
+ static closed(reason?: string): ConnectionError;
120
+ /**
121
+ * Create a connection failed error
122
+ */
123
+ static failed(reason?: string, cause?: Error): ConnectionError;
124
+ }
125
+
126
+ export { ConnectionError as C, PushFloClient as P };
@@ -127,4 +127,95 @@ interface SubscriptionOptions {
127
127
  onUnsubscribed?: () => void;
128
128
  }
129
129
 
130
- export type { ClientOptions as C, Message as M, PublishOptions as P, Subscription as S, ConnectionInfo as a, ConnectionState as b, MessageHistoryOptions as c, PublishResult as d, SubscriptionOptions as e, ServerOptions as f };
130
+ /**
131
+ * Base error class for all PushFlo SDK errors
132
+ */
133
+ declare class PushFloError extends Error {
134
+ /** Error code for programmatic handling */
135
+ readonly code: string;
136
+ /** Whether this error is potentially recoverable through retry */
137
+ readonly retryable: boolean;
138
+ /** Original error that caused this error, if any */
139
+ readonly cause?: Error;
140
+ constructor(message: string, code: string, options?: {
141
+ retryable?: boolean;
142
+ cause?: Error;
143
+ });
144
+ /**
145
+ * Convert error to JSON-serializable object
146
+ */
147
+ toJSON(): Record<string, unknown>;
148
+ /**
149
+ * Create a string representation
150
+ */
151
+ toString(): string;
152
+ }
153
+
154
+ /**
155
+ * Error thrown when authentication fails
156
+ */
157
+ declare class AuthenticationError extends PushFloError {
158
+ constructor(message: string, code?: string, options?: {
159
+ retryable?: boolean;
160
+ cause?: Error;
161
+ });
162
+ /**
163
+ * Create an invalid API key error
164
+ */
165
+ static invalidKey(keyType?: string): AuthenticationError;
166
+ /**
167
+ * Create an unauthorized error
168
+ */
169
+ static unauthorized(reason?: string): AuthenticationError;
170
+ /**
171
+ * Create a forbidden error
172
+ */
173
+ static forbidden(action?: string): AuthenticationError;
174
+ }
175
+
176
+ /**
177
+ * Error thrown for network-related failures
178
+ */
179
+ declare class NetworkError extends PushFloError {
180
+ /** HTTP status code, if applicable */
181
+ readonly statusCode?: number;
182
+ constructor(message: string, code?: string, options?: {
183
+ retryable?: boolean;
184
+ cause?: Error;
185
+ statusCode?: number;
186
+ });
187
+ /**
188
+ * Create a network error from fetch failure
189
+ */
190
+ static fromFetch(cause: Error): NetworkError;
191
+ /**
192
+ * Create a request timeout error
193
+ */
194
+ static timeout(timeoutMs: number): NetworkError;
195
+ /**
196
+ * Create an error from HTTP status code
197
+ */
198
+ static fromStatus(statusCode: number, message?: string): NetworkError;
199
+ private static getStatusMessage;
200
+ toJSON(): Record<string, unknown>;
201
+ }
202
+
203
+ /**
204
+ * Error thrown when input validation fails
205
+ */
206
+ declare class ValidationError extends PushFloError {
207
+ /** The field that failed validation */
208
+ readonly field?: string;
209
+ constructor(message: string, field?: string);
210
+ /**
211
+ * Create an error for an invalid channel slug
212
+ */
213
+ static invalidChannelSlug(slug: string): ValidationError;
214
+ /**
215
+ * Create an error for a required field
216
+ */
217
+ static required(field: string): ValidationError;
218
+ toJSON(): Record<string, unknown>;
219
+ }
220
+
221
+ export { AuthenticationError as A, type ClientOptions as C, type Message as M, NetworkError as N, type PublishOptions as P, type Subscription as S, ValidationError as V, type ConnectionInfo as a, type ConnectionState as b, type MessageHistoryOptions as c, type PublishResult as d, PushFloError as e, type SubscriptionOptions as f, type ServerOptions as g };
@@ -127,4 +127,95 @@ interface SubscriptionOptions {
127
127
  onUnsubscribed?: () => void;
128
128
  }
129
129
 
130
- export type { ClientOptions as C, Message as M, PublishOptions as P, Subscription as S, ConnectionInfo as a, ConnectionState as b, MessageHistoryOptions as c, PublishResult as d, SubscriptionOptions as e, ServerOptions as f };
130
+ /**
131
+ * Base error class for all PushFlo SDK errors
132
+ */
133
+ declare class PushFloError extends Error {
134
+ /** Error code for programmatic handling */
135
+ readonly code: string;
136
+ /** Whether this error is potentially recoverable through retry */
137
+ readonly retryable: boolean;
138
+ /** Original error that caused this error, if any */
139
+ readonly cause?: Error;
140
+ constructor(message: string, code: string, options?: {
141
+ retryable?: boolean;
142
+ cause?: Error;
143
+ });
144
+ /**
145
+ * Convert error to JSON-serializable object
146
+ */
147
+ toJSON(): Record<string, unknown>;
148
+ /**
149
+ * Create a string representation
150
+ */
151
+ toString(): string;
152
+ }
153
+
154
+ /**
155
+ * Error thrown when authentication fails
156
+ */
157
+ declare class AuthenticationError extends PushFloError {
158
+ constructor(message: string, code?: string, options?: {
159
+ retryable?: boolean;
160
+ cause?: Error;
161
+ });
162
+ /**
163
+ * Create an invalid API key error
164
+ */
165
+ static invalidKey(keyType?: string): AuthenticationError;
166
+ /**
167
+ * Create an unauthorized error
168
+ */
169
+ static unauthorized(reason?: string): AuthenticationError;
170
+ /**
171
+ * Create a forbidden error
172
+ */
173
+ static forbidden(action?: string): AuthenticationError;
174
+ }
175
+
176
+ /**
177
+ * Error thrown for network-related failures
178
+ */
179
+ declare class NetworkError extends PushFloError {
180
+ /** HTTP status code, if applicable */
181
+ readonly statusCode?: number;
182
+ constructor(message: string, code?: string, options?: {
183
+ retryable?: boolean;
184
+ cause?: Error;
185
+ statusCode?: number;
186
+ });
187
+ /**
188
+ * Create a network error from fetch failure
189
+ */
190
+ static fromFetch(cause: Error): NetworkError;
191
+ /**
192
+ * Create a request timeout error
193
+ */
194
+ static timeout(timeoutMs: number): NetworkError;
195
+ /**
196
+ * Create an error from HTTP status code
197
+ */
198
+ static fromStatus(statusCode: number, message?: string): NetworkError;
199
+ private static getStatusMessage;
200
+ toJSON(): Record<string, unknown>;
201
+ }
202
+
203
+ /**
204
+ * Error thrown when input validation fails
205
+ */
206
+ declare class ValidationError extends PushFloError {
207
+ /** The field that failed validation */
208
+ readonly field?: string;
209
+ constructor(message: string, field?: string);
210
+ /**
211
+ * Create an error for an invalid channel slug
212
+ */
213
+ static invalidChannelSlug(slug: string): ValidationError;
214
+ /**
215
+ * Create an error for a required field
216
+ */
217
+ static required(field: string): ValidationError;
218
+ toJSON(): Record<string, unknown>;
219
+ }
220
+
221
+ export { AuthenticationError as A, type ClientOptions as C, type Message as M, NetworkError as N, type PublishOptions as P, type Subscription as S, ValidationError as V, type ConnectionInfo as a, type ConnectionState as b, type MessageHistoryOptions as c, type PublishResult as d, PushFloError as e, type SubscriptionOptions as f, type ServerOptions as g };
@@ -1,94 +1,3 @@
1
- /**
2
- * Base error class for all PushFlo SDK errors
3
- */
4
- declare class PushFloError extends Error {
5
- /** Error code for programmatic handling */
6
- readonly code: string;
7
- /** Whether this error is potentially recoverable through retry */
8
- readonly retryable: boolean;
9
- /** Original error that caused this error, if any */
10
- readonly cause?: Error;
11
- constructor(message: string, code: string, options?: {
12
- retryable?: boolean;
13
- cause?: Error;
14
- });
15
- /**
16
- * Convert error to JSON-serializable object
17
- */
18
- toJSON(): Record<string, unknown>;
19
- /**
20
- * Create a string representation
21
- */
22
- toString(): string;
23
- }
24
-
25
- /**
26
- * Error thrown when authentication fails
27
- */
28
- declare class AuthenticationError extends PushFloError {
29
- constructor(message: string, code?: string, options?: {
30
- retryable?: boolean;
31
- cause?: Error;
32
- });
33
- /**
34
- * Create an invalid API key error
35
- */
36
- static invalidKey(keyType?: string): AuthenticationError;
37
- /**
38
- * Create an unauthorized error
39
- */
40
- static unauthorized(reason?: string): AuthenticationError;
41
- /**
42
- * Create a forbidden error
43
- */
44
- static forbidden(action?: string): AuthenticationError;
45
- }
46
-
47
- /**
48
- * Error thrown for network-related failures
49
- */
50
- declare class NetworkError extends PushFloError {
51
- /** HTTP status code, if applicable */
52
- readonly statusCode?: number;
53
- constructor(message: string, code?: string, options?: {
54
- retryable?: boolean;
55
- cause?: Error;
56
- statusCode?: number;
57
- });
58
- /**
59
- * Create a network error from fetch failure
60
- */
61
- static fromFetch(cause: Error): NetworkError;
62
- /**
63
- * Create a request timeout error
64
- */
65
- static timeout(timeoutMs: number): NetworkError;
66
- /**
67
- * Create an error from HTTP status code
68
- */
69
- static fromStatus(statusCode: number, message?: string): NetworkError;
70
- private static getStatusMessage;
71
- toJSON(): Record<string, unknown>;
72
- }
73
-
74
- /**
75
- * Error thrown when input validation fails
76
- */
77
- declare class ValidationError extends PushFloError {
78
- /** The field that failed validation */
79
- readonly field?: string;
80
- constructor(message: string, field?: string);
81
- /**
82
- * Create an error for an invalid channel slug
83
- */
84
- static invalidChannelSlug(slug: string): ValidationError;
85
- /**
86
- * Create an error for a required field
87
- */
88
- static required(field: string): ValidationError;
89
- toJSON(): Record<string, unknown>;
90
- }
91
-
92
1
  /**
93
2
  * Channel slug validation utilities
94
3
  *
@@ -226,4 +135,4 @@ interface Pagination {
226
135
  totalPages: number;
227
136
  }
228
137
 
229
- export { AuthenticationError as A, type Channel as C, type ListChannelsOptions as L, MAX_SLUG_LENGTH as M, NetworkError as N, PushFloError as P, type SlugValidationResult as S, ValidationError as V, type ChannelInput as a, type ChannelUpdateInput as b, MIN_SLUG_LENGTH as c, type Pagination as d, isValidChannelSlug as i, toChannelSlug as t, validateChannelSlug as v };
138
+ export { type Channel as C, type ListChannelsOptions as L, MAX_SLUG_LENGTH as M, type Pagination as P, type SlugValidationResult as S, type ChannelInput as a, type ChannelUpdateInput as b, MIN_SLUG_LENGTH as c, isValidChannelSlug as i, toChannelSlug as t, validateChannelSlug as v };
@@ -1,94 +1,3 @@
1
- /**
2
- * Base error class for all PushFlo SDK errors
3
- */
4
- declare class PushFloError extends Error {
5
- /** Error code for programmatic handling */
6
- readonly code: string;
7
- /** Whether this error is potentially recoverable through retry */
8
- readonly retryable: boolean;
9
- /** Original error that caused this error, if any */
10
- readonly cause?: Error;
11
- constructor(message: string, code: string, options?: {
12
- retryable?: boolean;
13
- cause?: Error;
14
- });
15
- /**
16
- * Convert error to JSON-serializable object
17
- */
18
- toJSON(): Record<string, unknown>;
19
- /**
20
- * Create a string representation
21
- */
22
- toString(): string;
23
- }
24
-
25
- /**
26
- * Error thrown when authentication fails
27
- */
28
- declare class AuthenticationError extends PushFloError {
29
- constructor(message: string, code?: string, options?: {
30
- retryable?: boolean;
31
- cause?: Error;
32
- });
33
- /**
34
- * Create an invalid API key error
35
- */
36
- static invalidKey(keyType?: string): AuthenticationError;
37
- /**
38
- * Create an unauthorized error
39
- */
40
- static unauthorized(reason?: string): AuthenticationError;
41
- /**
42
- * Create a forbidden error
43
- */
44
- static forbidden(action?: string): AuthenticationError;
45
- }
46
-
47
- /**
48
- * Error thrown for network-related failures
49
- */
50
- declare class NetworkError extends PushFloError {
51
- /** HTTP status code, if applicable */
52
- readonly statusCode?: number;
53
- constructor(message: string, code?: string, options?: {
54
- retryable?: boolean;
55
- cause?: Error;
56
- statusCode?: number;
57
- });
58
- /**
59
- * Create a network error from fetch failure
60
- */
61
- static fromFetch(cause: Error): NetworkError;
62
- /**
63
- * Create a request timeout error
64
- */
65
- static timeout(timeoutMs: number): NetworkError;
66
- /**
67
- * Create an error from HTTP status code
68
- */
69
- static fromStatus(statusCode: number, message?: string): NetworkError;
70
- private static getStatusMessage;
71
- toJSON(): Record<string, unknown>;
72
- }
73
-
74
- /**
75
- * Error thrown when input validation fails
76
- */
77
- declare class ValidationError extends PushFloError {
78
- /** The field that failed validation */
79
- readonly field?: string;
80
- constructor(message: string, field?: string);
81
- /**
82
- * Create an error for an invalid channel slug
83
- */
84
- static invalidChannelSlug(slug: string): ValidationError;
85
- /**
86
- * Create an error for a required field
87
- */
88
- static required(field: string): ValidationError;
89
- toJSON(): Record<string, unknown>;
90
- }
91
-
92
1
  /**
93
2
  * Channel slug validation utilities
94
3
  *
@@ -226,4 +135,4 @@ interface Pagination {
226
135
  totalPages: number;
227
136
  }
228
137
 
229
- export { AuthenticationError as A, type Channel as C, type ListChannelsOptions as L, MAX_SLUG_LENGTH as M, NetworkError as N, PushFloError as P, type SlugValidationResult as S, ValidationError as V, type ChannelInput as a, type ChannelUpdateInput as b, MIN_SLUG_LENGTH as c, type Pagination as d, isValidChannelSlug as i, toChannelSlug as t, validateChannelSlug as v };
138
+ export { type Channel as C, type ListChannelsOptions as L, MAX_SLUG_LENGTH as M, type Pagination as P, type SlugValidationResult as S, type ChannelInput as a, type ChannelUpdateInput as b, MIN_SLUG_LENGTH as c, isValidChannelSlug as i, toChannelSlug as t, validateChannelSlug as v };
package/dist/index.d.cts CHANGED
@@ -1,28 +1,3 @@
1
- export { P as PushFloClient } from './PushFloClient-DqOYR0GV.cjs';
2
- import { P as PushFloError } from './api-Dgp2k2ZF.cjs';
3
- export { A as AuthenticationError, C as Channel, a as ChannelInput, b as ChannelUpdateInput, L as ListChannelsOptions, M as MAX_SLUG_LENGTH, c as MIN_SLUG_LENGTH, N as NetworkError, d as Pagination, S as SlugValidationResult, V as ValidationError, i as isValidChannelSlug, t as toChannelSlug, v as validateChannelSlug } from './api-Dgp2k2ZF.cjs';
4
- export { C as ClientOptions, a as ConnectionInfo, b as ConnectionState, M as Message, c as MessageHistoryOptions, P as PublishOptions, d as PublishResult, S as Subscription, e as SubscriptionOptions } from './message-CVgilLwz.cjs';
5
-
6
- /**
7
- * Error thrown when connection to PushFlo fails
8
- */
9
- declare class ConnectionError extends PushFloError {
10
- constructor(message: string, code?: string, options?: {
11
- retryable?: boolean;
12
- cause?: Error;
13
- });
14
- /**
15
- * Create a connection timeout error
16
- */
17
- static timeout(timeoutMs: number): ConnectionError;
18
- /**
19
- * Create a connection closed error
20
- */
21
- static closed(reason?: string): ConnectionError;
22
- /**
23
- * Create a connection failed error
24
- */
25
- static failed(reason?: string, cause?: Error): ConnectionError;
26
- }
27
-
28
- export { ConnectionError, PushFloError };
1
+ export { C as ConnectionError, P as PushFloClient } from './ConnectionError-DMzDtJlz.cjs';
2
+ export { A as AuthenticationError, C as ClientOptions, a as ConnectionInfo, b as ConnectionState, M as Message, c as MessageHistoryOptions, N as NetworkError, P as PublishOptions, d as PublishResult, e as PushFloError, S as Subscription, f as SubscriptionOptions, V as ValidationError } from './ValidationError-izGOr1dF.cjs';
3
+ export { C as Channel, a as ChannelInput, b as ChannelUpdateInput, L as ListChannelsOptions, M as MAX_SLUG_LENGTH, c as MIN_SLUG_LENGTH, P as Pagination, S as SlugValidationResult, i as isValidChannelSlug, t as toChannelSlug, v as validateChannelSlug } from './api-DKISn33_.cjs';
package/dist/index.d.ts CHANGED
@@ -1,28 +1,3 @@
1
- export { P as PushFloClient } from './PushFloClient-B4smuFOa.js';
2
- import { P as PushFloError } from './api-Dgp2k2ZF.js';
3
- export { A as AuthenticationError, C as Channel, a as ChannelInput, b as ChannelUpdateInput, L as ListChannelsOptions, M as MAX_SLUG_LENGTH, c as MIN_SLUG_LENGTH, N as NetworkError, d as Pagination, S as SlugValidationResult, V as ValidationError, i as isValidChannelSlug, t as toChannelSlug, v as validateChannelSlug } from './api-Dgp2k2ZF.js';
4
- export { C as ClientOptions, a as ConnectionInfo, b as ConnectionState, M as Message, c as MessageHistoryOptions, P as PublishOptions, d as PublishResult, S as Subscription, e as SubscriptionOptions } from './message-CVgilLwz.js';
5
-
6
- /**
7
- * Error thrown when connection to PushFlo fails
8
- */
9
- declare class ConnectionError extends PushFloError {
10
- constructor(message: string, code?: string, options?: {
11
- retryable?: boolean;
12
- cause?: Error;
13
- });
14
- /**
15
- * Create a connection timeout error
16
- */
17
- static timeout(timeoutMs: number): ConnectionError;
18
- /**
19
- * Create a connection closed error
20
- */
21
- static closed(reason?: string): ConnectionError;
22
- /**
23
- * Create a connection failed error
24
- */
25
- static failed(reason?: string, cause?: Error): ConnectionError;
26
- }
27
-
28
- export { ConnectionError, PushFloError };
1
+ export { C as ConnectionError, P as PushFloClient } from './ConnectionError-CfKkkpfA.js';
2
+ export { A as AuthenticationError, C as ClientOptions, a as ConnectionInfo, b as ConnectionState, M as Message, c as MessageHistoryOptions, N as NetworkError, P as PublishOptions, d as PublishResult, e as PushFloError, S as Subscription, f as SubscriptionOptions, V as ValidationError } from './ValidationError-izGOr1dF.js';
3
+ export { C as Channel, a as ChannelInput, b as ChannelUpdateInput, L as ListChannelsOptions, M as MAX_SLUG_LENGTH, c as MIN_SLUG_LENGTH, P as Pagination, S as SlugValidationResult, i as isValidChannelSlug, t as toChannelSlug, v as validateChannelSlug } from './api-DKISn33_.js';
package/dist/react.cjs CHANGED
@@ -123,6 +123,13 @@ var ERROR_CODES = {
123
123
  INVALID_API_KEY: "INVALID_API_KEY",
124
124
  UNAUTHORIZED: "UNAUTHORIZED",
125
125
  FORBIDDEN: "FORBIDDEN",
126
+ // Network errors
127
+ NETWORK_ERROR: "NETWORK_ERROR",
128
+ REQUEST_TIMEOUT: "REQUEST_TIMEOUT",
129
+ // API errors
130
+ NOT_FOUND: "NOT_FOUND",
131
+ VALIDATION_ERROR: "VALIDATION_ERROR",
132
+ RATE_LIMITED: "RATE_LIMITED",
126
133
  SERVER_ERROR: "SERVER_ERROR"};
127
134
 
128
135
  // src/utils/logger.ts
@@ -1346,7 +1353,82 @@ function useChannel(channel, options = {}) {
1346
1353
  };
1347
1354
  }
1348
1355
 
1356
+ // src/errors/NetworkError.ts
1357
+ var NetworkError = class _NetworkError extends PushFloError {
1358
+ /** HTTP status code, if applicable */
1359
+ statusCode;
1360
+ constructor(message, code = ERROR_CODES.NETWORK_ERROR, options = {}) {
1361
+ super(message, code, { retryable: true, ...options });
1362
+ this.name = "NetworkError";
1363
+ this.statusCode = options.statusCode;
1364
+ }
1365
+ /**
1366
+ * Create a network error from fetch failure
1367
+ */
1368
+ static fromFetch(cause) {
1369
+ return new _NetworkError(
1370
+ `Network request failed: ${cause.message}`,
1371
+ ERROR_CODES.NETWORK_ERROR,
1372
+ { retryable: true, cause }
1373
+ );
1374
+ }
1375
+ /**
1376
+ * Create a request timeout error
1377
+ */
1378
+ static timeout(timeoutMs) {
1379
+ return new _NetworkError(
1380
+ `Request timed out after ${timeoutMs}ms`,
1381
+ ERROR_CODES.REQUEST_TIMEOUT,
1382
+ { retryable: true }
1383
+ );
1384
+ }
1385
+ /**
1386
+ * Create an error from HTTP status code
1387
+ */
1388
+ static fromStatus(statusCode, message) {
1389
+ const defaultMessage = _NetworkError.getStatusMessage(statusCode);
1390
+ const retryable = statusCode >= 500 || statusCode === 429;
1391
+ let code = ERROR_CODES.SERVER_ERROR;
1392
+ if (statusCode === 404) {
1393
+ code = ERROR_CODES.NOT_FOUND;
1394
+ } else if (statusCode === 422 || statusCode === 400) {
1395
+ code = ERROR_CODES.VALIDATION_ERROR;
1396
+ } else if (statusCode === 429) {
1397
+ code = ERROR_CODES.RATE_LIMITED;
1398
+ }
1399
+ return new _NetworkError(
1400
+ message ?? defaultMessage,
1401
+ code,
1402
+ { retryable, statusCode }
1403
+ );
1404
+ }
1405
+ static getStatusMessage(statusCode) {
1406
+ const messages = {
1407
+ 400: "Bad request",
1408
+ 404: "Resource not found",
1409
+ 422: "Validation error",
1410
+ 429: "Rate limit exceeded",
1411
+ 500: "Internal server error",
1412
+ 502: "Bad gateway",
1413
+ 503: "Service unavailable",
1414
+ 504: "Gateway timeout"
1415
+ };
1416
+ return messages[statusCode] ?? `HTTP error ${statusCode}`;
1417
+ }
1418
+ toJSON() {
1419
+ return {
1420
+ ...super.toJSON(),
1421
+ statusCode: this.statusCode
1422
+ };
1423
+ }
1424
+ };
1425
+
1426
+ exports.AuthenticationError = AuthenticationError;
1427
+ exports.ConnectionError = ConnectionError;
1428
+ exports.NetworkError = NetworkError;
1429
+ exports.PushFloError = PushFloError;
1349
1430
  exports.PushFloProvider = PushFloProvider;
1431
+ exports.ValidationError = ValidationError;
1350
1432
  exports.useChannel = useChannel;
1351
1433
  exports.usePushFlo = usePushFlo;
1352
1434
  exports.usePushFloContext = usePushFloContext;