@clickup/rest-client 2.10.294 → 2.11.0

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 (120) hide show
  1. package/.eslintrc.base.js +12 -2
  2. package/.eslintrc.js +4 -4
  3. package/.github/workflows/ci.yml +26 -0
  4. package/.github/workflows/semgrep.yml +36 -0
  5. package/.prettierrc +8 -0
  6. package/.vscode/extensions.json +8 -0
  7. package/.vscode/tasks.json +20 -0
  8. package/README.md +2 -0
  9. package/dist/.eslintcache +1 -1
  10. package/dist/RestClient.js +2 -2
  11. package/dist/RestClient.js.map +1 -1
  12. package/dist/RestOptions.d.ts +3 -0
  13. package/dist/RestOptions.d.ts.map +1 -1
  14. package/dist/RestOptions.js +1 -0
  15. package/dist/RestOptions.js.map +1 -1
  16. package/dist/RestRequest.d.ts.map +1 -1
  17. package/dist/RestRequest.js +1 -0
  18. package/dist/RestRequest.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/index.d.ts +2 -5
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -5
  28. package/dist/index.js.map +1 -1
  29. package/dist/internal/RestFetchReader.d.ts +4 -2
  30. package/dist/internal/RestFetchReader.d.ts.map +1 -1
  31. package/dist/internal/RestFetchReader.js +4 -4
  32. package/dist/internal/RestFetchReader.js.map +1 -1
  33. package/dist/internal/ellipsis.d.ts +6 -0
  34. package/dist/internal/ellipsis.d.ts.map +1 -0
  35. package/dist/internal/ellipsis.js +17 -0
  36. package/dist/internal/ellipsis.js.map +1 -0
  37. package/dist/internal/inferResBodyEncoding.js.map +1 -1
  38. package/dist/internal/inspectPossibleJSON.js +5 -8
  39. package/dist/internal/inspectPossibleJSON.js.map +1 -1
  40. package/dist/internal/throwIfErrorResponse.js +1 -1
  41. package/dist/internal/throwIfErrorResponse.js.map +1 -1
  42. package/dist/middlewares/paceRequests.d.ts +21 -2
  43. package/dist/middlewares/paceRequests.d.ts.map +1 -1
  44. package/dist/middlewares/paceRequests.js +3 -2
  45. package/dist/middlewares/paceRequests.js.map +1 -1
  46. package/docs/README.md +2 -0
  47. package/docs/classes/RestClient.md +32 -28
  48. package/docs/classes/RestContentSizeOverLimitError.md +5 -1
  49. package/docs/classes/RestError.md +5 -1
  50. package/docs/classes/RestRateLimitError.md +6 -2
  51. package/docs/classes/RestRequest.md +22 -18
  52. package/docs/classes/RestResponse.md +7 -3
  53. package/docs/classes/RestResponseError.md +5 -1
  54. package/docs/classes/RestRetriableError.md +6 -2
  55. package/docs/classes/RestStream.md +12 -8
  56. package/docs/classes/RestTimeoutError.md +5 -1
  57. package/docs/classes/RestTokenInvalidError.md +6 -2
  58. package/docs/interfaces/Middleware.md +4 -4
  59. package/docs/interfaces/Pacer.md +7 -12
  60. package/docs/interfaces/PacerOutcome.md +25 -0
  61. package/docs/interfaces/RestLogEvent.md +1 -1
  62. package/docs/interfaces/RestOptions.md +42 -30
  63. package/docs/interfaces/TokenGetter.md +3 -3
  64. package/docs/modules.md +8 -11
  65. package/internal/clean.sh +4 -0
  66. package/internal/deploy.sh +7 -0
  67. package/internal/docs.sh +6 -0
  68. package/internal/lint.sh +4 -0
  69. package/jest.config.base.js +13 -0
  70. package/jest.config.js +1 -10
  71. package/package.json +10 -6
  72. package/src/RestClient.ts +21 -21
  73. package/src/RestOptions.ts +6 -3
  74. package/src/RestRequest.ts +12 -11
  75. package/src/RestResponse.ts +1 -1
  76. package/src/RestStream.ts +1 -1
  77. package/src/__tests__/RestClient.test.ts +53 -0
  78. package/src/__tests__/RestFetchReader.test.ts +150 -0
  79. package/src/__tests__/RestRequest.test.ts +262 -0
  80. package/src/__tests__/RestStream.test.ts +63 -0
  81. package/src/__tests__/helpers.ts +173 -0
  82. package/src/errors/RestRateLimitError.ts +5 -1
  83. package/src/errors/RestResponseError.ts +3 -3
  84. package/src/errors/RestRetriableError.ts +5 -1
  85. package/src/errors/RestTokenInvalidError.ts +4 -1
  86. package/src/helpers/depaginate.ts +3 -3
  87. package/src/index.ts +2 -7
  88. package/src/internal/RestFetchReader.ts +6 -3
  89. package/src/internal/RestRangeUploader.ts +2 -2
  90. package/src/internal/calcRetryDelay.ts +2 -2
  91. package/src/internal/ellipsis.ts +16 -0
  92. package/src/internal/inferResBodyEncoding.ts +13 -13
  93. package/src/internal/inspectPossibleJSON.ts +6 -10
  94. package/src/internal/substituteParams.ts +1 -1
  95. package/src/internal/throwIfErrorResponse.ts +8 -8
  96. package/src/middlewares/paceRequests.ts +28 -3
  97. package/tsconfig.base.json +31 -0
  98. package/tsconfig.json +1 -32
  99. package/typedoc.config.js +20 -0
  100. package/dist/pacers/Pacer.d.ts +0 -21
  101. package/dist/pacers/Pacer.d.ts.map +0 -1
  102. package/dist/pacers/Pacer.js +0 -3
  103. package/dist/pacers/Pacer.js.map +0 -1
  104. package/dist/pacers/PacerComposite.d.ts +0 -14
  105. package/dist/pacers/PacerComposite.d.ts.map +0 -1
  106. package/dist/pacers/PacerComposite.js +0 -32
  107. package/dist/pacers/PacerComposite.js.map +0 -1
  108. package/dist/pacers/PacerQPS.d.ts +0 -53
  109. package/dist/pacers/PacerQPS.d.ts.map +0 -1
  110. package/dist/pacers/PacerQPS.js +0 -105
  111. package/dist/pacers/PacerQPS.js.map +0 -1
  112. package/docs/classes/PacerComposite.md +0 -62
  113. package/docs/classes/PacerQPS.md +0 -75
  114. package/docs/interfaces/PacerDelay.md +0 -25
  115. package/docs/interfaces/PacerQPSBackend.md +0 -44
  116. package/docs/interfaces/PacerQPSOptions.md +0 -40
  117. package/src/pacers/Pacer.ts +0 -22
  118. package/src/pacers/PacerComposite.ts +0 -29
  119. package/src/pacers/PacerQPS.ts +0 -147
  120. package/typedoc.json +0 -22
