@attrove/sdk 0.1.3 → 0.1.4
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/cjs/README.md +247 -0
- package/cjs/package.json +56 -0
- package/cjs/src/__mocks__/version.js +17 -0
- package/cjs/src/__mocks__/version.js.map +1 -0
- package/cjs/src/admin-client.js +221 -0
- package/cjs/src/admin-client.js.map +1 -0
- package/cjs/src/client.js +312 -0
- package/cjs/src/client.js.map +1 -0
- package/cjs/src/constants.js +69 -0
- package/cjs/src/constants.js.map +1 -0
- package/cjs/src/errors/index.js +307 -0
- package/cjs/src/errors/index.js.map +1 -0
- package/cjs/src/index.js +98 -0
- package/cjs/src/index.js.map +1 -0
- package/cjs/src/resources/conversations.js +95 -0
- package/cjs/src/resources/conversations.js.map +1 -0
- package/cjs/src/resources/index.js +17 -0
- package/cjs/src/resources/index.js.map +1 -0
- package/cjs/src/resources/integrations.js +69 -0
- package/cjs/src/resources/integrations.js.map +1 -0
- package/cjs/src/resources/messages.js +98 -0
- package/cjs/src/resources/messages.js.map +1 -0
- package/cjs/src/resources/query.js +143 -0
- package/cjs/src/resources/query.js.map +1 -0
- package/cjs/src/resources/users.js +91 -0
- package/cjs/src/resources/users.js.map +1 -0
- package/cjs/src/types/index.js +292 -0
- package/cjs/src/types/index.js.map +1 -0
- package/cjs/src/utils/fetch.js +417 -0
- package/cjs/src/utils/fetch.js.map +1 -0
- package/cjs/src/utils/index.js +12 -0
- package/cjs/src/utils/index.js.map +1 -0
- package/cjs/src/utils/streaming.js +368 -0
- package/cjs/src/utils/streaming.js.map +1 -0
- package/cjs/src/version.js +31 -0
- package/cjs/src/version.js.map +1 -0
- package/esm/README.md +247 -0
- package/esm/package.json +56 -0
- package/esm/src/__mocks__/version.js +12 -0
- package/esm/src/__mocks__/version.js.map +1 -0
- package/esm/src/admin-client.js +216 -0
- package/esm/src/admin-client.js.map +1 -0
- package/esm/src/client.js +308 -0
- package/esm/src/client.js.map +1 -0
- package/esm/src/constants.js +65 -0
- package/esm/src/constants.js.map +1 -0
- package/esm/src/errors/index.js +285 -0
- package/esm/src/errors/index.js.map +1 -0
- package/esm/src/index.js +68 -0
- package/esm/src/index.js.map +1 -0
- package/esm/src/resources/conversations.js +91 -0
- package/esm/src/resources/conversations.js.map +1 -0
- package/esm/src/resources/index.js +9 -0
- package/esm/src/resources/index.js.map +1 -0
- package/esm/src/resources/integrations.js +65 -0
- package/esm/src/resources/integrations.js.map +1 -0
- package/esm/src/resources/messages.js +94 -0
- package/esm/src/resources/messages.js.map +1 -0
- package/esm/src/resources/query.js +139 -0
- package/esm/src/resources/query.js.map +1 -0
- package/esm/src/resources/users.js +87 -0
- package/esm/src/resources/users.js.map +1 -0
- package/esm/src/types/index.js +277 -0
- package/esm/src/types/index.js.map +1 -0
- package/esm/src/utils/fetch.js +413 -0
- package/esm/src/utils/fetch.js.map +1 -0
- package/esm/src/utils/index.js +6 -0
- package/esm/src/utils/index.js.map +1 -0
- package/esm/src/utils/streaming.js +363 -0
- package/esm/src/utils/streaming.js.map +1 -0
- package/esm/src/version.js +26 -0
- package/esm/src/version.js.map +1 -0
- package/package.json +16 -9
- package/types/src/__mocks__/version.d.ts +8 -0
- package/types/src/__mocks__/version.d.ts.map +1 -0
- package/types/src/admin-client.d.ts +144 -0
- package/types/src/admin-client.d.ts.map +1 -0
- package/types/src/client.d.ts +233 -0
- package/types/src/client.d.ts.map +1 -0
- package/types/src/constants.d.ts +47 -0
- package/types/src/constants.d.ts.map +1 -0
- package/types/src/errors/index.d.ts +206 -0
- package/types/src/errors/index.d.ts.map +1 -0
- package/types/src/index.d.ts +65 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/resources/conversations.d.ts +81 -0
- package/types/src/resources/conversations.d.ts.map +1 -0
- package/types/src/resources/index.d.ts +12 -0
- package/types/src/resources/index.d.ts.map +1 -0
- package/types/src/resources/integrations.d.ts +63 -0
- package/types/src/resources/integrations.d.ts.map +1 -0
- package/types/src/resources/messages.d.ts +69 -0
- package/types/src/resources/messages.d.ts.map +1 -0
- package/types/src/resources/query.d.ts +86 -0
- package/types/src/resources/query.d.ts.map +1 -0
- package/types/src/resources/users.d.ts +88 -0
- package/types/src/resources/users.d.ts.map +1 -0
- package/types/src/types/index.d.ts +807 -0
- package/types/src/types/index.d.ts.map +1 -0
- package/types/src/utils/fetch.d.ts +161 -0
- package/types/src/utils/fetch.d.ts.map +1 -0
- package/types/src/utils/index.d.ts +8 -0
- package/types/src/utils/index.d.ts.map +1 -0
- package/types/src/utils/streaming.d.ts +210 -0
- package/types/src/utils/streaming.d.ts.map +1 -0
- package/types/src/version.d.ts +21 -0
- package/types/src/version.d.ts.map +1 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP Client with Retries
|
|
4
|
+
*
|
|
5
|
+
* Provides a robust fetch wrapper with automatic retries, timeout handling,
|
|
6
|
+
* and proper error mapping.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HttpClient = void 0;
|
|
10
|
+
const errors_1 = require("../errors");
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
|
+
/**
|
|
14
|
+
* Delay execution during retry backoff.
|
|
15
|
+
* Used between retry attempts to avoid overwhelming the server.
|
|
16
|
+
*/
|
|
17
|
+
function sleep(ms) {
|
|
18
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calculate retry delay with exponential backoff and jitter.
|
|
22
|
+
*/
|
|
23
|
+
function calculateRetryDelay(attempt, retryAfter) {
|
|
24
|
+
if (retryAfter !== undefined && retryAfter > 0) {
|
|
25
|
+
return retryAfter * 1000;
|
|
26
|
+
}
|
|
27
|
+
// Exponential backoff with jitter
|
|
28
|
+
const exponentialDelay = constants_1.INITIAL_RETRY_DELAY * Math.pow(2, attempt);
|
|
29
|
+
const jitter = Math.random() * 0.3 * exponentialDelay;
|
|
30
|
+
return Math.floor(exponentialDelay + jitter);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse the Retry-After header value.
|
|
34
|
+
* Returns undefined if the header is missing, invalid, or not a positive number.
|
|
35
|
+
*/
|
|
36
|
+
function parseRetryAfter(header) {
|
|
37
|
+
if (!header)
|
|
38
|
+
return undefined;
|
|
39
|
+
// Try parsing as seconds (integer)
|
|
40
|
+
const seconds = parseInt(header, 10);
|
|
41
|
+
if (!Number.isNaN(seconds) && seconds > 0) {
|
|
42
|
+
return seconds;
|
|
43
|
+
}
|
|
44
|
+
// Try parsing as HTTP date
|
|
45
|
+
const date = Date.parse(header);
|
|
46
|
+
if (!Number.isNaN(date)) {
|
|
47
|
+
const diffSeconds = Math.ceil((date - Date.now()) / 1000);
|
|
48
|
+
return diffSeconds > 0 ? diffSeconds : undefined;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Convert legacy config to new config format.
|
|
54
|
+
* @throws {ValidationError} If partial credentials are provided
|
|
55
|
+
*/
|
|
56
|
+
function normalizeConfig(config) {
|
|
57
|
+
let auth;
|
|
58
|
+
// Check for partial API key credentials
|
|
59
|
+
if (config.apiKey && !config.userId) {
|
|
60
|
+
throw new errors_1.ValidationError('userId is required when using apiKey authentication', types_1.ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: 'userId', providedFields: ['apiKey'] });
|
|
61
|
+
}
|
|
62
|
+
if (!config.apiKey && config.userId) {
|
|
63
|
+
throw new errors_1.ValidationError('apiKey is required when using user authentication', types_1.ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: 'apiKey', providedFields: ['userId'] });
|
|
64
|
+
}
|
|
65
|
+
// Check for partial partner credentials
|
|
66
|
+
if (config.clientId && !config.clientSecret) {
|
|
67
|
+
throw new errors_1.ValidationError('clientSecret is required when using partner authentication', types_1.ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: 'clientSecret', providedFields: ['clientId'] });
|
|
68
|
+
}
|
|
69
|
+
if (!config.clientId && config.clientSecret) {
|
|
70
|
+
throw new errors_1.ValidationError('clientId is required when using partner authentication', types_1.ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: 'clientId', providedFields: ['clientSecret'] });
|
|
71
|
+
}
|
|
72
|
+
if (config.apiKey && config.userId) {
|
|
73
|
+
auth = { type: 'apiKey', apiKey: config.apiKey, userId: config.userId };
|
|
74
|
+
}
|
|
75
|
+
else if (config.clientId && config.clientSecret) {
|
|
76
|
+
auth = { type: 'partner', clientId: config.clientId, clientSecret: config.clientSecret };
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
auth = { type: 'none' };
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
baseUrl: config.baseUrl.replace(/\/$/, ''),
|
|
83
|
+
auth,
|
|
84
|
+
timeout: config.timeout ?? constants_1.DEFAULT_TIMEOUT,
|
|
85
|
+
maxRetries: config.maxRetries ?? constants_1.DEFAULT_MAX_RETRIES,
|
|
86
|
+
onRetry: config.onRetry,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* HTTP client with automatic retries and error handling.
|
|
91
|
+
*
|
|
92
|
+
* Features:
|
|
93
|
+
* - Automatic retries with exponential backoff
|
|
94
|
+
* - Respects Retry-After headers
|
|
95
|
+
* - Proper error mapping to SDK error types
|
|
96
|
+
* - Support for API key and partner authentication
|
|
97
|
+
* - Optional retry callbacks for monitoring
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const client = new HttpClient({
|
|
102
|
+
* baseUrl: 'https://api.attrove.com',
|
|
103
|
+
* apiKey: 'sk_...',
|
|
104
|
+
* userId: 'user-uuid',
|
|
105
|
+
* onRetry: (info) => console.log(`Retrying (${info.attempt}/${info.maxRetries})...`)
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
class HttpClient {
|
|
110
|
+
constructor(config) {
|
|
111
|
+
this.config = normalizeConfig(config);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Build the full URL for a request.
|
|
115
|
+
*/
|
|
116
|
+
buildUrl(path, params) {
|
|
117
|
+
const url = new URL(path, this.config.baseUrl);
|
|
118
|
+
if (params) {
|
|
119
|
+
for (const [key, value] of Object.entries(params)) {
|
|
120
|
+
if (value !== undefined) {
|
|
121
|
+
if (Array.isArray(value)) {
|
|
122
|
+
value.forEach((v) => url.searchParams.append(key, v));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
url.searchParams.set(key, value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return url.toString();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Build headers for a request.
|
|
134
|
+
*/
|
|
135
|
+
buildHeaders(customHeaders) {
|
|
136
|
+
const headers = {
|
|
137
|
+
'Content-Type': 'application/json',
|
|
138
|
+
'Accept': 'application/json',
|
|
139
|
+
'User-Agent': `@attrove/sdk/${constants_1.SDK_VERSION}`,
|
|
140
|
+
...customHeaders,
|
|
141
|
+
};
|
|
142
|
+
const { auth } = this.config;
|
|
143
|
+
if (auth.type === 'apiKey') {
|
|
144
|
+
headers['Authorization'] = `Bearer ${auth.apiKey}`;
|
|
145
|
+
headers['X-Auth-Type'] = 'api';
|
|
146
|
+
headers['X-User-Id'] = auth.userId;
|
|
147
|
+
}
|
|
148
|
+
else if (auth.type === 'partner') {
|
|
149
|
+
headers['Authorization'] = `Bearer ${auth.clientSecret}`;
|
|
150
|
+
headers['X-Auth-Type'] = 'partner';
|
|
151
|
+
}
|
|
152
|
+
return headers;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Parse error from API response.
|
|
156
|
+
* Normalizes string errors to ApiError format.
|
|
157
|
+
*/
|
|
158
|
+
parseApiError(body, status) {
|
|
159
|
+
// Handle structured error response
|
|
160
|
+
if (body && typeof body === 'object' && 'error' in body) {
|
|
161
|
+
const errorResponse = body;
|
|
162
|
+
const error = errorResponse.error;
|
|
163
|
+
if (typeof error === 'string') {
|
|
164
|
+
return (0, errors_1.createErrorFromStatus)(error, status);
|
|
165
|
+
}
|
|
166
|
+
return (0, errors_1.createErrorFromStatus)(error.message, status, error.code, error.details);
|
|
167
|
+
}
|
|
168
|
+
// Handle unknown error format - include response preview for debugging
|
|
169
|
+
let message;
|
|
170
|
+
if (typeof body === 'string') {
|
|
171
|
+
message = body || 'Empty error response';
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
try {
|
|
175
|
+
message = `Unexpected error format: ${JSON.stringify(body).substring(0, 100)}`;
|
|
176
|
+
}
|
|
177
|
+
catch (serializeError) {
|
|
178
|
+
// Preserve serialization error context for debugging
|
|
179
|
+
const reason = serializeError instanceof Error ? serializeError.message : 'Unknown reason';
|
|
180
|
+
message = `Unknown error occurred (response not serializable: ${reason})`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return (0, errors_1.createErrorFromStatus)(message, status);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Make a request with automatic retries.
|
|
187
|
+
*
|
|
188
|
+
* @param path - API path (relative to base URL)
|
|
189
|
+
* @param config - Request configuration
|
|
190
|
+
* @param queryParams - Optional query parameters
|
|
191
|
+
* @returns Parsed response data
|
|
192
|
+
*
|
|
193
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
194
|
+
* @throws {AuthorizationError} When authorization fails (403)
|
|
195
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
196
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
197
|
+
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
198
|
+
* @throws {TimeoutError} When request times out
|
|
199
|
+
* @throws {NetworkError} When network errors occur
|
|
200
|
+
* @throws {ServerError} When server errors occur (5xx)
|
|
201
|
+
*/
|
|
202
|
+
async request(path, config = {}, queryParams) {
|
|
203
|
+
const method = config.method ?? 'GET';
|
|
204
|
+
const url = this.buildUrl(path, queryParams);
|
|
205
|
+
const headers = this.buildHeaders(config.headers);
|
|
206
|
+
const timeout = config.timeout ?? this.config.timeout;
|
|
207
|
+
let lastError;
|
|
208
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
209
|
+
try {
|
|
210
|
+
const controller = new AbortController();
|
|
211
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
212
|
+
const fetchOptions = {
|
|
213
|
+
method,
|
|
214
|
+
headers,
|
|
215
|
+
signal: controller.signal,
|
|
216
|
+
};
|
|
217
|
+
if (config.body && method !== 'GET') {
|
|
218
|
+
fetchOptions.body = JSON.stringify(config.body);
|
|
219
|
+
}
|
|
220
|
+
const response = await fetch(url, fetchOptions);
|
|
221
|
+
clearTimeout(timeoutId);
|
|
222
|
+
// Parse response body with explicit JSON error handling
|
|
223
|
+
let body;
|
|
224
|
+
const contentType = response.headers.get('content-type');
|
|
225
|
+
if (contentType?.includes('application/json')) {
|
|
226
|
+
const text = await response.text();
|
|
227
|
+
try {
|
|
228
|
+
body = JSON.parse(text);
|
|
229
|
+
}
|
|
230
|
+
catch (parseError) {
|
|
231
|
+
// JSON parse errors are not retryable
|
|
232
|
+
throw new errors_1.ServerError(`Server returned invalid JSON: ${parseError instanceof Error ? parseError.message : 'Parse failed'}`, response.status, { responsePreview: text.substring(0, 200) });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
body = await response.text();
|
|
237
|
+
}
|
|
238
|
+
// Handle successful response
|
|
239
|
+
if (response.ok) {
|
|
240
|
+
// Handle wrapped API responses
|
|
241
|
+
if (body && typeof body === 'object' && 'success' in body) {
|
|
242
|
+
const apiResponse = body;
|
|
243
|
+
if (apiResponse.success) {
|
|
244
|
+
// Paginated responses have a `pagination` field - preserve the full structure
|
|
245
|
+
if ('pagination' in body) {
|
|
246
|
+
return body;
|
|
247
|
+
}
|
|
248
|
+
return apiResponse.data;
|
|
249
|
+
}
|
|
250
|
+
// API returned success: false
|
|
251
|
+
throw this.parseApiError(body, response.status);
|
|
252
|
+
}
|
|
253
|
+
return body;
|
|
254
|
+
}
|
|
255
|
+
// Handle error response
|
|
256
|
+
const error = this.parseApiError(body, response.status);
|
|
257
|
+
// Check if we should retry
|
|
258
|
+
if (attempt < this.config.maxRetries && constants_1.RETRYABLE_STATUS_SET.has(response.status)) {
|
|
259
|
+
const retryAfterSeconds = parseRetryAfter(response.headers.get('retry-after'));
|
|
260
|
+
const delay = calculateRetryDelay(attempt, retryAfterSeconds);
|
|
261
|
+
// Call retry callback if provided
|
|
262
|
+
if (this.config.onRetry) {
|
|
263
|
+
this.config.onRetry({
|
|
264
|
+
attempt: attempt + 1,
|
|
265
|
+
maxRetries: this.config.maxRetries,
|
|
266
|
+
error,
|
|
267
|
+
delayMs: delay,
|
|
268
|
+
url,
|
|
269
|
+
method,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
lastError = error;
|
|
273
|
+
await sleep(delay);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
catch (err) {
|
|
279
|
+
// Handle abort/timeout
|
|
280
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
281
|
+
const timeoutError = new errors_1.TimeoutError(`Request timed out after ${timeout}ms`);
|
|
282
|
+
if (attempt < this.config.maxRetries) {
|
|
283
|
+
const delay = calculateRetryDelay(attempt);
|
|
284
|
+
if (this.config.onRetry) {
|
|
285
|
+
this.config.onRetry({
|
|
286
|
+
attempt: attempt + 1,
|
|
287
|
+
maxRetries: this.config.maxRetries,
|
|
288
|
+
error: timeoutError,
|
|
289
|
+
delayMs: delay,
|
|
290
|
+
url,
|
|
291
|
+
method,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
lastError = timeoutError;
|
|
295
|
+
await sleep(delay);
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
throw timeoutError;
|
|
299
|
+
}
|
|
300
|
+
// Handle network errors
|
|
301
|
+
if (err instanceof TypeError && err.message.includes('fetch')) {
|
|
302
|
+
const networkError = new errors_1.NetworkError(`Network error: ${err.message}. Check your connection and ensure the API endpoint is accessible.`);
|
|
303
|
+
if (attempt < this.config.maxRetries) {
|
|
304
|
+
const delay = calculateRetryDelay(attempt);
|
|
305
|
+
if (this.config.onRetry) {
|
|
306
|
+
this.config.onRetry({
|
|
307
|
+
attempt: attempt + 1,
|
|
308
|
+
maxRetries: this.config.maxRetries,
|
|
309
|
+
error: networkError,
|
|
310
|
+
delayMs: delay,
|
|
311
|
+
url,
|
|
312
|
+
method,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
lastError = networkError;
|
|
316
|
+
await sleep(delay);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
throw networkError;
|
|
320
|
+
}
|
|
321
|
+
// Re-throw AttroveErrors (including ServerError from JSON parse)
|
|
322
|
+
if (err instanceof errors_1.AttroveError) {
|
|
323
|
+
throw err;
|
|
324
|
+
}
|
|
325
|
+
// Handle unexpected errors - preserve as much context as possible
|
|
326
|
+
const originalError = err instanceof Error ? err : new Error(String(err));
|
|
327
|
+
const errorDetails = {
|
|
328
|
+
originalErrorName: originalError.name,
|
|
329
|
+
originalErrorMessage: originalError.message,
|
|
330
|
+
};
|
|
331
|
+
if (originalError.stack) {
|
|
332
|
+
errorDetails.originalStack = originalError.stack.split('\n').slice(0, 5).join('\n');
|
|
333
|
+
}
|
|
334
|
+
// Wrap in ServerError to indicate this was an unexpected failure
|
|
335
|
+
const wrappedError = new errors_1.ServerError(`Unexpected error during request: ${originalError.message}`, undefined, // No status code for unexpected errors
|
|
336
|
+
errorDetails);
|
|
337
|
+
lastError = wrappedError;
|
|
338
|
+
if (attempt < this.config.maxRetries) {
|
|
339
|
+
const delay = calculateRetryDelay(attempt);
|
|
340
|
+
if (this.config.onRetry) {
|
|
341
|
+
this.config.onRetry({
|
|
342
|
+
attempt: attempt + 1,
|
|
343
|
+
maxRetries: this.config.maxRetries,
|
|
344
|
+
error: wrappedError,
|
|
345
|
+
delayMs: delay,
|
|
346
|
+
url,
|
|
347
|
+
method,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
await sleep(delay);
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
throw wrappedError;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// Should not reach here, but just in case - use ServerError for consistency
|
|
357
|
+
throw lastError || new errors_1.ServerError('Max retries exceeded', undefined, { maxRetries: this.config.maxRetries });
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Make a GET request.
|
|
361
|
+
*
|
|
362
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
363
|
+
* @throws {AuthorizationError} When authorization fails (403)
|
|
364
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
365
|
+
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
366
|
+
* @throws {NetworkError} When network errors occur
|
|
367
|
+
*/
|
|
368
|
+
get(path, params, config) {
|
|
369
|
+
return this.request(path, { ...config, method: 'GET' }, params);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Make a POST request.
|
|
373
|
+
*
|
|
374
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
375
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
376
|
+
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
377
|
+
* @throws {NetworkError} When network errors occur
|
|
378
|
+
*/
|
|
379
|
+
post(path, body, config) {
|
|
380
|
+
return this.request(path, { ...config, method: 'POST', body });
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Make a PUT request.
|
|
384
|
+
*
|
|
385
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
386
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
387
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
388
|
+
* @throws {NetworkError} When network errors occur
|
|
389
|
+
*/
|
|
390
|
+
put(path, body, config) {
|
|
391
|
+
return this.request(path, { ...config, method: 'PUT', body });
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Make a PATCH request.
|
|
395
|
+
*
|
|
396
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
397
|
+
* @throws {ValidationError} When request validation fails (400)
|
|
398
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
399
|
+
* @throws {NetworkError} When network errors occur
|
|
400
|
+
*/
|
|
401
|
+
patch(path, body, config) {
|
|
402
|
+
return this.request(path, { ...config, method: 'PATCH', body });
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Make a DELETE request.
|
|
406
|
+
*
|
|
407
|
+
* @throws {AuthenticationError} When authentication fails (401)
|
|
408
|
+
* @throws {AuthorizationError} When authorization fails (403)
|
|
409
|
+
* @throws {NotFoundError} When resource is not found (404)
|
|
410
|
+
* @throws {NetworkError} When network errors occur
|
|
411
|
+
*/
|
|
412
|
+
delete(path, config) {
|
|
413
|
+
return this.request(path, { ...config, method: 'DELETE' });
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
exports.HttpClient = HttpClient;
|
|
417
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../../../packages/sdk/src/utils/fetch.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sCAWmB;AACnB,oCAAwE;AACxE,4CAMsB;AAoDtB;;;GAGG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,OAAe,EAAE,UAAmB;IAC/D,IAA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AAI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CACH,IAAY,EACZ,IAAc,EACd,MAAsC;QAEtC,OAAO,IAAI,CAAC,OAAO,CAAI,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CACJ,IAAY,EACZ,MAA+C;QAE/C,OAAO,IAAI,CAAC,OAAO,CAAI,IAAI,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;CACF;AAvXD,gCAuXC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility exports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateMessageId = exports.StreamingClient = exports.HttpClient = void 0;
|
|
7
|
+
var fetch_1 = require("./fetch");
|
|
8
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return fetch_1.HttpClient; } });
|
|
9
|
+
var streaming_1 = require("./streaming");
|
|
10
|
+
Object.defineProperty(exports, "StreamingClient", { enumerable: true, get: function () { return streaming_1.StreamingClient; } });
|
|
11
|
+
Object.defineProperty(exports, "generateMessageId", { enumerable: true, get: function () { return streaming_1.generateMessageId; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/sdk/src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iCAAqC;AAA5B,mGAAA,UAAU,OAAA;AAGnB,yCAAiE;AAAxD,4GAAA,eAAe,OAAA;AAAE,8GAAA,iBAAiB,OAAA"}
|