@unito/integration-sdk 1.1.1 → 1.1.2

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.
@@ -953,10 +953,6 @@ function extractOperationDeadline(req, res, next) {
953
953
  throw new TimeoutError('Request already timed out upon reception');
954
954
  }
955
955
  }
956
- else {
957
- // Default to 20s, which is the maximum time frame allowed for an operation by Unito.
958
- res.locals.signal = AbortSignal.timeout(20000);
959
- }
960
956
  next();
961
957
  }
962
958
 
@@ -1356,9 +1352,9 @@ class Provider {
1356
1352
  try {
1357
1353
  response = await fetch(absoluteUrl, {
1358
1354
  method: options.method,
1359
- signal: options.signal,
1360
1355
  headers,
1361
1356
  body: stringifiedBody,
1357
+ ...(options.signal ? { signal: options.signal } : {}),
1362
1358
  });
1363
1359
  }
1364
1360
  catch (error) {
@@ -7,7 +7,7 @@ declare global {
7
7
  * after which Unito will consider the operation to be timed out. You can use this signal to abort any
8
8
  * operation that would exceed this time frame.
9
9
  */
10
- signal: AbortSignal;
10
+ signal?: AbortSignal;
11
11
  }
12
12
  }
13
13
  }
@@ -13,10 +13,6 @@ function extractOperationDeadline(req, res, next) {
13
13
  throw new TimeoutError('Request already timed out upon reception');
14
14
  }
15
15
  }
16
- else {
17
- // Default to 20s, which is the maximum time frame allowed for an operation by Unito.
18
- res.locals.signal = AbortSignal.timeout(20000);
19
- }
20
16
  next();
21
17
  }
22
18
  export default extractOperationDeadline;
@@ -39,7 +39,7 @@ export type Context<P extends Maybe<Params> = Maybe<Params>, Q extends Maybe<Que
39
39
  * X-Unito-Operation-Deadline header. This header contains the timestamp after which Unito will consider the operation
40
40
  * to be timed out. You can use this signal to abort any operation that would exceed this time frame.
41
41
  */
42
- signal: AbortSignal;
42
+ signal: AbortSignal | undefined;
43
43
  /**
44
44
  * The request params.
45
45
  *
@@ -33,7 +33,7 @@ export type RateLimiter = <T>(options: {
33
33
  export type RequestOptions = {
34
34
  credentials: Credentials;
35
35
  logger: Logger;
36
- signal: AbortSignal;
36
+ signal?: AbortSignal;
37
37
  queryParams?: {
38
38
  [key: string]: string;
39
39
  };
@@ -253,9 +253,9 @@ export class Provider {
253
253
  try {
254
254
  response = await fetch(absoluteUrl, {
255
255
  method: options.method,
256
- signal: options.signal,
257
256
  headers,
258
257
  body: stringifiedBody,
258
+ ...(options.signal ? { signal: options.signal } : {}),
259
259
  });
260
260
  }
261
261
  catch (error) {
@@ -14,7 +14,6 @@ describe('signal middleware', () => {
14
14
  const request = { header: (_key) => undefined };
15
15
  const response = { locals: {} };
16
16
  extractOperationDeadline(request, response, () => { });
17
- assert.ok(response.locals.signal instanceof AbortSignal);
18
- assert.equal(response.locals.signal.aborted, false);
17
+ assert.ok(!response.locals.signal);
19
18
  });
20
19
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Integration SDK",
5
5
  "type": "module",
6
6
  "types": "dist/src/index.d.ts",
@@ -10,7 +10,7 @@ declare global {
10
10
  * after which Unito will consider the operation to be timed out. You can use this signal to abort any
11
11
  * operation that would exceed this time frame.
12
12
  */
13
- signal: AbortSignal;
13
+ signal?: AbortSignal;
14
14
  }
15
15
  }
16
16
  }
@@ -30,9 +30,6 @@ function extractOperationDeadline(req: Request, res: Response, next: NextFunctio
30
30
  } else {
31
31
  throw new TimeoutError('Request already timed out upon reception');
32
32
  }
33
- } else {
34
- // Default to 20s, which is the maximum time frame allowed for an operation by Unito.
35
- res.locals.signal = AbortSignal.timeout(20000);
36
33
  }
37
34
 
38
35
  next();
@@ -42,7 +42,7 @@ export type Context<P extends Maybe<Params> = Maybe<Params>, Q extends Maybe<Que
42
42
  * X-Unito-Operation-Deadline header. This header contains the timestamp after which Unito will consider the operation
43
43
  * to be timed out. You can use this signal to abort any operation that would exceed this time frame.
44
44
  */
45
- signal: AbortSignal;
45
+ signal: AbortSignal | undefined;
46
46
  /**
47
47
  * The request params.
48
48
  *
@@ -38,7 +38,7 @@ export type RateLimiter = <T>(
38
38
  export type RequestOptions = {
39
39
  credentials: Credentials;
40
40
  logger: Logger;
41
- signal: AbortSignal;
41
+ signal?: AbortSignal;
42
42
  queryParams?: { [key: string]: string };
43
43
  additionnalheaders?: { [key: string]: string };
44
44
  };
@@ -345,9 +345,9 @@ export class Provider {
345
345
  try {
346
346
  response = await fetch(absoluteUrl, {
347
347
  method: options.method,
348
- signal: options.signal,
349
348
  headers,
350
349
  body: stringifiedBody,
350
+ ...(options.signal ? { signal: options.signal } : {}),
351
351
  });
352
352
  } catch (error) {
353
353
  if (error instanceof Error) {
@@ -22,7 +22,6 @@ describe('signal middleware', () => {
22
22
 
23
23
  extractOperationDeadline(request, response, () => {});
24
24
 
25
- assert.ok(response.locals.signal instanceof AbortSignal);
26
- assert.equal(response.locals.signal.aborted, false);
25
+ assert.ok(!response.locals.signal);
27
26
  });
28
27
  });