@unito/integration-sdk 1.1.1 → 1.1.3
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/src/index.cjs +1 -5
- package/dist/src/middlewares/signal.d.ts +1 -1
- package/dist/src/middlewares/signal.js +0 -4
- package/dist/src/resources/context.d.ts +1 -1
- package/dist/src/resources/provider.d.ts +1 -1
- package/dist/src/resources/provider.js +1 -1
- package/dist/test/middlewares/signal.test.js +1 -2
- package/package.json +3 -3
- package/src/middlewares/signal.ts +1 -4
- package/src/resources/context.ts +1 -1
- package/src/resources/provider.ts +2 -2
- package/test/middlewares/signal.test.ts +1 -2
package/dist/src/index.cjs
CHANGED
|
@@ -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) {
|
|
@@ -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
|
*
|
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Integration SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/busboy": "^1.5.4",
|
|
37
|
-
"@types/express": "
|
|
37
|
+
"@types/express": "5.x",
|
|
38
38
|
"@types/node": "20.x",
|
|
39
39
|
"@typescript-eslint/eslint-plugin": "7.x",
|
|
40
40
|
"@typescript-eslint/parser": "7.x",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@unito/integration-api": "0.x",
|
|
50
50
|
"busboy": "^1.6.0",
|
|
51
51
|
"cachette": "2.x",
|
|
52
|
-
"express": "^5.
|
|
52
|
+
"express": "^5.x",
|
|
53
53
|
"form-data": "^4.0.0"
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|
|
@@ -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
|
|
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();
|
package/src/resources/context.ts
CHANGED
|
@@ -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
|
|
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
|
|
26
|
-
assert.equal(response.locals.signal.aborted, false);
|
|
25
|
+
assert.ok(!response.locals.signal);
|
|
27
26
|
});
|
|
28
27
|
});
|