@clickup/rest-client 2.10.293 → 2.10.296

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.
Files changed (92) hide show
  1. package/.eslintrc.base.js +20 -2
  2. package/README.md +3 -1
  3. package/SECURITY.md +39 -0
  4. package/dist/.eslintcache +1 -0
  5. package/dist/RestClient.js +1 -1
  6. package/dist/RestClient.js.map +1 -1
  7. package/dist/RestOptions.d.ts +5 -7
  8. package/dist/RestOptions.d.ts.map +1 -1
  9. package/dist/RestOptions.js +2 -2
  10. package/dist/RestOptions.js.map +1 -1
  11. package/dist/RestRequest.d.ts.map +1 -1
  12. package/dist/RestRequest.js +7 -13
  13. package/dist/RestRequest.js.map +1 -1
  14. package/dist/RestResponse.d.ts +4 -1
  15. package/dist/RestResponse.d.ts.map +1 -1
  16. package/dist/RestResponse.js +2 -1
  17. package/dist/RestResponse.js.map +1 -1
  18. package/dist/RestStream.js.map +1 -1
  19. package/dist/errors/RestRateLimitError.d.ts.map +1 -1
  20. package/dist/errors/RestRateLimitError.js.map +1 -1
  21. package/dist/errors/RestRetriableError.d.ts.map +1 -1
  22. package/dist/errors/RestRetriableError.js.map +1 -1
  23. package/dist/errors/RestTokenInvalidError.d.ts.map +1 -1
  24. package/dist/errors/RestTokenInvalidError.js.map +1 -1
  25. package/dist/helpers/depaginate.d.ts +1 -1
  26. package/dist/helpers/depaginate.d.ts.map +1 -1
  27. package/dist/helpers/depaginate.js.map +1 -1
  28. package/dist/internal/RestFetchReader.d.ts +9 -2
  29. package/dist/internal/RestFetchReader.d.ts.map +1 -1
  30. package/dist/internal/RestFetchReader.js +14 -3
  31. package/dist/internal/RestFetchReader.js.map +1 -1
  32. package/dist/internal/RestRangeUploader.js.map +1 -1
  33. package/dist/internal/calcRetryDelay.js.map +1 -1
  34. package/dist/internal/inferResBodyEncoding.js.map +1 -1
  35. package/dist/internal/inspectPossibleJSON.js.map +1 -1
  36. package/dist/internal/substituteParams.js.map +1 -1
  37. package/dist/internal/throwIfErrorResponse.js.map +1 -1
  38. package/dist/middlewares/paceRequests.js.map +1 -1
  39. package/dist/pacers/PacerQPS.js.map +1 -1
  40. package/docs/README.md +3 -1
  41. package/docs/classes/PacerComposite.md +7 -3
  42. package/docs/classes/PacerQPS.md +7 -3
  43. package/docs/classes/RestClient.md +32 -28
  44. package/docs/classes/RestContentSizeOverLimitError.md +5 -1
  45. package/docs/classes/RestError.md +5 -1
  46. package/docs/classes/RestRateLimitError.md +6 -2
  47. package/docs/classes/RestRequest.md +22 -18
  48. package/docs/classes/RestResponse.md +25 -10
  49. package/docs/classes/RestResponseError.md +5 -1
  50. package/docs/classes/RestRetriableError.md +6 -2
  51. package/docs/classes/RestStream.md +12 -8
  52. package/docs/classes/RestTimeoutError.md +5 -1
  53. package/docs/classes/RestTokenInvalidError.md +6 -2
  54. package/docs/interfaces/Middleware.md +4 -4
  55. package/docs/interfaces/Pacer.md +2 -2
  56. package/docs/interfaces/PacerQPSBackend.md +2 -2
  57. package/docs/interfaces/RestLogEvent.md +1 -1
  58. package/docs/interfaces/RestOptions.md +59 -23
  59. package/docs/interfaces/TokenGetter.md +3 -3
  60. package/docs/modules.md +4 -4
  61. package/jest.config.js +3 -0
  62. package/package.json +40 -8
  63. package/src/RestClient.ts +490 -0
  64. package/src/RestOptions.ts +186 -0
  65. package/src/RestRequest.ts +441 -0
  66. package/src/RestResponse.ts +49 -0
  67. package/src/RestStream.ts +89 -0
  68. package/src/errors/RestContentSizeOverLimitError.ts +3 -0
  69. package/src/errors/RestError.ts +6 -0
  70. package/src/errors/RestRateLimitError.ts +12 -0
  71. package/src/errors/RestResponseError.ts +46 -0
  72. package/src/errors/RestRetriableError.ts +12 -0
  73. package/src/errors/RestTimeoutError.ts +3 -0
  74. package/src/errors/RestTokenInvalidError.ts +11 -0
  75. package/src/helpers/depaginate.ts +37 -0
  76. package/src/index.ts +50 -0
  77. package/src/internal/RestFetchReader.ts +188 -0
  78. package/src/internal/RestRangeUploader.ts +61 -0
  79. package/src/internal/calcRetryDelay.ts +59 -0
  80. package/src/internal/inferResBodyEncoding.ts +33 -0
  81. package/src/internal/inspectPossibleJSON.ts +71 -0
  82. package/src/internal/prependNewlineIfMultiline.ts +3 -0
  83. package/src/internal/substituteParams.ts +25 -0
  84. package/src/internal/throwIfErrorResponse.ts +89 -0
  85. package/src/internal/toFloatMs.ts +3 -0
  86. package/src/middlewares/paceRequests.ts +42 -0
  87. package/src/pacers/Pacer.ts +22 -0
  88. package/src/pacers/PacerComposite.ts +29 -0
  89. package/src/pacers/PacerQPS.ts +147 -0
  90. package/tsconfig.json +5 -13
  91. package/typedoc.json +6 -1
  92. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -16,31 +16,46 @@ body and make it a part of RestResponse abstraction.
