@clickup/rest-client 2.10.292
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 +412 -0
- package/.eslintrc.js +5 -0
- package/LICENSE +22 -0
- package/README.md +121 -0
- package/dist/RestClient.d.ts +154 -0
- package/dist/RestClient.d.ts.map +1 -0
- package/dist/RestClient.js +361 -0
- package/dist/RestClient.js.map +1 -0
- package/dist/RestOptions.d.ts +143 -0
- package/dist/RestOptions.d.ts.map +1 -0
- package/dist/RestOptions.js +63 -0
- package/dist/RestOptions.js.map +1 -0
- package/dist/RestRequest.d.ts +81 -0
- package/dist/RestRequest.d.ts.map +1 -0
- package/dist/RestRequest.js +367 -0
- package/dist/RestRequest.js.map +1 -0
- package/dist/RestResponse.d.ts +37 -0
- package/dist/RestResponse.d.ts.map +1 -0
- package/dist/RestResponse.js +56 -0
- package/dist/RestResponse.js.map +1 -0
- package/dist/RestStream.d.ts +29 -0
- package/dist/RestStream.d.ts.map +1 -0
- package/dist/RestStream.js +85 -0
- package/dist/RestStream.js.map +1 -0
- package/dist/errors/RestContentSizeOverLimitError.d.ts +4 -0
- package/dist/errors/RestContentSizeOverLimitError.d.ts.map +1 -0
- package/dist/errors/RestContentSizeOverLimitError.js +10 -0
- package/dist/errors/RestContentSizeOverLimitError.js.map +1 -0
- package/dist/errors/RestError.d.ts +4 -0
- package/dist/errors/RestError.d.ts.map +1 -0
- package/dist/errors/RestError.js +10 -0
- package/dist/errors/RestError.js.map +1 -0
- package/dist/errors/RestRateLimitError.d.ts +7 -0
- package/dist/errors/RestRateLimitError.d.ts.map +1 -0
- package/dist/errors/RestRateLimitError.js +14 -0
- package/dist/errors/RestRateLimitError.js.map +1 -0
- package/dist/errors/RestResponseError.d.ts +13 -0
- package/dist/errors/RestResponseError.d.ts.map +1 -0
- package/dist/errors/RestResponseError.js +32 -0
- package/dist/errors/RestResponseError.js.map +1 -0
- package/dist/errors/RestRetriableError.d.ts +7 -0
- package/dist/errors/RestRetriableError.d.ts.map +1 -0
- package/dist/errors/RestRetriableError.js +14 -0
- package/dist/errors/RestRetriableError.js.map +1 -0
- package/dist/errors/RestTimeoutError.d.ts +4 -0
- package/dist/errors/RestTimeoutError.d.ts.map +1 -0
- package/dist/errors/RestTimeoutError.js +10 -0
- package/dist/errors/RestTimeoutError.js.map +1 -0
- package/dist/errors/RestTokenInvalidError.d.ts +7 -0
- package/dist/errors/RestTokenInvalidError.d.ts.map +1 -0
- package/dist/errors/RestTokenInvalidError.js +14 -0
- package/dist/errors/RestTokenInvalidError.js.map +1 -0
- package/dist/helpers/depaginate.d.ts +10 -0
- package/dist/helpers/depaginate.d.ts.map +1 -0
- package/dist/helpers/depaginate.js +32 -0
- package/dist/helpers/depaginate.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/RestFetchReader.d.ts +72 -0
- package/dist/internal/RestFetchReader.d.ts.map +1 -0
- package/dist/internal/RestFetchReader.js +192 -0
- package/dist/internal/RestFetchReader.js.map +1 -0
- package/dist/internal/RestRangeUploader.d.ts +24 -0
- package/dist/internal/RestRangeUploader.d.ts.map +1 -0
- package/dist/internal/RestRangeUploader.js +54 -0
- package/dist/internal/RestRangeUploader.js.map +1 -0
- package/dist/internal/calcRetryDelay.d.ts +8 -0
- package/dist/internal/calcRetryDelay.d.ts.map +1 -0
- package/dist/internal/calcRetryDelay.js +44 -0
- package/dist/internal/calcRetryDelay.js.map +1 -0
- package/dist/internal/inspectPossibleJSON.d.ts +6 -0
- package/dist/internal/inspectPossibleJSON.d.ts.map +1 -0
- package/dist/internal/inspectPossibleJSON.js +53 -0
- package/dist/internal/inspectPossibleJSON.js.map +1 -0
- package/dist/internal/prependNewlineIfMultiline.d.ts +2 -0
- package/dist/internal/prependNewlineIfMultiline.d.ts.map +1 -0
- package/dist/internal/prependNewlineIfMultiline.js +7 -0
- package/dist/internal/prependNewlineIfMultiline.js.map +1 -0
- package/dist/internal/substituteParams.d.ts +7 -0
- package/dist/internal/substituteParams.d.ts.map +1 -0
- package/dist/internal/substituteParams.js +24 -0
- package/dist/internal/substituteParams.js.map +1 -0
- package/dist/internal/throwIfErrorResponse.d.ts +11 -0
- package/dist/internal/throwIfErrorResponse.d.ts.map +1 -0
- package/dist/internal/throwIfErrorResponse.js +60 -0
- package/dist/internal/throwIfErrorResponse.js.map +1 -0
- package/dist/internal/toFloatMs.d.ts +2 -0
- package/dist/internal/toFloatMs.d.ts.map +1 -0
- package/dist/internal/toFloatMs.js +7 -0
- package/dist/internal/toFloatMs.js.map +1 -0
- package/dist/middlewares/paceRequests.d.ts +9 -0
- package/dist/middlewares/paceRequests.d.ts.map +1 -0
- package/dist/middlewares/paceRequests.js +36 -0
- package/dist/middlewares/paceRequests.js.map +1 -0
- package/dist/pacers/Pacer.d.ts +21 -0
- package/dist/pacers/Pacer.d.ts.map +1 -0
- package/dist/pacers/Pacer.js +3 -0
- package/dist/pacers/Pacer.js.map +1 -0
- package/dist/pacers/PacerComposite.d.ts +14 -0
- package/dist/pacers/PacerComposite.d.ts.map +1 -0
- package/dist/pacers/PacerComposite.js +32 -0
- package/dist/pacers/PacerComposite.js.map +1 -0
- package/dist/pacers/PacerQPS.d.ts +53 -0
- package/dist/pacers/PacerQPS.d.ts.map +1 -0
- package/dist/pacers/PacerQPS.js +105 -0
- package/dist/pacers/PacerQPS.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +123 -0
- package/docs/classes/PacerComposite.md +62 -0
- package/docs/classes/PacerQPS.md +75 -0
- package/docs/classes/RestClient.md +424 -0
- package/docs/classes/RestContentSizeOverLimitError.md +128 -0
- package/docs/classes/RestError.md +31 -0
- package/docs/classes/RestRateLimitError.md +139 -0
- package/docs/classes/RestRequest.md +257 -0
- package/docs/classes/RestResponse.md +110 -0
- package/docs/classes/RestResponseError.md +110 -0
- package/docs/classes/RestRetriableError.md +139 -0
- package/docs/classes/RestStream.md +92 -0
- package/docs/classes/RestTimeoutError.md +128 -0
- package/docs/classes/RestTokenInvalidError.md +138 -0
- package/docs/interfaces/Middleware.md +27 -0
- package/docs/interfaces/Pacer.md +40 -0
- package/docs/interfaces/PacerDelay.md +25 -0
- package/docs/interfaces/PacerQPSBackend.md +44 -0
- package/docs/interfaces/PacerQPSOptions.md +40 -0
- package/docs/interfaces/RestLogEvent.md +95 -0
- package/docs/interfaces/RestOptions.md +351 -0
- package/docs/interfaces/TokenGetter.md +34 -0
- package/docs/modules.md +87 -0
- package/jest.config.js +8 -0
- package/package.json +42 -0
- package/tsconfig.json +39 -0
- package/typedoc.json +17 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestLogEvent
|
|
2
|
+
|
|
3
|
+
# Interface: RestLogEvent
|
|
4
|
+
|
|
5
|
+
An event which is passed to an external logger (see RestOptions).
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
|
|
9
|
+
### attempt
|
|
10
|
+
|
|
11
|
+
• **attempt**: `number`
|
|
12
|
+
|
|
13
|
+
#### Defined in
|
|
14
|
+
|
|
15
|
+
[src/RestOptions.ts:12](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L12)
|
|
16
|
+
|
|
17
|
+
___
|
|
18
|
+
|
|
19
|
+
### req
|
|
20
|
+
|
|
21
|
+
• **req**: [`RestRequest`](../classes/RestRequest.md)<`any`\>
|
|
22
|
+
|
|
23
|
+
#### Defined in
|
|
24
|
+
|
|
25
|
+
[src/RestOptions.ts:13](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L13)
|
|
26
|
+
|
|
27
|
+
___
|
|
28
|
+
|
|
29
|
+
### res
|
|
30
|
+
|
|
31
|
+
• **res**: ``null`` \| [`RestResponse`](../classes/RestResponse.md) \| ``"backoff_delay"``
|
|
32
|
+
|
|
33
|
+
#### Defined in
|
|
34
|
+
|
|
35
|
+
[src/RestOptions.ts:14](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L14)
|
|
36
|
+
|
|
37
|
+
___
|
|
38
|
+
|
|
39
|
+
### exception
|
|
40
|
+
|
|
41
|
+
• **exception**: `any`
|
|
42
|
+
|
|
43
|
+
#### Defined in
|
|
44
|
+
|
|
45
|
+
[src/RestOptions.ts:15](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L15)
|
|
46
|
+
|
|
47
|
+
___
|
|
48
|
+
|
|
49
|
+
### timestamp
|
|
50
|
+
|
|
51
|
+
• **timestamp**: `number`
|
|
52
|
+
|
|
53
|
+
#### Defined in
|
|
54
|
+
|
|
55
|
+
[src/RestOptions.ts:16](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L16)
|
|
56
|
+
|
|
57
|
+
___
|
|
58
|
+
|
|
59
|
+
### elapsed
|
|
60
|
+
|
|
61
|
+
• **elapsed**: `number`
|
|
62
|
+
|
|
63
|
+
#### Defined in
|
|
64
|
+
|
|
65
|
+
[src/RestOptions.ts:17](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L17)
|
|
66
|
+
|
|
67
|
+
___
|
|
68
|
+
|
|
69
|
+
### isFinalAttempt
|
|
70
|
+
|
|
71
|
+
• **isFinalAttempt**: `boolean`
|
|
72
|
+
|
|
73
|
+
#### Defined in
|
|
74
|
+
|
|
75
|
+
[src/RestOptions.ts:18](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L18)
|
|
76
|
+
|
|
77
|
+
___
|
|
78
|
+
|
|
79
|
+
### privateDataInResponse
|
|
80
|
+
|
|
81
|
+
• **privateDataInResponse**: `boolean`
|
|
82
|
+
|
|
83
|
+
#### Defined in
|
|
84
|
+
|
|
85
|
+
[src/RestOptions.ts:19](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L19)
|
|
86
|
+
|
|
87
|
+
___
|
|
88
|
+
|
|
89
|
+
### comment
|
|
90
|
+
|
|
91
|
+
• **comment**: `string`
|
|
92
|
+
|
|
93
|
+
#### Defined in
|
|
94
|
+
|
|
95
|
+
[src/RestOptions.ts:20](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L20)
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestOptions
|
|
2
|
+
|
|
3
|
+
# Interface: RestOptions
|
|
4
|
+
|
|
5
|
+
Options passed to RestClient. More options can be added by cloning an
|
|
6
|
+
instance of RestClient, withOption() method.
|
|
7
|
+
|
|
8
|
+
## Properties
|
|
9
|
+
|
|
10
|
+
### retries
|
|
11
|
+
|
|
12
|
+
• **retries**: `number`
|
|
13
|
+
|
|
14
|
+
Max number of retries. Default is 0, because some requests are from the
|
|
15
|
+
web app, and we don't want to retry them.
|
|
16
|
+
|
|
17
|
+
#### Defined in
|
|
18
|
+
|
|
19
|
+
[src/RestOptions.ts:69](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L69)
|
|
20
|
+
|
|
21
|
+
___
|
|
22
|
+
|
|
23
|
+
### retryDelayFirstMs
|
|
24
|
+
|
|
25
|
+
• **retryDelayFirstMs**: `number`
|
|
26
|
+
|
|
27
|
+
How much time to wait by default on the 1st retry attempt.
|
|
28
|
+
|
|
29
|
+
#### Defined in
|
|
30
|
+
|
|
31
|
+
[src/RestOptions.ts:71](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L71)
|
|
32
|
+
|
|
33
|
+
___
|
|
34
|
+
|
|
35
|
+
### retryDelayFactor
|
|
36
|
+
|
|
37
|
+
• **retryDelayFactor**: `number`
|
|
38
|
+
|
|
39
|
+
How much to increase the retry delay on each retry.
|
|
40
|
+
|
|
41
|
+
#### Defined in
|
|
42
|
+
|
|
43
|
+
[src/RestOptions.ts:73](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L73)
|
|
44
|
+
|
|
45
|
+
___
|
|
46
|
+
|
|
47
|
+
### retryDelayJitter
|
|
48
|
+
|
|
49
|
+
• **retryDelayJitter**: `number`
|
|
50
|
+
|
|
51
|
+
Use this fraction (random) of the current retry delay to jitter both ways
|
|
52
|
+
(e.g. 0.1 means 90%...110% of the delay to be actually applied).
|
|
53
|
+
|
|
54
|
+
#### Defined in
|
|
55
|
+
|
|
56
|
+
[src/RestOptions.ts:76](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L76)
|
|
57
|
+
|
|
58
|
+
___
|
|
59
|
+
|
|
60
|
+
### retryDelayMaxMs
|
|
61
|
+
|
|
62
|
+
• **retryDelayMaxMs**: `number`
|
|
63
|
+
|
|
64
|
+
Maximum delay between each retry.
|
|
65
|
+
|
|
66
|
+
#### Defined in
|
|
67
|
+
|
|
68
|
+
[src/RestOptions.ts:78](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L78)
|
|
69
|
+
|
|
70
|
+
___
|
|
71
|
+
|
|
72
|
+
### heartbeater
|
|
73
|
+
|
|
74
|
+
• **heartbeater**: `Object`
|
|
75
|
+
|
|
76
|
+
A logic which runs on different IO stages (delay and heartbeats).
|
|
77
|
+
|
|
78
|
+
#### Type declaration
|
|
79
|
+
|
|
80
|
+
| Name | Type |
|
|
81
|
+
| :------ | :------ |
|
|
82
|
+
| `heartbeat` | () => `Promise`<`void`\> |
|
|
83
|
+
| `delay` | (`ms`: `number`) => `Promise`<`void`\> |
|
|
84
|
+
|
|
85
|
+
#### Defined in
|
|
86
|
+
|
|
87
|
+
[src/RestOptions.ts:80](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L80)
|
|
88
|
+
|
|
89
|
+
___
|
|
90
|
+
|
|
91
|
+
### throwIfResIsBigger
|
|
92
|
+
|
|
93
|
+
• **throwIfResIsBigger**: `undefined` \| `number`
|
|
94
|
+
|
|
95
|
+
Allows to limit huge requests and throw instead.
|
|
96
|
+
|
|
97
|
+
#### Defined in
|
|
98
|
+
|
|
99
|
+
[src/RestOptions.ts:91](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L91)
|
|
100
|
+
|
|
101
|
+
___
|
|
102
|
+
|
|
103
|
+
### privateDataInResponse
|
|
104
|
+
|
|
105
|
+
• **privateDataInResponse**: `boolean`
|
|
106
|
+
|
|
107
|
+
Passed to the logger which may decide, should it log details of the
|
|
108
|
+
response or not.
|
|
109
|
+
|
|
110
|
+
#### Defined in
|
|
111
|
+
|
|
112
|
+
[src/RestOptions.ts:94](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L94)
|
|
113
|
+
|
|
114
|
+
___
|
|
115
|
+
|
|
116
|
+
### allowInternalIPs
|
|
117
|
+
|
|
118
|
+
• **allowInternalIPs**: `boolean`
|
|
119
|
+
|
|
120
|
+
If true, non-public IP addresses are allowed too; otherwise, only unicast
|
|
121
|
+
addresses are allowed.
|
|
122
|
+
|
|
123
|
+
#### Defined in
|
|
124
|
+
|
|
125
|
+
[src/RestOptions.ts:97](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L97)
|
|
126
|
+
|
|
127
|
+
___
|
|
128
|
+
|
|
129
|
+
### isDebug
|
|
130
|
+
|
|
131
|
+
• **isDebug**: `boolean`
|
|
132
|
+
|
|
133
|
+
If true, logs request-response pairs to console.
|
|
134
|
+
|
|
135
|
+
#### Defined in
|
|
136
|
+
|
|
137
|
+
[src/RestOptions.ts:99](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L99)
|
|
138
|
+
|
|
139
|
+
___
|
|
140
|
+
|
|
141
|
+
### keepAlive
|
|
142
|
+
|
|
143
|
+
• **keepAlive**: `Object`
|
|
144
|
+
|
|
145
|
+
Sets Keep-Alive parameters (persistent connections).
|
|
146
|
+
|
|
147
|
+
#### Type declaration
|
|
148
|
+
|
|
149
|
+
| Name | Type | Description |
|
|
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. |
|
|
153
|
+
| `maxSockets?` | `number` | How many sockets at maximum will be kept open. |
|
|
154
|
+
|
|
155
|
+
#### Defined in
|
|
156
|
+
|
|
157
|
+
[src/RestOptions.ts:103](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L103)
|
|
158
|
+
|
|
159
|
+
___
|
|
160
|
+
|
|
161
|
+
### family
|
|
162
|
+
|
|
163
|
+
• **family**: ``0`` \| ``4`` \| ``6``
|
|
164
|
+
|
|
165
|
+
When resolving DNS, use IPv4, IPv6 or both (see dns.lookup() docs).
|
|
166
|
+
|
|
167
|
+
#### Defined in
|
|
168
|
+
|
|
169
|
+
[src/RestOptions.ts:113](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L113)
|
|
170
|
+
|
|
171
|
+
___
|
|
172
|
+
|
|
173
|
+
### timeoutMs
|
|
174
|
+
|
|
175
|
+
• **timeoutMs**: `number`
|
|
176
|
+
|
|
177
|
+
Max timeout to wait for a response.
|
|
178
|
+
|
|
179
|
+
#### Defined in
|
|
180
|
+
|
|
181
|
+
[src/RestOptions.ts:115](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L115)
|
|
182
|
+
|
|
183
|
+
___
|
|
184
|
+
|
|
185
|
+
### logger
|
|
186
|
+
|
|
187
|
+
• **logger**: (`event`: [`RestLogEvent`](RestLogEvent.md)) => `void`
|
|
188
|
+
|
|
189
|
+
#### Type declaration
|
|
190
|
+
|
|
191
|
+
▸ (`event`): `void`
|
|
192
|
+
|
|
193
|
+
Logger to be used for each responses (including retried) plus for backoff
|
|
194
|
+
delay events logging.
|
|
195
|
+
|
|
196
|
+
##### Parameters
|
|
197
|
+
|
|
198
|
+
| Name | Type |
|
|
199
|
+
| :------ | :------ |
|
|
200
|
+
| `event` | [`RestLogEvent`](RestLogEvent.md) |
|
|
201
|
+
|
|
202
|
+
##### Returns
|
|
203
|
+
|
|
204
|
+
`void`
|
|
205
|
+
|
|
206
|
+
#### Defined in
|
|
207
|
+
|
|
208
|
+
[src/RestOptions.ts:118](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L118)
|
|
209
|
+
|
|
210
|
+
___
|
|
211
|
+
|
|
212
|
+
### middlewares
|
|
213
|
+
|
|
214
|
+
• **middlewares**: [`Middleware`](Middleware.md)[]
|
|
215
|
+
|
|
216
|
+
Middlewares to wrap requests. May alter both request and response.
|
|
217
|
+
|
|
218
|
+
#### Defined in
|
|
219
|
+
|
|
220
|
+
[src/RestOptions.ts:120](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L120)
|
|
221
|
+
|
|
222
|
+
___
|
|
223
|
+
|
|
224
|
+
### isSuccessResponse
|
|
225
|
+
|
|
226
|
+
• **isSuccessResponse**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
|
|
227
|
+
|
|
228
|
+
#### Type declaration
|
|
229
|
+
|
|
230
|
+
▸ (`res`): ``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
|
|
231
|
+
|
|
232
|
+
If set, makes decision whether the response is successful or not. The
|
|
233
|
+
response will either be returned to the client, or an error will be thrown.
|
|
234
|
+
This allows to treat some non-successful HTTP statuses as success if the
|
|
235
|
+
remote API is that weird. Return values:
|
|
236
|
+
* "SUCCESS" - the request will be considered successful, no further checks
|
|
237
|
+
will be performed;
|
|
238
|
+
* "BEST_EFFORT" - inconclusive, the request may be either successful or
|
|
239
|
+
unsuccessful, additional tests (e.g. will check HTTP status code) will be
|
|
240
|
+
performed;
|
|
241
|
+
* "THROW" - the request resulted in error. Additional tests will be
|
|
242
|
+
performed to determine is the error is retriable, is OAuth token good,
|
|
243
|
+
and etc.
|
|
244
|
+
|
|
245
|
+
##### Parameters
|
|
246
|
+
|
|
247
|
+
| Name | Type |
|
|
248
|
+
| :------ | :------ |
|
|
249
|
+
| `res` | [`RestResponse`](../classes/RestResponse.md) |
|
|
250
|
+
|
|
251
|
+
##### Returns
|
|
252
|
+
|
|
253
|
+
``"SUCCESS"`` \| ``"THROW"`` \| ``"BEST_EFFORT"``
|
|
254
|
+
|
|
255
|
+
#### Defined in
|
|
256
|
+
|
|
257
|
+
[src/RestOptions.ts:134](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L134)
|
|
258
|
+
|
|
259
|
+
___
|
|
260
|
+
|
|
261
|
+
### isRateLimitError
|
|
262
|
+
|
|
263
|
+
• **isRateLimitError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
|
|
264
|
+
|
|
265
|
+
#### Type declaration
|
|
266
|
+
|
|
267
|
+
▸ (`res`): `number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
|
|
268
|
+
|
|
269
|
+
Decides whether the response is a rate-limit error or not. Returning
|
|
270
|
+
non-zero value is treated as retry delay (if retries are set up). In case
|
|
271
|
+
the returned value is "SOMETHING_ELSE", the response ought to be either
|
|
272
|
+
success or some other error. Returning "BEST_EFFORT" turns on built-in
|
|
273
|
+
heuristic (e.g. relying on HTTP status code and Retry-After header). In
|
|
274
|
+
case we've made a decision that it's a rate limited error, the request is
|
|
275
|
+
always retried; this covers a very common case when we have both
|
|
276
|
+
isRateLimitError and isRetriableError handlers set up, and they return
|
|
277
|
+
contradictory information; then isRateLimitError wins.
|
|
278
|
+
|
|
279
|
+
##### Parameters
|
|
280
|
+
|
|
281
|
+
| Name | Type |
|
|
282
|
+
| :------ | :------ |
|
|
283
|
+
| `res` | [`RestResponse`](../classes/RestResponse.md) |
|
|
284
|
+
|
|
285
|
+
##### Returns
|
|
286
|
+
|
|
287
|
+
`number` \| ``"BEST_EFFORT"`` \| ``"SOMETHING_ELSE"`` \| ``"RATE_LIMIT"``
|
|
288
|
+
|
|
289
|
+
#### Defined in
|
|
290
|
+
|
|
291
|
+
[src/RestOptions.ts:144](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L144)
|
|
292
|
+
|
|
293
|
+
___
|
|
294
|
+
|
|
295
|
+
### isTokenInvalidError
|
|
296
|
+
|
|
297
|
+
• **isTokenInvalidError**: (`res`: [`RestResponse`](../classes/RestResponse.md)) => `boolean`
|
|
298
|
+
|
|
299
|
+
#### Type declaration
|
|
300
|
+
|
|
301
|
+
▸ (`res`): `boolean`
|
|
302
|
+
|
|
303
|
+
Decides whether the response is a token-invalid error or not. In case it's
|
|
304
|
+
not, the response ought to be either success or some other error.
|
|
305
|
+
|
|
306
|
+
##### Parameters
|
|
307
|
+
|
|
308
|
+
| Name | Type |
|
|
309
|
+
| :------ | :------ |
|
|
310
|
+
| `res` | [`RestResponse`](../classes/RestResponse.md) |
|
|
311
|
+
|
|
312
|
+
##### Returns
|
|
313
|
+
|
|
314
|
+
`boolean`
|
|
315
|
+
|
|
316
|
+
#### Defined in
|
|
317
|
+
|
|
318
|
+
[src/RestOptions.ts:149](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L149)
|
|
319
|
+
|
|
320
|
+
___
|
|
321
|
+
|
|
322
|
+
### isRetriableError
|
|
323
|
+
|
|
324
|
+
• **isRetriableError**: (`res`: [`RestResponse`](../classes/RestResponse.md), `_error`: `any`) => `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
|
|
325
|
+
|
|
326
|
+
#### Type declaration
|
|
327
|
+
|
|
328
|
+
▸ (`res`, `_error`): `number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
|
|
329
|
+
|
|
330
|
+
Called only if we haven't decided earlier that it's a rate limit error.
|
|
331
|
+
Decides whether the response is a retriable error or not. In case the
|
|
332
|
+
returned value is "NEVER_RETRY", the response ought to be either success or
|
|
333
|
+
some other error, but it's guaranteed that the request won't be retried.
|
|
334
|
+
Returning "BEST_EFFORT" turns on built-in heuristics (e.g. never retry "not
|
|
335
|
+
found" errors). Returning a number is treated as "RETRY", and the next
|
|
336
|
+
retry will happen in not less than this number of milliseconds.
|
|
337
|
+
|
|
338
|
+
##### Parameters
|
|
339
|
+
|
|
340
|
+
| Name | Type |
|
|
341
|
+
| :------ | :------ |
|
|
342
|
+
| `res` | [`RestResponse`](../classes/RestResponse.md) |
|
|
343
|
+
| `_error` | `any` |
|
|
344
|
+
|
|
345
|
+
##### Returns
|
|
346
|
+
|
|
347
|
+
`number` \| ``"BEST_EFFORT"`` \| ``"NEVER_RETRY"`` \| ``"RETRY"``
|
|
348
|
+
|
|
349
|
+
#### Defined in
|
|
350
|
+
|
|
351
|
+
[src/RestOptions.ts:157](https://github.com/clickup/rest-client/blob/master/src/RestOptions.ts#L157)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / TokenGetter
|
|
2
|
+
|
|
3
|
+
# Interface: TokenGetter<TData\>
|
|
4
|
+
|
|
5
|
+
A callback which returns access token, possibly after refreshing it, and also
|
|
6
|
+
possibly before a retry on "invalid token" condition. I.e. it can be called
|
|
7
|
+
once or twice (the 2nd time after the previous request error, and that error
|
|
8
|
+
will be passed as a parameter).
|
|
9
|
+
|
|
10
|
+
## Type parameters
|
|
11
|
+
|
|
12
|
+
| Name | Type |
|
|
13
|
+
| :------ | :------ |
|
|
14
|
+
| `TData` | `string` |
|
|
15
|
+
|
|
16
|
+
## Callable
|
|
17
|
+
|
|
18
|
+
### TokenGetter
|
|
19
|
+
|
|
20
|
+
▸ **TokenGetter**(`prevError`): `Promise`<`TData`\>
|
|
21
|
+
|
|
22
|
+
#### Parameters
|
|
23
|
+
|
|
24
|
+
| Name | Type |
|
|
25
|
+
| :------ | :------ |
|
|
26
|
+
| `prevError` | ``null`` \| `Error` |
|
|
27
|
+
|
|
28
|
+
#### Returns
|
|
29
|
+
|
|
30
|
+
`Promise`<`TData`\>
|
|
31
|
+
|
|
32
|
+
#### Defined in
|
|
33
|
+
|
|
34
|
+
[src/RestClient.ts:21](https://github.com/clickup/rest-client/blob/master/src/RestClient.ts#L21)
|
package/docs/modules.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[@clickup/rest-client](README.md) / Exports
|
|
2
|
+
|
|
3
|
+
# @clickup/rest-client
|
|
4
|
+
|
|
5
|
+
## Classes
|
|
6
|
+
|
|
7
|
+
- [RestClient](classes/RestClient.md)
|
|
8
|
+
- [RestRequest](classes/RestRequest.md)
|
|
9
|
+
- [RestResponse](classes/RestResponse.md)
|
|
10
|
+
- [RestStream](classes/RestStream.md)
|
|
11
|
+
- [RestContentSizeOverLimitError](classes/RestContentSizeOverLimitError.md)
|
|
12
|
+
- [RestError](classes/RestError.md)
|
|
13
|
+
- [RestRateLimitError](classes/RestRateLimitError.md)
|
|
14
|
+
- [RestResponseError](classes/RestResponseError.md)
|
|
15
|
+
- [RestRetriableError](classes/RestRetriableError.md)
|
|
16
|
+
- [RestTimeoutError](classes/RestTimeoutError.md)
|
|
17
|
+
- [RestTokenInvalidError](classes/RestTokenInvalidError.md)
|
|
18
|
+
- [PacerComposite](classes/PacerComposite.md)
|
|
19
|
+
- [PacerQPS](classes/PacerQPS.md)
|
|
20
|
+
|
|
21
|
+
## Interfaces
|
|
22
|
+
|
|
23
|
+
- [TokenGetter](interfaces/TokenGetter.md)
|
|
24
|
+
- [RestLogEvent](interfaces/RestLogEvent.md)
|
|
25
|
+
- [Middleware](interfaces/Middleware.md)
|
|
26
|
+
- [RestOptions](interfaces/RestOptions.md)
|
|
27
|
+
- [PacerDelay](interfaces/PacerDelay.md)
|
|
28
|
+
- [Pacer](interfaces/Pacer.md)
|
|
29
|
+
- [PacerQPSBackend](interfaces/PacerQPSBackend.md)
|
|
30
|
+
- [PacerQPSOptions](interfaces/PacerQPSOptions.md)
|
|
31
|
+
|
|
32
|
+
## Functions
|
|
33
|
+
|
|
34
|
+
### depaginate
|
|
35
|
+
|
|
36
|
+
▸ **depaginate**<`TItem`, `TCursor`\>(`readFunc`): `AsyncGenerator`<`TItem`, `void`, `undefined`\>
|
|
37
|
+
|
|
38
|
+
Keeps calling a function with an updating cursor, and depaginates all the
|
|
39
|
+
results until the cursor returned is null or undefined.
|
|
40
|
+
|
|
41
|
+
On each call, the inner function needs to return an array with two elements:
|
|
42
|
+
1. Array or results, which could be empty, but not null or undefined.
|
|
43
|
+
2. A new cursor.
|
|
44
|
+
|
|
45
|
+
#### Type parameters
|
|
46
|
+
|
|
47
|
+
| Name | Type |
|
|
48
|
+
| :------ | :------ |
|
|
49
|
+
| `TItem` | `TItem` |
|
|
50
|
+
| `TCursor` | `string` |
|
|
51
|
+
|
|
52
|
+
#### Parameters
|
|
53
|
+
|
|
54
|
+
| Name | Type |
|
|
55
|
+
| :------ | :------ |
|
|
56
|
+
| `readFunc` | (`cursor`: `undefined` \| `TCursor`) => `Promise`<[`TItem`[], `undefined` \| ``null`` \| `TCursor`]\> |
|
|
57
|
+
|
|
58
|
+
#### Returns
|
|
59
|
+
|
|
60
|
+
`AsyncGenerator`<`TItem`, `void`, `undefined`\>
|
|
61
|
+
|
|
62
|
+
#### Defined in
|
|
63
|
+
|
|
64
|
+
[src/helpers/depaginate.ts:9](https://github.com/clickup/rest-client/blob/master/src/helpers/depaginate.ts#L9)
|
|
65
|
+
|
|
66
|
+
___
|
|
67
|
+
|
|
68
|
+
### paceRequests
|
|
69
|
+
|
|
70
|
+
▸ **paceRequests**(`pacer`): [`Middleware`](interfaces/Middleware.md)
|
|
71
|
+
|
|
72
|
+
Rest Client middleware that adds some delay between requests using one of
|
|
73
|
+
Pacer implementations.
|
|
74
|
+
|
|
75
|
+
#### Parameters
|
|
76
|
+
|
|
77
|
+
| Name | Type |
|
|
78
|
+
| :------ | :------ |
|
|
79
|
+
| `pacer` | ``null`` \| [`Pacer`](interfaces/Pacer.md) \| (`req`: [`RestRequest`](classes/RestRequest.md)<`any`\>) => `Promise`<``null`` \| [`Pacer`](interfaces/Pacer.md)\> |
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
[`Middleware`](interfaces/Middleware.md)
|
|
84
|
+
|
|
85
|
+
#### Defined in
|
|
86
|
+
|
|
87
|
+
[src/middlewares/paceRequests.ts:11](https://github.com/clickup/rest-client/blob/master/src/middlewares/paceRequests.ts#L11)
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clickup/rest-client",
|
|
3
|
+
"description": "A syntax sugar tool around Node fetch() API, tailored to work with TypeScript and response validators",
|
|
4
|
+
"version": "2.10.292",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"lint": "eslint . --ext .ts --cache --cache-location dist/.eslintcache",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"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')",
|
|
14
|
+
"clean": "rm -rf dist node_modules yarn.lock package-lock.json",
|
|
15
|
+
"copy-package-to-public-dir": "copy-package-to-public-dir.sh",
|
|
16
|
+
"deploy": "npm run build && npm test && npm publish --access=public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"abort-controller": "^3.0.0",
|
|
20
|
+
"delay": "^4.4.1",
|
|
21
|
+
"fast-typescript-memoize": "^1.0.2",
|
|
22
|
+
"ipaddr.js": "^1.9.1",
|
|
23
|
+
"lodash": "^4.17.21",
|
|
24
|
+
"node-fetch": "^2.6.11",
|
|
25
|
+
"oauth-1.0a": "^2.2.6"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/jest": "^29.5.5",
|
|
29
|
+
"@types/lodash": "^4.14.175",
|
|
30
|
+
"@types/node-fetch": "^2.6.4",
|
|
31
|
+
"superstruct": "^0.15.3",
|
|
32
|
+
"ts-jest": "^29.1.1",
|
|
33
|
+
"typedoc": "^0.25.2",
|
|
34
|
+
"typedoc-plugin-markdown": "^3.16.0",
|
|
35
|
+
"typedoc-plugin-merge-modules": "^5.1.0",
|
|
36
|
+
"typescript": "^5.2.2"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git://github.com/clickup/rest-client"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**/*"
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"disableReferencedProjectLoad": true,
|
|
10
|
+
"disableSourceOfProjectReferenceRedirect": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"experimentalDecorators": true,
|
|
13
|
+
"incremental": true,
|
|
14
|
+
"lib": [
|
|
15
|
+
"es2019"
|
|
16
|
+
],
|
|
17
|
+
"module": "commonjs",
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"noEmitOnError": true,
|
|
20
|
+
"noErrorTruncation": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
"noImplicitReturns": true,
|
|
23
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
24
|
+
"outDir": "dist",
|
|
25
|
+
"pretty": true,
|
|
26
|
+
"removeComments": false,
|
|
27
|
+
"resolveJsonModule": true,
|
|
28
|
+
"rootDir": "src",
|
|
29
|
+
"skipLibCheck": true,
|
|
30
|
+
"sourceMap": true,
|
|
31
|
+
"strict": true,
|
|
32
|
+
"target": "es2019",
|
|
33
|
+
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
|
|
34
|
+
"types": [
|
|
35
|
+
"node",
|
|
36
|
+
"jest"
|
|
37
|
+
],
|
|
38
|
+
}
|
|
39
|
+
}
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entryPoints": ["src"],
|
|
3
|
+
"exclude": ["src/internal/**", "src/__tests__/**", "**/node-fetch/**", "**/node_modules/**"],
|
|
4
|
+
"entryPointStrategy": "expand",
|
|
5
|
+
"mergeModulesMergeMode": "project",
|
|
6
|
+
"sort": ["source-order"],
|
|
7
|
+
"out": "docs",
|
|
8
|
+
"logLevel": "Warn",
|
|
9
|
+
"hideGenerator": true,
|
|
10
|
+
"excludeInternal": true,
|
|
11
|
+
"excludePrivate": true,
|
|
12
|
+
"categorizeByGroup": true,
|
|
13
|
+
"hideInPageTOC": true,
|
|
14
|
+
"gitRevision": "master",
|
|
15
|
+
"sourceLinkTemplate": "https://github.com/clickup/rest-client/blob/master/{path}#L{line}",
|
|
16
|
+
"basePath": "."
|
|
17
|
+
}
|