@@ -1,6 +1,6 @@
1
1
  [@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestRequest
2
2
 
3
- # Class: RestRequest<TAssertShape\>
3
+ # Class: RestRequest\<TAssertShape\>
4
4
 
5
5
  Type TAssertShape allows to limit json()'s assert callbacks to only those
6
6
  which return an object compatible with TAssertShape.
@@ -15,7 +15,7 @@ which return an object compatible with TAssertShape.
15
15
 
16
16
  ### constructor
17
17
 
18
- • **new RestRequest**<`TAssertShape`\>(`options`, `method`, `url`, `headers`, `body`, `shape?`)
18
+ • **new RestRequest**\<`TAssertShape`\>(`options`, `method`, `url`, `headers`, `body`, `shape?`): [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
19
19
 
20
20
  #### Type parameters
21
21
 
@@ -34,6 +34,10 @@ which return an object compatible with TAssertShape.
34
34
  | `body` | `string` \| `Buffer` \| `ReadableStream` |
35
35
  | `shape?` | `string` |
36
36
 
37
+ #### Returns
38
+
39
+ [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
40
+
37
41
  #### Defined in
38
42
 
39
43
  [src/RestRequest.ts:30](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L30)
@@ -102,7 +106,7 @@ ___
102
106
 
103
107
  ### setHeader
104
108
 
105
- ▸ **setHeader**(`name`, `value`): [`RestRequest`](RestRequest.md)<`TAssertShape`\>
109
+ ▸ **setHeader**(`name`, `value`): [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
106
110
 
107
111
  Modifies the request by adding a custom HTTP header.
108
112
 
@@ -115,7 +119,7 @@ Modifies the request by adding a custom HTTP header.
115
119
 
116
120
  #### Returns
117
121
 
118
- [`RestRequest`](RestRequest.md)<`TAssertShape`\>
122
+ [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
119
123
 
120
124
  #### Defined in
121
125
 
@@ -125,7 +129,7 @@ ___
125
129
 
126
130
  ### setOptions
127
131
 
128
- ▸ **setOptions**(`options`): [`RestRequest`](RestRequest.md)<`TAssertShape`\>
132
+ ▸ **setOptions**(`options`): [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
129
133
 
130
134
  Modifies the request by adding a custom request option.
131
135
 
@@ -133,11 +137,11 @@ Modifies the request by adding a custom request option.
133
137
 
134
138
  | Name | Type |
135
139
  | :------ | :------ |
136
- | `options` | `Partial`<[`RestOptions`](../interfaces/RestOptions.md)\> |
140
+ | `options` | `Partial`\<[`RestOptions`](../interfaces/RestOptions.md)\> |
137
141
 
138
142
  #### Returns
139
143
 
140
- [`RestRequest`](RestRequest.md)<`TAssertShape`\>
144
+ [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
141
145
 
142
146
  #### Defined in
143
147
 
@@ -147,7 +151,7 @@ ___
147
151
 
148
152
  ### setDebug
149
153
 
150
- ▸ **setDebug**(`flag?`): [`RestRequest`](RestRequest.md)<`TAssertShape`\>
154
+ ▸ **setDebug**(`flag?`): [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
151
155
 
152
156
  Forces RestClient to debug-output the request and response to console.
153
157
  Never use in production.
@@ -160,7 +164,7 @@ Never use in production.
160
164
 
161
165
  #### Returns
162
166
 
163
- [`RestRequest`](RestRequest.md)<`TAssertShape`\>
167
+ [`RestRequest`](RestRequest.md)\<`TAssertShape`\>
164
168
 
165
169
  #### Defined in
166
170
 
@@ -170,7 +174,7 @@ ___
170
174
 
171
175
  ### json
172
176
 
173
- ▸ **json**<`TJson`\>(`assert`, `...checkers`): `Promise`<`TJson`\>
177
+ ▸ **json**\<`TJson`\>(`assert`, `...checkers`): `Promise`\<`TJson`\>
174
178
 
175
179
  Sends the request and reads the response a JSON. In absolute most of the
176
180
  cases, this method is used to reach API responses. The assert callback
@@ -187,12 +191,12 @@ not let people to do anti-patterns.
187
191
 
188
192
  | Name | Type |
189
193
  | :------ | :------ |
190
- | `assert` | { `mask`: (`obj`: `any`) => `TJson` } \| { `$assert`: (`obj`: `any`) => `TJson` } \| (`obj`: `any`) => `TJson` |
194
+ | `assert` | \{ `mask`: (`obj`: `any`) => `TJson` } \| \{ `$assert`: (`obj`: `any`) => `TJson` } \| (`obj`: `any`) => `TJson` |
191
195
  | `...checkers` | (`json`: `TJson`, `res`: [`RestResponse`](RestResponse.md)) => ``false`` \| `Error`[] |
192
196
 
193
197
  #### Returns
194
198
 
195
- `Promise`<`TJson`\>
199
+ `Promise`\<`TJson`\>
196
200
 
197
201
  #### Defined in
198
202
 
@@ -202,13 +206,13 @@ ___
202
206
 
203
207
  ### text
204
208
 
205
- ▸ **text**(): `Promise`<`string`\>
209
+ ▸ **text**(): `Promise`\<`string`\>
206
210
 
207
211
  Sends the request and returns plaintext response.
208
212
 
209
213
  #### Returns
210
214
 
211
- `Promise`<`string`\>
215
+ `Promise`\<`string`\>
212
216
 
213
217
  #### Defined in
214
218
 
@@ -218,7 +222,7 @@ ___
218
222
 
219
223
  ### response
220
224
 
221
- ▸ **response**(): `Promise`<[`RestResponse`](RestResponse.md)\>
225
+ ▸ **response**(): `Promise`\<[`RestResponse`](RestResponse.md)\>
222
226
 
223
227
  Returns the entire RestResponse object with response status and headers
224
228
  information in it. Try to minimize usage of this method, because it doesn't
@@ -226,7 +230,7 @@ make any assumptions on the response structure.
226
230
 
227
231
  #### Returns
228
232
 
229
- `Promise`<[`RestResponse`](RestResponse.md)\>
233
+ `Promise`\<[`RestResponse`](RestResponse.md)\>
230
234
 
231
235
  #### Defined in
232
236
 
@@ -236,7 +240,7 @@ ___
236
240
 
237
241
  ### stream
238
242
 
239
- ▸ **stream**(`preloadChars?`): `Promise`<[`RestStream`](RestStream.md)\>
243
+ ▸ **stream**(`preloadChars?`): `Promise`\<[`RestStream`](RestStream.md)\>
240
244
 
241
245
  Sends the requests and returns RestStream object. You MUST iterate over
242
246
  this object entirely (or call its return() method), otherwise the
@@ -250,7 +254,7 @@ connection will remain dangling.
250
254
 
251
255
  #### Returns
252
256
 
253
- `Promise`<[`RestStream`](RestStream.md)\>
257
+ `Promise`\<[`RestStream`](RestStream.md)\>
254
258
 
255
259
  #### Defined in
256
260
 
@@ -16,19 +16,23 @@ body and make it a part of RestResponse abstraction.
16
16
 
17
17
  ### constructor
18
18
 
19
- • **new RestResponse**(`req`, `agent`, `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
26
  | `agent` | ``null`` \| `Agent` |
27
27
  | `status` | `number` |
28
28
  | `headers` | `Headers` |
29
29
  | `text` | `string` |
30
30
  | `textIsPartial` | `boolean` |
31
31
 
32
+ #### Returns
33
+
34
+ [`RestResponse`](RestResponse.md)
35
+
32
36
  #### Defined in
33
37
 
34
38
  [src/RestResponse.ts:18](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L18)
@@ -37,7 +41,7 @@ body and make it a part of RestResponse abstraction.
37
41
 
38
42
  ### req
39
43
 
40
- • `Readonly` **req**: [`RestRequest`](RestRequest.md)<`any`\>
44
+ • `Readonly` **req**: [`RestRequest`](RestRequest.md)\<`any`\>
41
45
 
42
46
  #### Defined in
43
47
 
@@ -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
 
@@ -5,36 +5,31 @@
5
5
  Pacer is a class which allows to pace requests on some resource identified by
6
6
  the instance of this class.
7
7
 
8
- ## Implemented by
9
-
10
- - [`PacerComposite`](../classes/PacerComposite.md)
11
- - [`PacerQPS`](../classes/PacerQPS.md)
12
-
13
8
  ## Properties
14
9
 
15
- ### name
10
+ ### key
16
11
 
17
- • `Readonly` **name**: `string`
12
+ • `Readonly` **key**: `string`
18
13
 
19
14
  Human readable name of the pacer, used when composing multiple pacers.
20
15
 
21
16
  #### Defined in
22
17
 
23
- [src/pacers/Pacer.ts:15](https://github.com/clickup/rest-client/blob/master/src/pacers/Pacer.ts#L15)
18
+ [src/middlewares/paceRequests.ts:12](https://github.com/clickup/rest-client/blob/master/src/middlewares/paceRequests.ts#L12)
24
19
 
25
20
  ## Methods
26
21
 
27
- ### touch
22
+ ### pace
28
23
 
29
- ▸ **touch**(): `Promise`<[`PacerDelay`](PacerDelay.md)\>
24
+ ▸ **pace**(): `Promise`\<[`PacerOutcome`](PacerOutcome.md)\>
30
25
 
31
26
  Signals that we're about to send a request. Returns the delay we need to
32
27
  wait for before actually sending.
33
28
 
34
29
  #### Returns
35
30
 
36
- `Promise`<[`PacerDelay`](PacerDelay.md)\>
31
+ `Promise`\<[`PacerOutcome`](PacerOutcome.md)\>
37
32
 
38
33
  #### Defined in
39
34
 
40
- [src/pacers/Pacer.ts:21](https://github.com/clickup/rest-client/blob/master/src/pacers/Pacer.ts#L21)
35
+ [src/middlewares/paceRequests.ts:18](https://github.com/clickup/rest-client/blob/master/src/middlewares/paceRequests.ts#L18)
@@ -0,0 +1,25 @@
1
+ [@clickup/rest-client](../README.md) / [Exports](../modules.md) / PacerOutcome
2
+
3
+ # Interface: PacerOutcome
4
+
5
+ A result of some Pacer work.
6
+
7
+ ## Properties
8
+
9
+ ### delayMs
10
+
11
+ • **delayMs**: `number`
12
+
13
+ #### Defined in
14
+
15
+ [src/middlewares/paceRequests.ts:25](https://github.com/clickup/rest-client/blob/master/src/middlewares/paceRequests.ts#L25)
16
+
17
+ ___
18
+
19
+ ### reason
20
+
21
+ • **reason**: `string`
22
+
23
+ #### Defined in
24
+
25
+ [src/middlewares/paceRequests.ts:26](https://github.com/clickup/rest-client/blob/master/src/middlewares/paceRequests.ts#L26)
@@ -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
 
@@ -79,8 +79,8 @@ 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
 
@@ -126,6 +126,18 @@ addresses are allowed.
126
126
 
127
127
  ___
128
128
 
129
+ ### responseEncoding
130
+
131
+ • **responseEncoding**: `undefined` \| `BufferEncoding`
132
+
133
+ Overrides the default encoding heuristics for responses.
134
+
135
+ #### Defined in
136
+
137
+ [src/RestOptions.ts:100](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L100)
138
+
139
+ ___
140
+
129
141
  ### isDebug
130
142
 
131
143
  • **isDebug**: `boolean`
@@ -134,7 +146,7 @@ If true, logs request-response pairs to console.
134
146
 
135
147
  #### Defined in
136
148
 
137
- [src/RestOptions.ts:100](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L100)
149
+ [src/RestOptions.ts:102](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L102)
138
150
 
139
151
  ___
140
152
 
@@ -153,7 +165,7 @@ Sets Keep-Alive parameters (persistent connections).
153
165
 
154
166
  #### Defined in
155
167
 
156
- [src/RestOptions.ts:104](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L104)
168
+ [src/RestOptions.ts:106](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L106)
157
169
 
158
170
  ___
159
171
 
@@ -165,7 +177,7 @@ When resolving DNS, use IPv4, IPv6 or both (see dns.lookup() docs).
165
177
 
166
178
  #### Defined in
167
179
 
168
- [src/RestOptions.ts:112](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L112)
180
+ [src/RestOptions.ts:114](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L114)
169
181
 
170
182
  ___
171
183
 
@@ -177,7 +189,7 @@ Max timeout to wait for a response.
177
189
 
178
190
  #### Defined in
179
191
 
180
- [src/RestOptions.ts:114](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L114)
192
+ [src/RestOptions.ts:116](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L116)
181
193
 
182
194
  ___
183
195
 
@@ -185,13 +197,13 @@ ___
185
197
 
186
198
  • **logger**: (`event`: [`RestLogEvent`](RestLogEvent.md)) => `void`
187
199
 
200
+ Logger to be used for each responses (including retried) plus for backoff
201
+ delay events logging.
202
+
188
203
  #### Type declaration
189
204
 
190
205
  ▸ (`event`): `void`
191
206
 
192
- Logger to be used for each responses (including retried) plus for backoff
193
- delay events logging.
194
-
195
207
  ##### Parameters
196
208
 
197
209
  | Name | Type |
@@ -204,7 +216,7 @@ delay events logging.
204
216
 
205
217
  #### Defined in
206
218
 
207
- [src/RestOptions.ts:117](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L117)
219
+ [src/RestOptions.ts:119](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L119)
208
220
 
209
221
  ___
210
222
 
@@ -216,7 +228,7 @@ Middlewares to wrap requests. May alter both request and response.
216
228
 
217
229
  #### Defined in
218
230
 
219
- [src/RestOptions.ts:119](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L119)
231
+ [src/RestOptions.ts:121](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L121)
220
232
 
221
233
  ___
222
234
 
@@ -224,10 +236,6 @@ ___
224
236
 
225
237
  • **isSuccessResponse**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
226
238
 
227
- #### Type declaration
228
-
229
- ▸ (`res`): ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
230
-
231
239
  If set, makes decision whether the response is successful or not. The
232
240
  response will either be returned to the client, or an error will be thrown.
233
241
  This allows to treat some non-successful HTTP statuses as success if the
@@ -241,6 +249,10 @@ remote API is that weird. Return values:
241
249
  performed to determine is the error is retriable, is OAuth token good,
242
250
  and etc.
243
251
 
252
+ #### Type declaration
253
+
254
+ ▸ (`res`): ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
255
+
244
256
  ##### Parameters
245
257
 
246
258
  | Name | Type |
@@ -253,7 +265,7 @@ remote API is that weird. Return values:
253
265
 
254
266
  #### Defined in
255
267
 
256
- [src/RestOptions.ts:132](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L132)
268
+ [src/RestOptions.ts:134](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L134)
257
269
 
258
270
  ___
259
271
 
@@ -261,10 +273,6 @@ ___
261
273
 
262
274
  • **isRateLimitError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
263
275
 
264
- #### Type declaration
265
-
266
- ▸ (`res`): `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
267
-
268
276
  Decides whether the response is a rate-limit error or not. Returning
269
277
  non-zero value is treated as retry delay (if retries are set up). In case
270
278
  the returned value is "SOMETHING_ELSE", the response ought to be either
@@ -275,6 +283,10 @@ always retried; this covers a very common case when we have both
275
283
  isRateLimitError and isRetriableError handlers set up, and they return
276
284
  contradictory information; then isRateLimitError wins.
277
285
 
286
+ #### Type declaration
287
+
288
+ ▸ (`res`): `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
289
+
278
290
  ##### Parameters
279
291
 
280
292
  | Name | Type |
@@ -287,7 +299,7 @@ contradictory information; then isRateLimitError wins.
287
299
 
288
300
  #### Defined in
289
301
 
290
- [src/RestOptions.ts:142](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L142)
302
+ [src/RestOptions.ts:144](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L144)
291
303
 
292
304
  ___
293
305
 
@@ -295,13 +307,13 @@ ___
295
307
 
296
308
  • **isTokenInvalidError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `boolean`
297
309
 
310
+ Decides whether the response is a token-invalid error or not. In case it's
311
+ not, the response ought to be either success or some other error.
312
+
298
313
  #### Type declaration
299
314
 
300
315
  ▸ (`res`): `boolean`
301
316
 
302
- Decides whether the response is a token-invalid error or not. In case it's
303
- not, the response ought to be either success or some other error.
304
-
305
317
  ##### Parameters
306
318
 
307
319
  | Name | Type |
@@ -314,7 +326,7 @@ not, the response ought to be either success or some other error.
314
326
 
315
327
  #### Defined in
316
328
 
317
- [src/RestOptions.ts:147](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L147)
329
+ [src/RestOptions.ts:149](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L149)
318
330
 
319
331
  ___
320
332
 
@@ -322,10 +334,6 @@ ___
322
334
 
323
335
  • **isRetriableError**: (`res`: [`RestResponse`](../classes/RestResponse.md), `_error`: `any`) => `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
324
336
 
325
- #### Type declaration
326
-
327
- ▸ (`res`, `_error`): `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
328
-
329
337
  Called only if we haven't decided earlier that it's a rate limit error.
330
338
  Decides whether the response is a retriable error or not. In case the
331
339
  returned value is "NEVER_RETRY", the response ought to be either success or
@@ -334,6 +342,10 @@ Returning "BEST_EFFORT" turns on built-in heuristics (e.g. never retry "not
334
342
  found" errors). Returning a number is treated as "RETRY", and the next
335
343
  retry will happen in not less than this number of milliseconds.
336
344
 
345
+ #### Type declaration
346
+
347
+ ▸ (`res`, `_error`): `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
348
+
337
349
  ##### Parameters
338
350
 
339
351
  | Name | Type |
@@ -347,4 +359,4 @@ retry will happen in not less than this number of milliseconds.
347
359
 
348
360
  #### Defined in
349
361
 
350
- [src/RestOptions.ts:155](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L155)
362
+ [src/RestOptions.ts:157](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L157)