16
16
 
17
17
  ### constructor
18
18
 
19
- • **new RestResponse**(`req`, `status`, `headers`, `text`, `textIsPartial`)
19
+ • **new RestResponse**(`req`, `agent`, `status`, `headers`, `text`, `textIsPartial`): [`RestResponse`](RestResponse.md)
20
20
 
21
21
  #### Parameters
22
22
 
23
23
  | Name | Type |
24
24
  | :------ | :------ |
25
- | `req` | [`RestRequest`](RestRequest.md)<`any`\> |
25
+ | `req` | [`RestRequest`](RestRequest.md)\<`any`\> |
26
+ | `agent` | ``null`` \| `Agent` |
26
27
  | `status` | `number` |
27
28
  | `headers` | `Headers` |
28
29
  | `text` | `string` |
29
30
  | `textIsPartial` | `boolean` |
30
31
 
32
+ #### Returns
33
+
34
+ [`RestResponse`](RestResponse.md)
35
+
31
36
  #### Defined in
32
37
 
33
- [src/RestResponse.ts:17](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L17)
38
+ [src/RestResponse.ts:18](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L18)
34
39
 
35
40
  ## Properties
36
41
 
37
42
  ### req
38
43
 
39
- • `Readonly` **req**: [`RestRequest`](RestRequest.md)<`any`\>
44
+ • `Readonly` **req**: [`RestRequest`](RestRequest.md)\<`any`\>
40
45
 
41
46
  #### Defined in
42
47
 
43
- [src/RestResponse.ts:18](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L18)
48
+ [src/RestResponse.ts:19](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L19)
49
+
50
+ ___
51
+
52
+ ### agent
53
+
54
+ • `Readonly` **agent**: ``null`` \| `Agent`
55
+
56
+ #### Defined in
57
+
58
+ [src/RestResponse.ts:20](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L20)
44
59
 
45
60
  ___
46
61
 
@@ -50,7 +65,7 @@ ___
50
65
 
51
66
  #### Defined in
52
67
 
53
- [src/RestResponse.ts:19](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L19)
68
+ [src/RestResponse.ts:21](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L21)
54
69
 
55
70
  ___
56
71
 
@@ -60,7 +75,7 @@ ___
60
75
 
61
76
  #### Defined in
62
77
 
63
- [src/RestResponse.ts:20](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L20)
78
+ [src/RestResponse.ts:22](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L22)
64
79
 
65
80
  ___
66
81
 
@@ -70,7 +85,7 @@ ___
70
85
 
