@clickup/rest-client 2.10.294 → 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.
- package/.eslintrc.base.js +2 -1
- package/README.md +2 -0
- package/dist/.eslintcache +1 -1
- package/dist/errors/RestRateLimitError.d.ts.map +1 -1
- package/dist/errors/RestRateLimitError.js.map +1 -1
- package/dist/errors/RestRetriableError.d.ts.map +1 -1
- package/dist/errors/RestRetriableError.js.map +1 -1
- package/dist/errors/RestTokenInvalidError.d.ts.map +1 -1
- package/dist/errors/RestTokenInvalidError.js.map +1 -1
- package/dist/internal/inferResBodyEncoding.js.map +1 -1
- package/docs/README.md +2 -0
- package/docs/classes/PacerComposite.md +7 -3
- package/docs/classes/PacerQPS.md +7 -3
- package/docs/classes/RestClient.md +32 -28
- package/docs/classes/RestContentSizeOverLimitError.md +5 -1
- package/docs/classes/RestError.md +5 -1
- package/docs/classes/RestRateLimitError.md +6 -2
- package/docs/classes/RestRequest.md +22 -18
- package/docs/classes/RestResponse.md +7 -3
- package/docs/classes/RestResponseError.md +5 -1
- package/docs/classes/RestRetriableError.md +6 -2
- package/docs/classes/RestStream.md +12 -8
- package/docs/classes/RestTimeoutError.md +5 -1
- package/docs/classes/RestTokenInvalidError.md +6 -2
- package/docs/interfaces/Middleware.md +4 -4
- package/docs/interfaces/Pacer.md +2 -2
- package/docs/interfaces/PacerQPSBackend.md +2 -2
- package/docs/interfaces/RestLogEvent.md +1 -1
- package/docs/interfaces/RestOptions.md +39 -2
- package/docs/interfaces/TokenGetter.md +3 -3
- package/docs/modules.md +4 -4
- package/package.json +5 -2
- package/src/RestClient.ts +19 -19
- package/src/RestOptions.ts +3 -3
- package/src/RestRequest.ts +11 -11
- package/src/RestResponse.ts +1 -1
- package/src/RestStream.ts +1 -1
- package/src/errors/RestRateLimitError.ts +5 -1
- package/src/errors/RestResponseError.ts +3 -3
- package/src/errors/RestRetriableError.ts +5 -1
- package/src/errors/RestTokenInvalidError.ts +4 -1
- package/src/helpers/depaginate.ts +3 -3
- package/src/internal/RestFetchReader.ts +2 -2
- package/src/internal/RestRangeUploader.ts +2 -2
- package/src/internal/calcRetryDelay.ts +2 -2
- package/src/internal/inferResBodyEncoding.ts +13 -13
- package/src/internal/inspectPossibleJSON.ts +5 -5
- package/src/internal/substituteParams.ts +1 -1
- package/src/internal/throwIfErrorResponse.ts +7 -7
- package/src/middlewares/paceRequests.ts +1 -1
- package/src/pacers/PacerComposite.ts +1 -1
- package/src/pacers/PacerQPS.ts +3 -3
- package/tsconfig.json +3 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestRequest
|
|
2
2
|
|
|
3
|
-
# Class: RestRequest
|
|
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
|
|
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)
|
|
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)
|
|
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)
|
|
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
|
|
140
|
+
| `options` | `Partial`\<[`RestOptions`](../interfaces/RestOptions.md)\> |
|
|
137
141
|
|
|
138
142
|
#### Returns
|
|
139
143
|
|
|
140
|
-
[`RestRequest`](RestRequest.md)
|
|
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)
|
|
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)
|
|
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
|
|
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
|
|
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
|
|
209
|
+
▸ **text**(): `Promise`\<`string`\>
|
|
206
210
|
|
|
207
211
|
Sends the request and returns plaintext response.
|
|
208
212
|
|
|
209
213
|
#### Returns
|
|
210
214
|
|
|
211
|
-
`Promise
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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)
|
|
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)
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
73
|
+
▸ **close**(): `Promise`\<`void`\>
|
|
70
74
|
|
|
71
75
|
Closes the connection.
|
|
72
76
|
|
|
73
77
|
#### Returns
|
|
74
78
|
|
|
75
|
-
`Promise
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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)
|
|
19
|
-
| `next` | (`req`: [`RestRequest`](../classes/RestRequest.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
|
|
23
|
+
`Promise`\<[`RestResponse`](../classes/RestResponse.md)\>
|
|
24
24
|
|
|
25
25
|
#### Defined in
|
|
26
26
|
|
package/docs/interfaces/Pacer.md
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
40
|
+
`Promise`\<\{ `count`: `number` ; `sum`: `number` ; `avg`: `number` ; `median`: `number` }\>
|
|
41
41
|
|
|
42
42
|
#### Defined in
|
|
43
43
|
|
|
@@ -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
|
|
83
|
-
| `delay` | (`ms`: `number`) => `Promise
|
|
82
|
+
| `heartbeat` | () => `Promise`\<`void`\> |
|
|
83
|
+
| `delay` | (`ms`: `number`) => `Promise`\<`void`\> |
|
|
84
84
|
|
|
85
85
|
#### Defined in
|
|
86
86
|
|
|
@@ -185,6 +185,9 @@ ___
|
|
|
185
185
|
|
|
186
186
|
• **logger**: (`event`: [`RestLogEvent`](RestLogEvent.md)) => `void`
|
|
187
187
|
|
|
188
|
+
Logger to be used for each responses (including retried) plus for backoff
|
|
189
|
+
delay events logging.
|
|
190
|
+
|
|
188
191
|
#### Type declaration
|
|
189
192
|
|
|
190
193
|
▸ (`event`): `void`
|
|
@@ -224,6 +227,19 @@ ___
|
|
|
224
227
|
|
|
225
228
|
• **isSuccessResponse**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
|
|
226
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
|
+
|
|
227
243
|
#### Type declaration
|
|
228
244
|
|
|
229
245
|
▸ (`res`): ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
|
|
@@ -261,6 +277,16 @@ ___
|
|
|
261
277
|
|
|
262
278
|
• **isRateLimitError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
|
|
263
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
|
+
|
|
264
290
|
#### Type declaration
|
|
265
291
|
|
|
266
292
|
▸ (`res`): `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
|
|
@@ -295,6 +321,9 @@ ___
|
|
|
295
321
|
|
|
296
322
|
• **isTokenInvalidError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `boolean`
|
|
297
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
|
+
|
|
298
327
|
#### Type declaration
|
|
299
328
|
|
|
300
329
|
▸ (`res`): `boolean`
|
|
@@ -322,6 +351,14 @@ ___
|
|
|
322
351
|
|
|
323
352
|
• **isRetriableError**: (`res`: [`RestResponse`](../classes/RestResponse.md), `_error`: `any`) => `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
|
|
324
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
|
+
|
|
325
362
|
#### Type declaration
|
|
326
363
|
|
|
327
364
|
▸ (`res`, `_error`): `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / TokenGetter
|
|
2
2
|
|
|
3
|
-
# Interface: TokenGetter
|
|
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
|
|
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
|
|
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
|
|
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
|
|
56
|
+
| `readFunc` | (`cursor`: `undefined` \| `TCursor`) => `Promise`\<readonly [`TItem`[], `undefined` \| ``null`` \| `TCursor`]\> |
|
|
57
57
|
|
|
58
58
|
#### Returns
|
|
59
59
|
|
|
60
|
-
`AsyncGenerator
|
|
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)
|
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clickup/rest-client",
|
|
3
3
|
"description": "A syntax sugar tool around Node fetch() API, tailored to work with TypeScript and response validators",
|
|
4
|
-
"version": "2.10.
|
|
4
|
+
"version": "2.10.296",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"rest-client",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint": "eslint . --ext .ts --cache --cache-location dist/.eslintcache",
|
|
28
28
|
"test": "jest",
|
|
29
29
|
"docs": "rm -rf docs && typedoc --plugin typedoc-plugin-markdown --plugin typedoc-plugin-merge-modules && sed -i '' -E 's#packages/[^/]+/##g' $(find docs -type f -name '*.md')",
|
|
30
|
-
"clean": "rm -rf dist node_modules yarn.lock package-lock.json",
|
|
30
|
+
"clean": "rm -rf dist node_modules yarn.lock package-lock.json pnpm-lock.yaml *.log",
|
|
31
31
|
"copy-package-to-public-dir": "copy-package-to-public-dir.sh",
|
|
32
32
|
"backport-package-from-public-dir": "backport-package-from-public-dir.sh",
|
|
33
33
|
"deploy": "npm run build && npm run lint && npm run test && npm publish --access=public"
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@types/jest": "^29.5.5",
|
|
46
46
|
"@types/lodash": "^4.14.175",
|
|
47
47
|
"@types/node-fetch": "^2.6.4",
|
|
48
|
+
"@types/node": "^20.4.1",
|
|
48
49
|
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
49
50
|
"@typescript-eslint/parser": "^5.59.6",
|
|
50
51
|
"eslint-import-resolver-typescript": "^3.5.5",
|
|
@@ -57,6 +58,8 @@
|
|
|
57
58
|
"eslint-plugin-typescript-sort-keys": "^2.3.0",
|
|
58
59
|
"eslint-plugin-unused-imports": "^2.0.0",
|
|
59
60
|
"eslint": "^8.40.0",
|
|
61
|
+
"jest": "^29.7.0",
|
|
62
|
+
"prettier": "3.2.1",
|
|
60
63
|
"superstruct": "^1.0.3",
|
|
61
64
|
"ts-jest": "^29.1.1",
|
|
62
65
|
"typedoc-plugin-markdown": "^3.16.0",
|