@adea-ai/sdk 3.1.0 → 4.0.1

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/dist/client.js CHANGED
@@ -255,6 +255,7 @@ export class ControlPlaneClient {
255
255
  async #request(operation, input) {
256
256
  const request = operation.requestSchema.parse(input);
257
257
  const credential = await resolveCredential(this.#credential);
258
+ const signal = AbortSignal.timeout(this.#timeoutMs);
258
259
  const response = await this.#fetch(new URL(operation.path.slice(1), this.#baseUrl), {
259
260
  method: operation.method,
260
261
  headers: {
@@ -266,9 +267,9 @@ export class ControlPlaneClient {
266
267
  },
267
268
  body: JSON.stringify(request),
268
269
  redirect: 'error',
269
- signal: AbortSignal.timeout(this.#timeoutMs),
270
+ signal,
270
271
  });
271
- const body = await parseResponseBody(response, request.requestId);
272
+ const body = await parseResponseBody(response, request.requestId, signal);
272
273
  if (!response.ok) {
273
274
  const parsedError = ErrorResponseEnvelopeSchema.safeParse(body);
274
275
  if (!parsedError.success) {
@@ -313,11 +314,12 @@ async function resolveCredential(provider) {
313
314
  throw new Error('Control Plane service credential is required');
314
315
  return credential;
315
316
  }
316
- async function parseResponseBody(response, requestId) {
317
+ async function parseResponseBody(response, requestId, signal) {
317
318
  try {
318
319
  return await response.json();
319
320
  }
320
321
  catch {
322
+ signal.throwIfAborted();
321
323
  throw invalidResponse(requestId, response.status);
322
324
  }
323
325
  }