71
86
  #### Defined in
72
87
 
73
- [src/RestResponse.ts:21](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L21)
88
+ [src/RestResponse.ts:23](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L23)
74
89
 
75
90
  ___
76
91
 
@@ -80,7 +95,7 @@ ___
80
95
 
81
96
  #### Defined in
82
97
 
83
- [src/RestResponse.ts:22](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L22)
98
+ [src/RestResponse.ts:24](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L24)
84
99
 
85
100
  ## Accessors
86
101
 
@@ -107,4 +122,4 @@ RestRequest.json() instead.
107
122
 
108
123
  #### Defined in
109
124
 
110
- [src/RestResponse.ts:40](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L40)
125
+ [src/RestResponse.ts:42](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L42)
@@ -22,7 +22,7 @@
22
22
 
23
23
  ### constructor
24
24
 
25
- • **new RestResponseError**(`message`, `res`)
25
+ • **new RestResponseError**(`message`, `res`): [`RestResponseError`](RestResponseError.md)
26
26
 
27
27
  #### Parameters
28
28
 
@@ -31,6 +31,10 @@
31
31
  | `message` | `string` |
32
32
  | `res` | [`RestResponse`](RestResponse.md) |
33
33
 
34
+ #### Returns
35
+
36
+ [`RestResponseError`](RestResponseError.md)
37
+
34
38
  #### Overrides
35
39
 
