@attrove/sdk 0.1.5 → 0.1.7
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/{src/__mocks__ → __mocks__}/version.js +1 -2
- package/cjs/{src/admin-client.js → admin-client.js} +23 -22
- package/cjs/{src/client.js → client.js} +40 -39
- package/cjs/{src/constants.js → constants.js} +20 -22
- package/cjs/{src/errors → errors}/index.js +26 -27
- package/cjs/{src/index.js → index.js} +35 -36
- package/cjs/package.json +1 -56
- package/cjs/{src/resources → resources}/conversations.js +1 -2
- package/cjs/{src/resources → resources}/index.js +10 -11
- package/cjs/{src/resources → resources}/integrations.js +0 -1
- package/cjs/{src/resources → resources}/messages.js +3 -4
- package/cjs/{src/resources → resources}/query.js +4 -5
- package/cjs/{src/resources → resources}/users.js +0 -1
- package/cjs/{src/types → types}/index.js +88 -61
- package/cjs/{src/utils → utils}/fetch.js +67 -55
- package/cjs/{src/utils → utils}/index.js +5 -6
- package/cjs/{src/utils → utils}/streaming.js +59 -45
- package/cjs/{src/version.js → version.js} +3 -4
- package/esm/__mocks__/version.d.ts.map +1 -0
- package/esm/{src/__mocks__ → __mocks__}/version.js +1 -1
- package/esm/__mocks__/version.js.map +1 -0
- package/{types/src → esm}/admin-client.d.ts +2 -2
- package/esm/admin-client.d.ts.map +1 -0
- package/esm/{src/admin-client.js → admin-client.js} +18 -16
- package/esm/admin-client.js.map +1 -0
- package/{types/src → esm}/client.d.ts +6 -6
- package/esm/client.d.ts.map +1 -0
- package/esm/{src/client.js → client.js} +28 -26
- package/esm/client.js.map +1 -0
- package/{types/src → esm}/constants.d.ts +3 -4
- package/esm/constants.d.ts.map +1 -0
- package/esm/{src/constants.js → constants.js} +20 -21
- package/esm/constants.js.map +1 -0
- package/{types/src → esm}/errors/index.d.ts +1 -1
- package/{types/src → esm}/errors/index.d.ts.map +1 -1
- package/esm/{src/errors → errors}/index.js +13 -13
- package/esm/errors/index.js.map +1 -0
- package/{types/src → esm}/index.d.ts +14 -14
- package/esm/index.d.ts.map +1 -0
- package/esm/{src/index.js → index.js} +8 -8
- package/esm/index.js.map +1 -0
- package/esm/package.json +1 -56
- package/{types/src → esm}/resources/conversations.d.ts +2 -2
- package/esm/resources/conversations.d.ts.map +1 -0
- package/esm/{src/resources → resources}/conversations.js +1 -1
- package/esm/resources/conversations.js.map +1 -0
- package/esm/resources/index.d.ts +12 -0
- package/esm/resources/index.d.ts.map +1 -0
- package/esm/resources/index.js +9 -0
- package/esm/resources/index.js.map +1 -0
- package/{types/src → esm}/resources/integrations.d.ts +2 -2
- package/esm/resources/integrations.d.ts.map +1 -0
- package/esm/resources/integrations.js.map +1 -0
- package/{types/src → esm}/resources/messages.d.ts +2 -2
- package/esm/resources/messages.d.ts.map +1 -0
- package/esm/{src/resources → resources}/messages.js +3 -3
- package/{cjs/src → esm}/resources/messages.js.map +1 -1
- package/{types/src → esm}/resources/query.d.ts +2 -2
- package/esm/resources/query.d.ts.map +1 -0
- package/esm/{src/resources → resources}/query.js +4 -4
- package/esm/resources/query.js.map +1 -0
- package/{types/src → esm}/resources/users.d.ts +2 -2
- package/esm/resources/users.d.ts.map +1 -0
- package/esm/resources/users.js.map +1 -0
- package/{types/src → esm}/types/index.d.ts +28 -28
- package/esm/types/index.d.ts.map +1 -0
- package/esm/{src/types → types}/index.js +88 -60
- package/esm/types/index.js.map +1 -0
- package/{types/src → esm}/utils/fetch.d.ts +10 -10
- package/esm/utils/fetch.d.ts.map +1 -0
- package/esm/{src/utils → utils}/fetch.js +57 -44
- package/esm/utils/fetch.js.map +1 -0
- package/esm/utils/index.d.ts +8 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +6 -0
- package/esm/utils/index.js.map +1 -0
- package/{types/src → esm}/utils/streaming.d.ts +5 -5
- package/esm/utils/streaming.d.ts.map +1 -0
- package/esm/{src/utils → utils}/streaming.js +47 -32
- package/esm/utils/streaming.js.map +1 -0
- package/{types/src → esm}/version.d.ts +1 -1
- package/esm/version.d.ts.map +1 -0
- package/esm/{src/version.js → version.js} +2 -2
- package/esm/version.js.map +1 -0
- package/package.json +13 -10
- package/cjs/README.md +0 -247
- package/cjs/src/__mocks__/version.js.map +0 -1
- package/cjs/src/admin-client.js.map +0 -1
- package/cjs/src/client.js.map +0 -1
- package/cjs/src/constants.js.map +0 -1
- package/cjs/src/errors/index.js.map +0 -1
- package/cjs/src/index.js.map +0 -1
- package/cjs/src/resources/conversations.js.map +0 -1
- package/cjs/src/resources/index.js.map +0 -1
- package/cjs/src/resources/integrations.js.map +0 -1
- package/cjs/src/resources/query.js.map +0 -1
- package/cjs/src/resources/users.js.map +0 -1
- package/cjs/src/types/index.js.map +0 -1
- package/cjs/src/utils/fetch.js.map +0 -1
- package/cjs/src/utils/index.js.map +0 -1
- package/cjs/src/utils/streaming.js.map +0 -1
- package/cjs/src/version.js.map +0 -1
- package/esm/README.md +0 -247
- package/esm/src/__mocks__/version.js.map +0 -1
- package/esm/src/admin-client.js.map +0 -1
- package/esm/src/client.js.map +0 -1
- package/esm/src/constants.js.map +0 -1
- package/esm/src/errors/index.js.map +0 -1
- package/esm/src/index.js.map +0 -1
- package/esm/src/resources/conversations.js.map +0 -1
- package/esm/src/resources/index.js +0 -9
- package/esm/src/resources/index.js.map +0 -1
- package/esm/src/resources/integrations.js.map +0 -1
- package/esm/src/resources/messages.js.map +0 -1
- package/esm/src/resources/query.js.map +0 -1
- package/esm/src/resources/users.js.map +0 -1
- package/esm/src/types/index.js.map +0 -1
- package/esm/src/utils/fetch.js.map +0 -1
- package/esm/src/utils/index.js +0 -6
- package/esm/src/utils/index.js.map +0 -1
- package/esm/src/utils/streaming.js.map +0 -1
- package/esm/src/version.js.map +0 -1
- package/types/src/__mocks__/version.d.ts.map +0 -1
- package/types/src/admin-client.d.ts.map +0 -1
- package/types/src/client.d.ts.map +0 -1
- package/types/src/constants.d.ts.map +0 -1
- package/types/src/index.d.ts.map +0 -1
- package/types/src/resources/conversations.d.ts.map +0 -1
- package/types/src/resources/index.d.ts +0 -12
- package/types/src/resources/index.d.ts.map +0 -1
- package/types/src/resources/integrations.d.ts.map +0 -1
- package/types/src/resources/messages.d.ts.map +0 -1
- package/types/src/resources/query.d.ts.map +0 -1
- package/types/src/resources/users.d.ts.map +0 -1
- package/types/src/types/index.d.ts.map +0 -1
- package/types/src/utils/fetch.d.ts.map +0 -1
- package/types/src/utils/index.d.ts +0 -8
- package/types/src/utils/index.d.ts.map +0 -1
- package/types/src/utils/streaming.d.ts.map +0 -1
- package/types/src/version.d.ts.map +0 -1
- /package/{types/src → esm}/__mocks__/version.d.ts +0 -0
- /package/esm/{src/resources → resources}/integrations.js +0 -0
- /package/esm/{src/resources → resources}/users.js +0 -0
|
@@ -74,11 +74,11 @@ export function isValidUUID(value) {
|
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
76
|
export function createUserId(value) {
|
|
77
|
-
if (!value || typeof value !==
|
|
78
|
-
return { success: false, error:
|
|
77
|
+
if (!value || typeof value !== "string") {
|
|
78
|
+
return { success: false, error: "UserId must be a non-empty string" };
|
|
79
79
|
}
|
|
80
80
|
if (!UUID_REGEX.test(value)) {
|
|
81
|
-
return { success: false, error:
|
|
81
|
+
return { success: false, error: "UserId must be a valid UUID format" };
|
|
82
82
|
}
|
|
83
83
|
return { success: true, value: value };
|
|
84
84
|
}
|
|
@@ -86,11 +86,17 @@ export function createUserId(value) {
|
|
|
86
86
|
* Validate and create an IntegrationId from a string.
|
|
87
87
|
*/
|
|
88
88
|
export function createIntegrationId(value) {
|
|
89
|
-
if (!value || typeof value !==
|
|
90
|
-
return {
|
|
89
|
+
if (!value || typeof value !== "string") {
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
error: "IntegrationId must be a non-empty string",
|
|
93
|
+
};
|
|
91
94
|
}
|
|
92
95
|
if (!UUID_REGEX.test(value)) {
|
|
93
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
success: false,
|
|
98
|
+
error: "IntegrationId must be a valid UUID format",
|
|
99
|
+
};
|
|
94
100
|
}
|
|
95
101
|
return { success: true, value: value };
|
|
96
102
|
}
|
|
@@ -98,11 +104,11 @@ export function createIntegrationId(value) {
|
|
|
98
104
|
* Validate and create a MessageId from a string.
|
|
99
105
|
*/
|
|
100
106
|
export function createMessageId(value) {
|
|
101
|
-
if (!value || typeof value !==
|
|
102
|
-
return { success: false, error:
|
|
107
|
+
if (!value || typeof value !== "string") {
|
|
108
|
+
return { success: false, error: "MessageId must be a non-empty string" };
|
|
103
109
|
}
|
|
104
110
|
if (!UUID_REGEX.test(value)) {
|
|
105
|
-
return { success: false, error:
|
|
111
|
+
return { success: false, error: "MessageId must be a valid UUID format" };
|
|
106
112
|
}
|
|
107
113
|
return { success: true, value: value };
|
|
108
114
|
}
|
|
@@ -110,11 +116,17 @@ export function createMessageId(value) {
|
|
|
110
116
|
* Validate and create a ConversationId from a string.
|
|
111
117
|
*/
|
|
112
118
|
export function createConversationId(value) {
|
|
113
|
-
if (!value || typeof value !==
|
|
114
|
-
return {
|
|
119
|
+
if (!value || typeof value !== "string") {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: "ConversationId must be a non-empty string",
|
|
123
|
+
};
|
|
115
124
|
}
|
|
116
125
|
if (!UUID_REGEX.test(value)) {
|
|
117
|
-
return {
|
|
126
|
+
return {
|
|
127
|
+
success: false,
|
|
128
|
+
error: "ConversationId must be a valid UUID format",
|
|
129
|
+
};
|
|
118
130
|
}
|
|
119
131
|
return { success: true, value: value };
|
|
120
132
|
}
|
|
@@ -130,11 +142,14 @@ export function createConversationId(value) {
|
|
|
130
142
|
* ```
|
|
131
143
|
*/
|
|
132
144
|
export function createApiKey(value) {
|
|
133
|
-
if (!value || typeof value !==
|
|
134
|
-
return { success: false, error:
|
|
145
|
+
if (!value || typeof value !== "string") {
|
|
146
|
+
return { success: false, error: "ApiKey must be a non-empty string" };
|
|
135
147
|
}
|
|
136
148
|
if (!API_KEY_REGEX.test(value)) {
|
|
137
|
-
return {
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
error: 'ApiKey must start with "sk_" followed by alphanumeric characters',
|
|
152
|
+
};
|
|
138
153
|
}
|
|
139
154
|
return { success: true, value: value };
|
|
140
155
|
}
|
|
@@ -150,16 +165,22 @@ export function createApiKey(value) {
|
|
|
150
165
|
* ```
|
|
151
166
|
*/
|
|
152
167
|
export function createISODate(value) {
|
|
153
|
-
if (!value || typeof value !==
|
|
154
|
-
return {
|
|
168
|
+
if (!value || typeof value !== "string") {
|
|
169
|
+
return {
|
|
170
|
+
success: false,
|
|
171
|
+
error: "ISODateString must be a non-empty string",
|
|
172
|
+
};
|
|
155
173
|
}
|
|
156
174
|
if (!ISO_DATE_REGEX.test(value)) {
|
|
157
|
-
return {
|
|
175
|
+
return {
|
|
176
|
+
success: false,
|
|
177
|
+
error: "ISODateString must be a valid ISO 8601 date format",
|
|
178
|
+
};
|
|
158
179
|
}
|
|
159
180
|
// Additional validation: ensure it parses to a valid date
|
|
160
181
|
const parsed = Date.parse(value);
|
|
161
182
|
if (Number.isNaN(parsed)) {
|
|
162
|
-
return { success: false, error:
|
|
183
|
+
return { success: false, error: "ISODateString must be a valid date" };
|
|
163
184
|
}
|
|
164
185
|
return { success: true, value: value };
|
|
165
186
|
}
|
|
@@ -167,11 +188,11 @@ export function createISODate(value) {
|
|
|
167
188
|
* Validate and create a UUID from a string.
|
|
168
189
|
*/
|
|
169
190
|
export function createUUID(value) {
|
|
170
|
-
if (!value || typeof value !==
|
|
171
|
-
return { success: false, error:
|
|
191
|
+
if (!value || typeof value !== "string") {
|
|
192
|
+
return { success: false, error: "UUID must be a non-empty string" };
|
|
172
193
|
}
|
|
173
194
|
if (!UUID_REGEX.test(value)) {
|
|
174
|
-
return { success: false, error:
|
|
195
|
+
return { success: false, error: "UUID must be a valid UUID format" };
|
|
175
196
|
}
|
|
176
197
|
return { success: true, value: value };
|
|
177
198
|
}
|
|
@@ -195,37 +216,44 @@ export function isValidISODate(value) {
|
|
|
195
216
|
*/
|
|
196
217
|
export const ErrorCodes = {
|
|
197
218
|
// Authentication errors
|
|
198
|
-
AUTH_MISSING_TOKEN:
|
|
199
|
-
AUTH_INVALID_TOKEN:
|
|
200
|
-
AUTH_EXPIRED_TOKEN:
|
|
201
|
-
AUTH_USER_MISMATCH:
|
|
202
|
-
AUTH_INSUFFICIENT_PERMISSIONS:
|
|
219
|
+
AUTH_MISSING_TOKEN: "AUTH_MISSING_TOKEN",
|
|
220
|
+
AUTH_INVALID_TOKEN: "AUTH_INVALID_TOKEN",
|
|
221
|
+
AUTH_EXPIRED_TOKEN: "AUTH_EXPIRED_TOKEN",
|
|
222
|
+
AUTH_USER_MISMATCH: "AUTH_USER_MISMATCH",
|
|
223
|
+
AUTH_INSUFFICIENT_PERMISSIONS: "AUTH_INSUFFICIENT_PERMISSIONS",
|
|
203
224
|
// Resource errors
|
|
204
|
-
RESOURCE_NOT_FOUND:
|
|
205
|
-
RESOURCE_ACCESS_DENIED:
|
|
206
|
-
RESOURCE_ALREADY_EXISTS:
|
|
207
|
-
RESOURCE_DELETED:
|
|
225
|
+
RESOURCE_NOT_FOUND: "RESOURCE_NOT_FOUND",
|
|
226
|
+
RESOURCE_ACCESS_DENIED: "RESOURCE_ACCESS_DENIED",
|
|
227
|
+
RESOURCE_ALREADY_EXISTS: "RESOURCE_ALREADY_EXISTS",
|
|
228
|
+
RESOURCE_DELETED: "RESOURCE_DELETED",
|
|
208
229
|
// Validation errors
|
|
209
|
-
VALIDATION_INVALID_ID:
|
|
210
|
-
VALIDATION_REQUIRED_FIELD:
|
|
211
|
-
VALIDATION_INVALID_FORMAT:
|
|
212
|
-
VALIDATION_OUT_OF_RANGE:
|
|
230
|
+
VALIDATION_INVALID_ID: "VALIDATION_INVALID_ID",
|
|
231
|
+
VALIDATION_REQUIRED_FIELD: "VALIDATION_REQUIRED_FIELD",
|
|
232
|
+
VALIDATION_INVALID_FORMAT: "VALIDATION_INVALID_FORMAT",
|
|
233
|
+
VALIDATION_OUT_OF_RANGE: "VALIDATION_OUT_OF_RANGE",
|
|
213
234
|
// Integration errors
|
|
214
|
-
INTEGRATION_OAUTH_FAILED:
|
|
215
|
-
INTEGRATION_EMAIL_EXISTS:
|
|
216
|
-
INTEGRATION_TOKEN_EXPIRED:
|
|
217
|
-
INTEGRATION_SYNC_FAILED:
|
|
218
|
-
INTEGRATION_NOT_CONNECTED:
|
|
235
|
+
INTEGRATION_OAUTH_FAILED: "INTEGRATION_OAUTH_FAILED",
|
|
236
|
+
INTEGRATION_EMAIL_EXISTS: "INTEGRATION_EMAIL_EXISTS",
|
|
237
|
+
INTEGRATION_TOKEN_EXPIRED: "INTEGRATION_TOKEN_EXPIRED",
|
|
238
|
+
INTEGRATION_SYNC_FAILED: "INTEGRATION_SYNC_FAILED",
|
|
239
|
+
INTEGRATION_NOT_CONNECTED: "INTEGRATION_NOT_CONNECTED",
|
|
219
240
|
// Rate limiting
|
|
220
|
-
RATE_LIMIT_EXCEEDED:
|
|
241
|
+
RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED",
|
|
221
242
|
// Server errors
|
|
222
|
-
INTERNAL_ERROR:
|
|
223
|
-
SERVICE_UNAVAILABLE:
|
|
243
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
244
|
+
SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE",
|
|
224
245
|
};
|
|
225
246
|
/**
|
|
226
247
|
* Valid stream frame types.
|
|
227
248
|
*/
|
|
228
|
-
const VALID_FRAME_TYPES = new Set([
|
|
249
|
+
const VALID_FRAME_TYPES = new Set([
|
|
250
|
+
"chunk",
|
|
251
|
+
"end",
|
|
252
|
+
"error",
|
|
253
|
+
"state",
|
|
254
|
+
"message_ids",
|
|
255
|
+
"stream_start",
|
|
256
|
+
]);
|
|
229
257
|
/**
|
|
230
258
|
* Runtime validator for StreamFrame objects.
|
|
231
259
|
* Validates that parsed JSON has the required structure for a StreamFrame.
|
|
@@ -243,32 +271,32 @@ const VALID_FRAME_TYPES = new Set(['chunk', 'end', 'error', 'state', 'message_id
|
|
|
243
271
|
* ```
|
|
244
272
|
*/
|
|
245
273
|
export function isValidStreamFrame(data) {
|
|
246
|
-
if (!data || typeof data !==
|
|
274
|
+
if (!data || typeof data !== "object") {
|
|
247
275
|
return false;
|
|
248
276
|
}
|
|
249
277
|
const frame = data;
|
|
250
278
|
// All frames must have type and message_id
|
|
251
|
-
if (typeof frame.type !==
|
|
279
|
+
if (typeof frame.type !== "string" || !VALID_FRAME_TYPES.has(frame.type)) {
|
|
252
280
|
return false;
|
|
253
281
|
}
|
|
254
|
-
if (typeof frame.message_id !==
|
|
282
|
+
if (typeof frame.message_id !== "string") {
|
|
255
283
|
return false;
|
|
256
284
|
}
|
|
257
285
|
// Type-specific validation
|
|
258
286
|
switch (frame.type) {
|
|
259
|
-
case
|
|
260
|
-
return typeof frame.content ===
|
|
261
|
-
case
|
|
262
|
-
return typeof frame.reason ===
|
|
263
|
-
[
|
|
264
|
-
case
|
|
265
|
-
return typeof frame.error ===
|
|
266
|
-
case
|
|
267
|
-
return typeof frame.state ===
|
|
268
|
-
case
|
|
269
|
-
return Array.isArray(frame.used_message_ids) &&
|
|
270
|
-
frame.used_message_ids.every((id) => typeof id ===
|
|
271
|
-
case
|
|
287
|
+
case "chunk":
|
|
288
|
+
return typeof frame.content === "string";
|
|
289
|
+
case "end":
|
|
290
|
+
return (typeof frame.reason === "string" &&
|
|
291
|
+
["completed", "cancelled", "error"].includes(frame.reason));
|
|
292
|
+
case "error":
|
|
293
|
+
return typeof frame.error === "string";
|
|
294
|
+
case "state":
|
|
295
|
+
return typeof frame.state === "string";
|
|
296
|
+
case "message_ids":
|
|
297
|
+
return (Array.isArray(frame.used_message_ids) &&
|
|
298
|
+
frame.used_message_ids.every((id) => typeof id === "string"));
|
|
299
|
+
case "stream_start":
|
|
272
300
|
return true;
|
|
273
301
|
default:
|
|
274
302
|
return false;
|
|
@@ -0,0 +1 @@
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AAC;gBACrC,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAW,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CACtE,CAAC;QACJ,KAAK,cAAc;YACjB,OAAO,IAAI,CAAC;QACd;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Provides a robust fetch wrapper with automatic retries, timeout handling,
|
|
5
5
|
* and proper error mapping.
|
|
6
6
|
*/
|
|
7
|
-
import { RetryInfo } from
|
|
7
|
+
import { RetryInfo } from "../types/index.js";
|
|
8
8
|
/**
|
|
9
9
|
* HTTP methods supported by the client.
|
|
10
10
|
*/
|
|
11
|
-
export type HttpMethod =
|
|
11
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
12
12
|
/**
|
|
13
13
|
* Configuration for HTTP requests.
|
|
14
14
|
*/
|
|
@@ -23,15 +23,15 @@ export interface RequestConfig {
|
|
|
23
23
|
* Uses a discriminated union to prevent impossible auth states.
|
|
24
24
|
*/
|
|
25
25
|
export type HttpClientAuth = {
|
|
26
|
-
type:
|
|
26
|
+
type: "apiKey";
|
|
27
27
|
apiKey: string;
|
|
28
28
|
userId: string;
|
|
29
29
|
} | {
|
|
30
|
-
type:
|
|
30
|
+
type: "partner";
|
|
31
31
|
clientId: string;
|
|
32
32
|
clientSecret: string;
|
|
33
33
|
} | {
|
|
34
|
-
type:
|
|
34
|
+
type: "none";
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Configuration for the HTTP client.
|
|
@@ -120,7 +120,7 @@ export declare class HttpClient {
|
|
|
120
120
|
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
121
121
|
* @throws {NetworkError} When network errors occur
|
|
122
122
|
*/
|
|
123
|
-
get<T>(path: string, params?: Record<string, string | string[] | undefined>, config?: Omit<RequestConfig,
|
|
123
|
+
get<T>(path: string, params?: Record<string, string | string[] | undefined>, config?: Omit<RequestConfig, "method" | "body">): Promise<T>;
|
|
124
124
|
/**
|
|
125
125
|
* Make a POST request.
|
|
126
126
|
*
|
|
@@ -129,7 +129,7 @@ export declare class HttpClient {
|
|
|
129
129
|
* @throws {RateLimitError} When rate limits are exceeded (429)
|
|
130
130
|
* @throws {NetworkError} When network errors occur
|
|
131
131
|
*/
|
|
132
|
-
post<T>(path: string, body?: unknown, config?: Omit<RequestConfig,
|
|
132
|
+
post<T>(path: string, body?: unknown, config?: Omit<RequestConfig, "method">): Promise<T>;
|
|
133
133
|
/**
|
|
134
134
|
* Make a PUT request.
|
|
135
135
|
*
|
|
@@ -138,7 +138,7 @@ export declare class HttpClient {
|
|
|
138
138
|
* @throws {NotFoundError} When resource is not found (404)
|
|
139
139
|
* @throws {NetworkError} When network errors occur
|
|
140
140
|
*/
|
|
141
|
-
put<T>(path: string, body?: unknown, config?: Omit<RequestConfig,
|
|
141
|
+
put<T>(path: string, body?: unknown, config?: Omit<RequestConfig, "method">): Promise<T>;
|
|
142
142
|
/**
|
|
143
143
|
* Make a PATCH request.
|
|
144
144
|
*
|
|
@@ -147,7 +147,7 @@ export declare class HttpClient {
|
|
|
147
147
|
* @throws {NotFoundError} When resource is not found (404)
|
|
148
148
|
* @throws {NetworkError} When network errors occur
|
|
149
149
|
*/
|
|
150
|
-
patch<T>(path: string, body?: unknown, config?: Omit<RequestConfig,
|
|
150
|
+
patch<T>(path: string, body?: unknown, config?: Omit<RequestConfig, "method">): Promise<T>;
|
|
151
151
|
/**
|
|
152
152
|
* Make a DELETE request.
|
|
153
153
|
*
|
|
@@ -156,6 +156,6 @@ export declare class HttpClient {
|
|
|
156
156
|
* @throws {NotFoundError} When resource is not found (404)
|
|
157
157
|
* @throws {NetworkError} When network errors occur
|
|
158
158
|
*/
|
|
159
|
-
delete<T>(path: string, config?: Omit<RequestConfig,
|
|
159
|
+
delete<T>(path: string, config?: Omit<RequestConfig, "method" | "body">): Promise<T>;
|
|
160
160
|
}
|
|
161
161
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/src/utils/fetch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EAIL,SAAS,EACV,MAAM,mBAAmB,CAAC;AAS3B;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,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EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GACrC,OAAO,CAAC,CAAC,CAAC;IAIb;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,EACL,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GACrC,OAAO,CAAC,CAAC,CAAC;IAIb;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,EACN,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,MAAM,CAAC,GAC9C,OAAO,CAAC,CAAC,CAAC;CAGd"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Provides a robust fetch wrapper with automatic retries, timeout handling,
|
|
5
5
|
* and proper error mapping.
|
|
6
6
|
*/
|
|
7
|
-
import { AttroveError, ValidationError, NetworkError, TimeoutError, ServerError, createErrorFromStatus, } from
|
|
8
|
-
import { ErrorCodes } from
|
|
9
|
-
import { SDK_VERSION, DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, INITIAL_RETRY_DELAY, RETRYABLE_STATUS_SET, } from
|
|
7
|
+
import { AttroveError, ValidationError, NetworkError, TimeoutError, ServerError, createErrorFromStatus, } from "../errors/index.js";
|
|
8
|
+
import { ErrorCodes, } from "../types/index.js";
|
|
9
|
+
import { SDK_VERSION, DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, INITIAL_RETRY_DELAY, RETRYABLE_STATUS_SET, } from "../constants.js";
|
|
10
10
|
/**
|
|
11
11
|
* Delay execution during retry backoff.
|
|
12
12
|
* Used between retry attempts to avoid overwhelming the server.
|
|
@@ -54,29 +54,33 @@ function normalizeConfig(config) {
|
|
|
54
54
|
let auth;
|
|
55
55
|
// Check for partial API key credentials
|
|
56
56
|
if (config.apiKey && !config.userId) {
|
|
57
|
-
throw new ValidationError(
|
|
57
|
+
throw new ValidationError("userId is required when using apiKey authentication", ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: "userId", providedFields: ["apiKey"] });
|
|
58
58
|
}
|
|
59
59
|
if (!config.apiKey && config.userId) {
|
|
60
|
-
throw new ValidationError(
|
|
60
|
+
throw new ValidationError("apiKey is required when using user authentication", ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: "apiKey", providedFields: ["userId"] });
|
|
61
61
|
}
|
|
62
62
|
// Check for partial partner credentials
|
|
63
63
|
if (config.clientId && !config.clientSecret) {
|
|
64
|
-
throw new ValidationError(
|
|
64
|
+
throw new ValidationError("clientSecret is required when using partner authentication", ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: "clientSecret", providedFields: ["clientId"] });
|
|
65
65
|
}
|
|
66
66
|
if (!config.clientId && config.clientSecret) {
|
|
67
|
-
throw new ValidationError(
|
|
67
|
+
throw new ValidationError("clientId is required when using partner authentication", ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: "clientId", providedFields: ["clientSecret"] });
|
|
68
68
|
}
|
|
69
69
|
if (config.apiKey && config.userId) {
|
|
70
|
-
auth = { type:
|
|
70
|
+
auth = { type: "apiKey", apiKey: config.apiKey, userId: config.userId };
|
|
71
71
|
}
|
|
72
72
|
else if (config.clientId && config.clientSecret) {
|
|
73
|
-
auth = {
|
|
73
|
+
auth = {
|
|
74
|
+
type: "partner",
|
|
75
|
+
clientId: config.clientId,
|
|
76
|
+
clientSecret: config.clientSecret,
|
|
77
|
+
};
|
|
74
78
|
}
|
|
75
79
|
else {
|
|
76
|
-
auth = { type:
|
|
80
|
+
auth = { type: "none" };
|
|
77
81
|
}
|
|
78
82
|
return {
|
|
79
|
-
baseUrl: config.baseUrl.replace(/\/$/,
|
|
83
|
+
baseUrl: config.baseUrl.replace(/\/$/, ""),
|
|
80
84
|
auth,
|
|
81
85
|
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
82
86
|
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
@@ -131,20 +135,20 @@ export class HttpClient {
|
|
|
131
135
|
*/
|
|
132
136
|
buildHeaders(customHeaders) {
|
|
133
137
|
const headers = {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
"Content-Type": "application/json",
|
|
139
|
+
Accept: "application/json",
|
|
140
|
+
"User-Agent": `@attrove/sdk/${SDK_VERSION}`,
|
|
137
141
|
...customHeaders,
|
|
138
142
|
};
|
|
139
143
|
const { auth } = this.config;
|
|
140
|
-
if (auth.type ===
|
|
141
|
-
headers[
|
|
142
|
-
headers[
|
|
143
|
-
headers[
|
|
144
|
+
if (auth.type === "apiKey") {
|
|
145
|
+
headers["Authorization"] = `Bearer ${auth.apiKey}`;
|
|
146
|
+
headers["X-Auth-Type"] = "api";
|
|
147
|
+
headers["X-User-Id"] = auth.userId;
|
|
144
148
|
}
|
|
145
|
-
else if (auth.type ===
|
|
146
|
-
headers[
|
|
147
|
-
headers[
|
|
149
|
+
else if (auth.type === "partner") {
|
|
150
|
+
headers["Authorization"] = `Bearer ${auth.clientSecret}`;
|
|
151
|
+
headers["X-Auth-Type"] = "partner";
|
|
148
152
|
}
|
|
149
153
|
return headers;
|
|
150
154
|
}
|
|
@@ -154,18 +158,18 @@ export class HttpClient {
|
|
|
154
158
|
*/
|
|
155
159
|
parseApiError(body, status) {
|
|
156
160
|
// Handle structured error response
|
|
157
|
-
if (body && typeof body ===
|
|
161
|
+
if (body && typeof body === "object" && "error" in body) {
|
|
158
162
|
const errorResponse = body;
|
|
159
163
|
const error = errorResponse.error;
|
|
160
|
-
if (typeof error ===
|
|
164
|
+
if (typeof error === "string") {
|
|
161
165
|
return createErrorFromStatus(error, status);
|
|
162
166
|
}
|
|
163
167
|
return createErrorFromStatus(error.message, status, error.code, error.details);
|
|
164
168
|
}
|
|
165
169
|
// Handle unknown error format - include response preview for debugging
|
|
166
170
|
let message;
|
|
167
|
-
if (typeof body ===
|
|
168
|
-
message = body ||
|
|
171
|
+
if (typeof body === "string") {
|
|
172
|
+
message = body || "Empty error response";
|
|
169
173
|
}
|
|
170
174
|
else {
|
|
171
175
|
try {
|
|
@@ -173,7 +177,9 @@ export class HttpClient {
|
|
|
173
177
|
}
|
|
174
178
|
catch (serializeError) {
|
|
175
179
|
// Preserve serialization error context for debugging
|
|
176
|
-
const reason = serializeError instanceof Error
|
|
180
|
+
const reason = serializeError instanceof Error
|
|
181
|
+
? serializeError.message
|
|
182
|
+
: "Unknown reason";
|
|
177
183
|
message = `Unknown error occurred (response not serializable: ${reason})`;
|
|
178
184
|
}
|
|
179
185
|
}
|
|
@@ -197,7 +203,7 @@ export class HttpClient {
|
|
|
197
203
|
* @throws {ServerError} When server errors occur (5xx)
|
|
198
204
|
*/
|
|
199
205
|
async request(path, config = {}, queryParams) {
|
|
200
|
-
const method = config.method ??
|
|
206
|
+
const method = config.method ?? "GET";
|
|
201
207
|
const url = this.buildUrl(path, queryParams);
|
|
202
208
|
const headers = this.buildHeaders(config.headers);
|
|
203
209
|
const timeout = config.timeout ?? this.config.timeout;
|
|
@@ -211,22 +217,22 @@ export class HttpClient {
|
|
|
211
217
|
headers,
|
|
212
218
|
signal: controller.signal,
|
|
213
219
|
};
|
|
214
|
-
if (config.body && method !==
|
|
220
|
+
if (config.body && method !== "GET") {
|
|
215
221
|
fetchOptions.body = JSON.stringify(config.body);
|
|
216
222
|
}
|
|
217
223
|
const response = await fetch(url, fetchOptions);
|
|
218
224
|
clearTimeout(timeoutId);
|
|
219
225
|
// Parse response body with explicit JSON error handling
|
|
220
226
|
let body;
|
|
221
|
-
const contentType = response.headers.get(
|
|
222
|
-
if (contentType?.includes(
|
|
227
|
+
const contentType = response.headers.get("content-type");
|
|
228
|
+
if (contentType?.includes("application/json")) {
|
|
223
229
|
const text = await response.text();
|
|
224
230
|
try {
|
|
225
231
|
body = JSON.parse(text);
|
|
226
232
|
}
|
|
227
233
|
catch (parseError) {
|
|
228
234
|
// JSON parse errors are not retryable
|
|
229
|
-
throw new ServerError(`Server returned invalid JSON: ${parseError instanceof Error ? parseError.message :
|
|
235
|
+
throw new ServerError(`Server returned invalid JSON: ${parseError instanceof Error ? parseError.message : "Parse failed"}`, response.status, { responsePreview: text.substring(0, 200) });
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
else {
|
|
@@ -235,11 +241,11 @@ export class HttpClient {
|
|
|
235
241
|
// Handle successful response
|
|
236
242
|
if (response.ok) {
|
|
237
243
|
// Handle wrapped API responses
|
|
238
|
-
if (body && typeof body ===
|
|
244
|
+
if (body && typeof body === "object" && "success" in body) {
|
|
239
245
|
const apiResponse = body;
|
|
240
246
|
if (apiResponse.success) {
|
|
241
247
|
// Paginated responses have a `pagination` field - preserve the full structure
|
|
242
|
-
if (
|
|
248
|
+
if ("pagination" in body) {
|
|
243
249
|
return body;
|
|
244
250
|
}
|
|
245
251
|
return apiResponse.data;
|
|
@@ -252,8 +258,9 @@ export class HttpClient {
|
|
|
252
258
|
// Handle error response
|
|
253
259
|
const error = this.parseApiError(body, response.status);
|
|
254
260
|
// Check if we should retry
|
|
255
|
-
if (attempt < this.config.maxRetries &&
|
|
256
|
-
|
|
261
|
+
if (attempt < this.config.maxRetries &&
|
|
262
|
+
RETRYABLE_STATUS_SET.has(response.status)) {
|
|
263
|
+
const retryAfterSeconds = parseRetryAfter(response.headers.get("retry-after"));
|
|
257
264
|
const delay = calculateRetryDelay(attempt, retryAfterSeconds);
|
|
258
265
|
// Call retry callback if provided
|
|
259
266
|
if (this.config.onRetry) {
|
|
@@ -274,7 +281,7 @@ export class HttpClient {
|
|
|
274
281
|
}
|
|
275
282
|
catch (err) {
|
|
276
283
|
// Handle abort/timeout
|
|
277
|
-
if (err instanceof Error && err.name ===
|
|
284
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
278
285
|
const timeoutError = new TimeoutError(`Request timed out after ${timeout}ms`);
|
|
279
286
|
if (attempt < this.config.maxRetries) {
|
|
280
287
|
const delay = calculateRetryDelay(attempt);
|
|
@@ -295,7 +302,7 @@ export class HttpClient {
|
|
|
295
302
|
throw timeoutError;
|
|
296
303
|
}
|
|
297
304
|
// Handle network errors
|
|
298
|
-
if (err instanceof TypeError && err.message.includes(
|
|
305
|
+
if (err instanceof TypeError && err.message.includes("fetch")) {
|
|
299
306
|
const networkError = new NetworkError(`Network error: ${err.message}. Check your connection and ensure the API endpoint is accessible.`);
|
|
300
307
|
if (attempt < this.config.maxRetries) {
|
|
301
308
|
const delay = calculateRetryDelay(attempt);
|
|
@@ -326,7 +333,10 @@ export class HttpClient {
|
|
|
326
333
|
originalErrorMessage: originalError.message,
|
|
327
334
|
};
|
|
328
335
|
if (originalError.stack) {
|
|
329
|
-
errorDetails.originalStack = originalError.stack
|
|
336
|
+
errorDetails.originalStack = originalError.stack
|
|
337
|
+
.split("\n")
|
|
338
|
+
.slice(0, 5)
|
|
339
|
+
.join("\n");
|
|
330
340
|
}
|
|
331
341
|
// Wrap in ServerError to indicate this was an unexpected failure
|
|
332
342
|
const wrappedError = new ServerError(`Unexpected error during request: ${originalError.message}`, undefined, // No status code for unexpected errors
|
|
@@ -351,7 +361,10 @@ export class HttpClient {
|
|
|
351
361
|
}
|
|
352
362
|
}
|
|
353
363
|
// Should not reach here, but just in case - use ServerError for consistency
|
|
354
|
-
throw lastError ||
|
|
364
|
+
throw (lastError ||
|
|
365
|
+
new ServerError("Max retries exceeded", undefined, {
|
|
366
|
+
maxRetries: this.config.maxRetries,
|
|
367
|
+
}));
|
|
355
368
|
}
|
|
356
369
|
/**
|
|
357
370
|
* Make a GET request.
|
|
@@ -363,7 +376,7 @@ export class HttpClient {
|
|
|
363
376
|
* @throws {NetworkError} When network errors occur
|
|
364
377
|
*/
|
|
365
378
|
get(path, params, config) {
|
|
366
|
-
return this.request(path, { ...config, method:
|
|
379
|
+
return this.request(path, { ...config, method: "GET" }, params);
|
|
367
380
|
}
|
|
368
381
|
/**
|
|
369
382
|
* Make a POST request.
|
|
@@ -374,7 +387,7 @@ export class HttpClient {
|
|
|
374
387
|
* @throws {NetworkError} When network errors occur
|
|
375
388
|
*/
|
|
376
389
|
post(path, body, config) {
|
|
377
|
-
return this.request(path, { ...config, method:
|
|
390
|
+
return this.request(path, { ...config, method: "POST", body });
|
|
378
391
|
}
|
|
379
392
|
/**
|
|
380
393
|
* Make a PUT request.
|
|
@@ -385,7 +398,7 @@ export class HttpClient {
|
|
|
385
398
|
* @throws {NetworkError} When network errors occur
|
|
386
399
|
*/
|
|
387
400
|
put(path, body, config) {
|
|
388
|
-
return this.request(path, { ...config, method:
|
|
401
|
+
return this.request(path, { ...config, method: "PUT", body });
|
|
389
402
|
}
|
|
390
403
|
/**
|
|
391
404
|
* Make a PATCH request.
|
|
@@ -396,7 +409,7 @@ export class HttpClient {
|
|
|
396
409
|
* @throws {NetworkError} When network errors occur
|
|
397
410
|
*/
|
|
398
411
|
patch(path, body, config) {
|
|
399
|
-
return this.request(path, { ...config, method:
|
|
412
|
+
return this.request(path, { ...config, method: "PATCH", body });
|
|
400
413
|
}
|
|
401
414
|
/**
|
|
402
415
|
* Make a DELETE request.
|
|
@@ -407,7 +420,7 @@ export class HttpClient {
|
|
|
407
420
|
* @throws {NetworkError} When network errors occur
|
|
408
421
|
*/
|
|
409
422
|
delete(path, config) {
|
|
410
|
-
return this.request(path, { ...config, method:
|
|
423
|
+
return this.request(path, { ...config, method: "DELETE" });
|
|
411
424
|
}
|
|
412
425
|
}
|
|
413
426
|
//# 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,OAAO,EACL,YAAY,EAIZ,eAAe,EAEf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,UAAU,GAGX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,mBAAmB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