36
40
  [RestError](RestError.md).[constructor](RestError.md#constructor)
@@ -12,7 +12,7 @@
12
12
 
13
13
  ### constructor
14
14
 
15
- • **new RestRetriableError**(`message`, `delayMs`, `res`)
15
+ • **new RestRetriableError**(`message`, `delayMs`, `res`): [`RestRetriableError`](RestRetriableError.md)
16
16
 
17
17
  #### Parameters
18
18
 
@@ -22,6 +22,10 @@
22
22
  | `delayMs` | `number` |
23
23
  | `res` | [`RestResponse`](RestResponse.md) |
24
24
 
25
+ #### Returns
26
+
27
+ [`RestRetriableError`](RestRetriableError.md)
28
+
25
29
  #### Overrides
26
30
 
27
31
  [RestResponseError](RestResponseError.md).[constructor](RestResponseError.md#constructor)
@@ -136,4 +140,4 @@ ___
136
140
 
137
141
  #### Defined in
138
142
 
139
- [src/errors/RestRetriableError.ts:5](https://github.com/clickup/rest-client/blob/master/src/errors/RestRetriableError.ts#L5)
143
+ [src/errors/RestRetriableError.ts:7](https://github.com/clickup/rest-client/blob/master/src/errors/RestRetriableError.ts#L7)
@@ -15,7 +15,7 @@ use something like `Buffer.from(responseText, "binary")`.
15
15
 
16
16
  ### constructor
17
17
 
18
- • **new RestStream**(`res`, `readerIterable`)
18
+ • **new RestStream**(`res`, `readerIterable`): [`RestStream`](RestStream.md)
19
19
 
20
20
  #### Parameters
21
21
 
@@ -23,7 +23,11 @@ use something like `Buffer.from(responseText, "binary")`.
23
23
  | :------ | :------ |
24
24
  | `res` | [`RestResponse`](RestResponse.md) |
25
25
  | `readerIterable` | `Object` |
26
- | `readerIterable.[asyncIterator]` | () => `AsyncGenerator`<`string`, `void`, `unknown`\> |
26
+ | `readerIterable.[asyncIterator]` | () => `AsyncGenerator`\<`string`, `void`, `unknown`\> |
27
+
28
+ #### Returns
29
+
30
+ [`RestStream`](RestStream.md)
27
31
 
28
32
  #### Defined in
29
33
 
@@ -43,7 +47,7 @@ use something like `Buffer.from(responseText, "binary")`.
43
47
 
44
48
  ### consumeReturningPrefix
45
49
 
46
- ▸ **consumeReturningPrefix**(`maxChars`): `Promise`<`string`\>
50
+ ▸ **consumeReturningPrefix**(`maxChars`): `Promise`\<`string`\>
47
51
 
48
52
  Reads the prefix of the stream. Closes the connection after the read is
49
53
  done in all cases, so safe to be used to e.g. receive a trimmed response.
@@ -56,7 +60,7 @@ done in all cases, so safe to be used to e.g. receive a trimmed response.
56
60
 
57
61
  #### Returns
58
62
 
59
- `Promise`<`string`\>
63
+ `Promise`\<`string`\>
60
64
 
61
65
  #### Defined in
62
66
 
@@ -66,13 +70,13 @@ ___
66
70
 
67
71
  ### close
68
72
 
69
- ▸ **close**(): `Promise`<`void`\>
73
+ ▸ **close**(): `Promise`\<`void`\>
70
74
 
71
75
  Closes the connection.
72
76
 
73
77
  #### Returns
74
78
 
75
- `Promise`<`void`\>
79
+ `Promise`\<`void`\>
76
80
 
77
81
  #### Defined in
78
82
 
@@ -82,7 +86,7 @@ ___
82
86
 
83
87
  ### [asyncIterator]
84
88
 
85
- ▸ **[asyncIterator]**(): `AsyncGenerator`<`string`, `void`, `unknown`\>
89
+ ▸ **[asyncIterator]**(): `AsyncGenerator`\<`string`, `void`, `unknown`\>
86
90
 
87
91
  Allows to iterate over the entire stream of data. You must consume the
88
92
  entire iterable or at least call this.close(), otherwise the connection may
@@ -90,7 +94,7 @@ remain open.
90
94
 
91
95
  #### Returns
92
96
 
93
- `AsyncGenerator`<`string`, `void`, `unknown`\>
97
+ `AsyncGenerator`\<`string`, `void`, `unknown`\>
94
98
 
95
99
  #### Defined in
96
100
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  ### constructor
14
14
 
15
- • **new RestTimeoutError**(`message`, `res`)
15
+ • **new RestTimeoutError**(`message`, `res`): [`RestTimeoutError`](RestTimeoutError.md)
16
16
 
17
17
  #### Parameters
18
18
 
@@ -21,6 +21,10 @@
21
21
  | `message` | `string` |
22
22
  | `res` | [`RestResponse`](RestResponse.md) |
23
23
 
24
+ #### Returns
25
+
26
+ [`RestTimeoutError`](RestTimeoutError.md)
27
+
24
28
  #### Inherited from
25
29
 
26
30
  [RestResponseError](RestResponseError.md).[constructor](RestResponseError.md#constructor)
@@ -12,7 +12,7 @@
12
12
 
13
13
  ### constructor
14
14
 
15
- • **new RestTokenInvalidError**(`humanReason`, `res`)
15
+ • **new RestTokenInvalidError**(`humanReason`, `res`): [`RestTokenInvalidError`](RestTokenInvalidError.md)
16
16
 
17
17
  #### Parameters
18
18
 
@@ -21,6 +21,10 @@
21
21
  | `humanReason` | `string` |
22
22
  | `res` | [`RestResponse`](RestResponse.md) |
23
23
 
24
+ #### Returns
25
+
26
+ [`RestTokenInvalidError`](RestTokenInvalidError.md)
27
+
24
28
  #### Overrides
25
29
 
26
30
  [RestResponseError](RestResponseError.md).[constructor](RestResponseError.md#constructor)
@@ -135,4 +139,4 @@ ___
135
139
 
136
140
  #### Defined in
137
141
 
138
- [src/errors/RestTokenInvalidError.ts:5](https://github.com/clickup/rest-client/blob/master/src/errors/RestTokenInvalidError.ts#L5)
142
+ [src/errors/RestTokenInvalidError.ts:6](https://github.com/clickup/rest-client/blob/master/src/errors/RestTokenInvalidError.ts#L6)
@@ -9,18 +9,18 @@ request processing.
9
9
 
10
10
  ### Middleware
11
11
 
12
- ▸ **Middleware**(`req`, `next`): `Promise`<[`RestResponse`](../classes/RestResponse.md)\>
12
+ ▸ **Middleware**(`req`, `next`): `Promise`\<[`RestResponse`](../classes/RestResponse.md)\>
13
13
 
14
14
  #### Parameters
15
15
 
16
16
  | Name | Type |
17
17
  | :------ | :------ |
18
- | `req` | [`RestRequest`](../classes/RestRequest.md)<`any`\> |
19
- | `next` | (`req`: [`RestRequest`](../classes/RestRequest.md)<`any`\>) => `Promise`<[`RestResponse`](../classes/RestResponse.md)\> |
18
+ | `req` | [`RestRequest`](../classes/RestRequest.md)\<`any`\> |
19
+ | `next` | (`req`: [`RestRequest`](../classes/RestRequest.md)\<`any`\>) => `Promise`\<[`RestResponse`](../classes/RestResponse.md)\> |
20
20
 
21
21
  #### Returns
22
22
 
23
- `Promise`<[`RestResponse`](../classes/RestResponse.md)\>
23
+ `Promise`\<[`RestResponse`](../classes/RestResponse.md)\>
24
24
 
25
25
  #### Defined in
26
26
 
@@ -26,14 +26,14 @@ Human readable name of the pacer, used when composing multiple pacers.
26
26
 
27
27
  ### touch
28
28
 
29
- ▸ **touch**(): `Promise`<[`PacerDelay`](PacerDelay.md)\>
29
+ ▸ **touch**(): `Promise`\<[`PacerDelay`](PacerDelay.md)\>
30
30
 
31
31
  Signals that we're about to send a request. Returns the delay we need to
32
32
  wait for before actually sending.
33
33
 
34
34
  #### Returns
35
35
 
36
- `Promise`<[`PacerDelay`](PacerDelay.md)\>
36
+ `Promise`\<[`PacerDelay`](PacerDelay.md)\>
37
37
 
38
38
  #### Defined in
39
39
 
@@ -18,7 +18,7 @@ Resource key which this backend is operating on.
18
18
 
19
19
  ### push
20
20
 
21
- ▸ **push**(`props`): `Promise`<{ `count`: `number` ; `sum`: `number` ; `avg`: `number` ; `median`: `number` }\>
21
+ ▸ **push**(`props`): `Promise`\<\{ `count`: `number` ; `sum`: `number` ; `avg`: `number` ; `median`: `number` }\>
22
22
 
23
23
  Maintains the array of numbers somewhere in memory (time-value pairs),
24
24
  inserts a new time-value pair to the end of this list, and removes all the
@@ -37,7 +37,7 @@ array and some central tendency statistics about its values.
37
37
 
38
38
  #### Returns
39
39
 
40
- `Promise`<{ `count`: `number` ; `sum`: `number` ; `avg`: `number` ; `median`: `number` }\>
40
+ `Promise`\<\{ `count`: `number` ; `sum`: `number` ; `avg`: `number` ; `median`: `number` }\>
41
41
 
42
42
  #### Defined in
43
43
 
@@ -18,7 +18,7 @@ ___
18
18
 
19
19
  ### req
20
20
 
21
- • **req**: [`RestRequest`](../classes/RestRequest.md)<`any`\>
21
+ • **req**: [`RestRequest`](../classes/RestRequest.md)\<`any`\>
22
22
 
23
23
  #### Defined in
24
24
 
@@ -16,7 +16,7 @@ web app, and we don't want to retry them.
16
16
 
17
17
  #### Defined in
18
18
 
19
- [src/RestOptions.ts:69](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L69)
19
+ [src/RestOptions.ts:70](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L70)
20
20
 
21
21
  ___
22
22
 
@@ -28,7 +28,7 @@ How much time to wait by default on the 1st retry attempt.
28
28
 
29
29
  #### Defined in
30
30
 
31
- [src/RestOptions.ts:71](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L71)
31
+ [src/RestOptions.ts:72](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L72)
32
32
 
33
33
  ___
34
34
 
@@ -40,7 +40,7 @@ How much to increase the retry delay on each retry.
40
40
 
41
41
  #### Defined in
42
42
 
43
- [src/RestOptions.ts:73](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L73)
43
+ [src/RestOptions.ts:74](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L74)
44
44
 
45
45
  ___
46
46
 
@@ -53,7 +53,7 @@ Use this fraction (random) of the current retry delay to jitter both ways
53
53
 
54
54
  #### Defined in
55
55
 
56
- [src/RestOptions.ts:76](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L76)
56
+ [src/RestOptions.ts:77](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L77)
57
57
 
58
58
  ___
59
59
 
@@ -65,7 +65,7 @@ Maximum delay between each retry.
65
65
 
66
66
  #### Defined in
67
67
 
68
- [src/RestOptions.ts:78](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L78)
68
+ [src/RestOptions.ts:79](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L79)
69
69
 
70
70
  ___
71
71
 
@@ -79,12 +79,12 @@ A logic which runs on different IO stages (delay and heartbeats).
79
79
 
80
80
  | Name | Type |
81
81
  | :------ | :------ |
82
- | `heartbeat` | () => `Promise`<`void`\> |
83
- | `delay` | (`ms`: `number`) => `Promise`<`void`\> |
82
+ | `heartbeat` | () => `Promise`\<`void`\> |
83
+ | `delay` | (`ms`: `number`) => `Promise`\<`void`\> |
84
84
 
85
85
  #### Defined in
86
86
 
87
- [src/RestOptions.ts:80](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L80)
87
+ [src/RestOptions.ts:81](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L81)
88
88
 
89
89
  ___
90
90
 
@@ -96,7 +96,7 @@ Allows to limit huge requests and throw instead.
96
96
 
97
97
  #### Defined in
98
98
 
99
- [src/RestOptions.ts:91](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L91)
99
+ [src/RestOptions.ts:92](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L92)
100
100
 
101
101
  ___
102
102
 
@@ -109,7 +109,7 @@ response or not.
109
109
 
110
110
  #### Defined in
111
111
 
112
- [src/RestOptions.ts:94](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L94)
112
+ [src/RestOptions.ts:95](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L95)
113
113
 
114
114
  ___
115
115
 
@@ -122,7 +122,7 @@ addresses are allowed.
122
122
 
123
123
  #### Defined in
124
124
 
125
- [src/RestOptions.ts:97](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L97)
125
+ [src/RestOptions.ts:98](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L98)
126
126
 
127
127
  ___
128
128
 
@@ -134,7 +134,7 @@ If true, logs request-response pairs to console.
134
134
 
135
135
  #### Defined in
136
136
 
137
- [src/RestOptions.ts:99](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L99)
137
+ [src/RestOptions.ts:100](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L100)
138
138
 
139
139
  ___
140
140
 
@@ -148,13 +148,12 @@ Sets Keep-Alive parameters (persistent connections).
148
148
 
149
149
  | Name | Type | Description |
150
150
  | :------ | :------ | :------ |
151
- | `timeout` | `number` | A hint to the server, how much time to keep the connection alive. Not all the servers respect it though (e.g. nginx and express do not). |
152
- | `max` | `number` | How many requests are allowed to be processed in one connection. |
151
+ | `timeoutMs` | `number` | How much time to keep an idle connection alive in the pool. If 0, closes the connection immediately after the response. |
153
152
  | `maxSockets?` | `number` | How many sockets at maximum will be kept open. |
154
153
 
155
154
  #### Defined in
156
155
 
157
- [src/RestOptions.ts:103](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L103)
156
+ [src/RestOptions.ts:104](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L104)
158
157
 
159
158
  ___
160
159
 
@@ -166,7 +165,7 @@ When resolving DNS, use IPv4, IPv6 or both (see dns.lookup() docs).
166
165
 
167
166
  #### Defined in
168
167
 
169
- [src/RestOptions.ts:113](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L113)
168
+ [src/RestOptions.ts:112](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L112)
170
169
 
171
170
  ___
172
171
 
@@ -178,7 +177,7 @@ Max timeout to wait for a response.
178
177
 
179
178
  #### Defined in
180
179
 
181
- [src/RestOptions.ts:115](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L115)
180
+ [src/RestOptions.ts:114](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L114)
182
181
 
183
182
  ___
184
183
 
@@ -186,6 +185,9 @@ ___
186
185
 
187
186
  • **logger**: (`event`: [`RestLogEvent`](RestLogEvent.md)) => `void`
188
187
 
188
+ Logger to be used for each responses (including retried) plus for backoff
189
+ delay events logging.
190
+
189
191
  #### Type declaration
190
192
 
191
193
  ▸ (`event`): `void`
@@ -205,7 +207,7 @@ delay events logging.
205
207
 
206
208
  #### Defined in
207
209
 
208
- [src/RestOptions.ts:118](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L118)
210
+ [src/RestOptions.ts:117](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L117)
209
211
 
210
212
  ___
211
213
 
@@ -217,7 +219,7 @@ Middlewares to wrap requests. May alter both request and response.
217
219
 
218
220
  #### Defined in
219
221
 
220
- [src/RestOptions.ts:120](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L120)
222
+ [src/RestOptions.ts:119](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L119)
221
223
 
222
224
  ___
223
225
 
@@ -225,6 +227,19 @@ ___
225
227
 
226
228
  • **isSuccessResponse**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
227
229
 
230
+ If set, makes decision whether the response is successful or not. The
231
+ response will either be returned to the client, or an error will be thrown.
232
+ This allows to treat some non-successful HTTP statuses as success if the
233
+ remote API is that weird. Return values:
234
+ * "SUCCESS" - the request will be considered successful, no further checks
235
+ will be performed;
236
+ * "BEST_EFFORT" - inconclusive, the request may be either successful or
237
+ unsuccessful, additional tests (e.g. will check HTTP status code) will be
238
+ performed;
239
+ * "THROW" - the request resulted in error. Additional tests will be
240
+ performed to determine is the error is retriable, is OAuth token good,
241
+ and etc.
242
+
228
243
  #### Type declaration
229
244
 
230
245
  ▸ (`res`): ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
@@ -254,7 +269,7 @@ remote API is that weird. Return values:
254
269
 
255
270
  #### Defined in
256
271
 
257
- [src/RestOptions.ts:134](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L134)
272
+ [src/RestOptions.ts:132](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L132)
258
273
 
259
274
  ___
260
275
 
@@ -262,6 +277,16 @@ ___
262
277
 
263
278
  • **isRateLimitError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
264
279
 
280
+ Decides whether the response is a rate-limit error or not. Returning
281
+ non-zero value is treated as retry delay (if retries are set up). In case
282
+ the returned value is "SOMETHING_ELSE", the response ought to be either
283
+ success or some other error. Returning "BEST_EFFORT" turns on built-in
284
+ heuristic (e.g. relying on HTTP status code and Retry-After header). In
285
+ case we've made a decision that it's a rate limited error, the request is
286
+ always retried; this covers a very common case when we have both
287
+ isRateLimitError and isRetriableError handlers set up, and they return
288
+ contradictory information; then isRateLimitError wins.
289
+
265
290
  #### Type declaration
266
291
 
267
292
  ▸ (`res`): `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
@@ -288,7 +313,7 @@ contradictory information; then isRateLimitError wins.
288
313
 
289
314
  #### Defined in
290
315
 
291
- [src/RestOptions.ts:144](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L144)
316
+ [src/RestOptions.ts:142](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L142)
292
317
 
293
318
  ___
294
319
 
@@ -296,6 +321,9 @@ ___
296
321
 
297
322
  • **isTokenInvalidError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `boolean`
298
323
 
324
+ Decides whether the response is a token-invalid error or not. In case it's
325
+ not, the response ought to be either success or some other error.
326
+
299
327
  #### Type declaration
300
328
 
301
329
  ▸ (`res`): `boolean`
@@ -315,7 +343,7 @@ not, the response ought to be either success or some other error.
315
343
 
316
344
  #### Defined in
317
345
 
318
- [src/RestOptions.ts:149](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L149)
346
+ [src/RestOptions.ts:147](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L147)
319
347
 
320
348
  ___
321
349
 
@@ -323,6 +351,14 @@ ___
323
351
 
324
352
  • **isRetriableError**: (`res`: [`RestResponse`](../classes/RestResponse.md), `_error`: `any`) => `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
325
353
 
354
+ Called only if we haven't decided earlier that it's a rate limit error.
355
+ Decides whether the response is a retriable error or not. In case the
356
+ returned value is "NEVER_RETRY", the response ought to be either success or
357
+ some other error, but it's guaranteed that the request won't be retried.
358
+ Returning "BEST_EFFORT" turns on built-in heuristics (e.g. never retry "not
359
+ found" errors). Returning a number is treated as "RETRY", and the next
360
+ retry will happen in not less than this number of milliseconds.
361
+
326
362
  #### Type declaration
327
363
 
328
364
  ▸ (`res`, `_error`): `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
@@ -348,4 +384,4 @@ retry will happen in not less than this number of milliseconds.
348
384
 
349
385
  #### Defined in
350
386
 
351
- [src/RestOptions.ts:157](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L157)
387
+ [src/RestOptions.ts:155](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L155)
@@ -1,6 +1,6 @@
1
1
  [@clickup/rest-client](../README.md) / [Exports](../modules.md) / TokenGetter
2
2
 
3
- # Interface: TokenGetter<TData\>
3
+ # Interface: TokenGetter\<TData\>
4
4
 
5
5
  A callback which returns access token, possibly after refreshing it, and also
6
6
  possibly before a retry on "invalid token" condition. I.e. it can be called
@@ -17,7 +17,7 @@ will be passed as a parameter).
17
17
 
18
18
  ### TokenGetter
19
19
 
20
- ▸ **TokenGetter**(`prevError`): `Promise`<`TData`\>
20
+ ▸ **TokenGetter**(`prevError`): `Promise`\<`TData`\>
21
21
 
22
22
  #### Parameters
23
23
 
@@ -27,7 +27,7 @@ will be passed as a parameter).
27
27
 
28
28
  #### Returns
29
29
 
30
- `Promise`<`TData`\>
30
+ `Promise`\<`TData`\>
31
31
 
32
32
  #### Defined in
33
33
 
package/docs/modules.md CHANGED
@@ -33,7 +33,7 @@
33
33
 
34
34
  ### depaginate
35
35
 
36
- ▸ **depaginate**<`TItem`, `TCursor`\>(`readFunc`): `AsyncGenerator`<`TItem`, `void`, `undefined`\>
36
+ ▸ **depaginate**\<`TItem`, `TCursor`\>(`readFunc`): `AsyncGenerator`\<`TItem`, `void`, `undefined`\>
37
37
 
38
38
  Keeps calling a function with an updating cursor, and depaginates all the
39
39
  results until the cursor returned is null or undefined.
@@ -53,11 +53,11 @@ On each call, the inner function needs to return an array with two elements:
53
53
 
54
54
  | Name | Type |
55
55
  | :------ | :------ |
56
- | `readFunc` | (`cursor`: `undefined` \| `TCursor`) => `Promise`<[`TItem`[], `undefined` \| ``null`` \| `TCursor`]\> |
56
+ | `readFunc` | (`cursor`: `undefined` \| `TCursor`) => `Promise`\<readonly [`TItem`[], `undefined` \| ``null`` \| `TCursor`]\> |
57
57
 
58
58
  #### Returns
59
59
 
60
- `AsyncGenerator`<`TItem`, `void`, `undefined`\>
60
+ `AsyncGenerator`\<`TItem`, `void`, `undefined`\>
61
61
 
62
62
  #### Defined in
63
63
 
@@ -76,7 +76,7 @@ Pacer implementations.
76
76
 
77
77
  | Name | Type |
78
78
  | :------ | :------ |
79
- | `pacer` | ``null`` \| [`Pacer`](interfaces/Pacer.md) \| (`req`: [`RestRequest`](classes/RestRequest.md)<`any`\>) => `Promise`<``null`` \| [`Pacer`](interfaces/Pacer.md)\> |
79
+ | `pacer` | ``null`` \| [`Pacer`](interfaces/Pacer.md) \| (`req`: [`RestRequest`](classes/RestRequest.md)\<`any`\>) => `Promise`\<``null`` \| [`Pacer`](interfaces/Pacer.md)\> |
80
80
 
81
81
  #### Returns
82
82
 
package/jest.config.js CHANGED
@@ -2,6 +2,9 @@
2
2
  module.exports = {
3
3
  roots: ["<rootDir>/src"],
4
4
  testMatch: ["**/*.test.ts"],
5
+ clearMocks: true,
6
+ restoreMocks: true,
7
+ ...(process.env.IN_JEST_PROJECT ? {} : { forceExit: true }),
5
8
  transform: {
6
9
  "\\.ts$": "ts-jest",
7
10
  },