@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,139 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestRateLimitError
|
|
2
|
+
|
|
3
|
+
# Class: RestRateLimitError
|
|
4
|
+
|
|
5
|
+
## Hierarchy
|
|
6
|
+
|
|
7
|
+
- [`RestResponseError`](RestResponseError.md)
|
|
8
|
+
|
|
9
|
+
↳ **`RestRateLimitError`**
|
|
10
|
+
|
|
11
|
+
## Constructors
|
|
12
|
+
|
|
13
|
+
### constructor
|
|
14
|
+
|
|
15
|
+
• **new RestRateLimitError**(`message`, `delayMs`, `res`)
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
| Name | Type |
|
|
20
|
+
| :------ | :------ |
|
|
21
|
+
| `message` | `string` |
|
|
22
|
+
| `delayMs` | `number` |
|
|
23
|
+
| `res` | [`RestResponse`](RestResponse.md) |
|
|
24
|
+
|
|
25
|
+
#### Overrides
|
|
26
|
+
|
|
27
|
+
[RestResponseError](RestResponseError.md).[constructor](RestResponseError.md#constructor)
|
|
28
|
+
|
|
29
|
+
#### Defined in
|
|
30
|
+
|
|
31
|
+
[src/errors/RestRateLimitError.ts:5](https://github.com/clickup/rest-client/blob/master/src/errors/RestRateLimitError.ts#L5)
|
|
32
|
+
|
|
33
|
+
## Properties
|
|
34
|
+
|
|
35
|
+
### delayMs
|
|
36
|
+
|
|
37
|
+
• **delayMs**: `number`
|
|
38
|
+
|
|
39
|
+
#### Defined in
|
|
40
|
+
|
|
41
|
+
[src/errors/RestRateLimitError.ts:5](https://github.com/clickup/rest-client/blob/master/src/errors/RestRateLimitError.ts#L5)
|
|
42
|
+
|
|
43
|
+
___
|
|
44
|
+
|
|
45
|
+
### res
|
|
46
|
+
|
|
47
|
+
• `Readonly` **res**: [`RestResponse`](RestResponse.md)
|
|
48
|
+
|
|
49
|
+
#### Inherited from
|
|
50
|
+
|
|
51
|
+
[RestResponseError](RestResponseError.md).[res](RestResponseError.md#res)
|
|
52
|
+
|
|
53
|
+
#### Defined in
|
|
54
|
+
|
|
55
|
+
[src/errors/RestResponseError.ts:10](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L10)
|
|
56
|
+
|
|
57
|
+
___
|
|
58
|
+
|
|
59
|
+
### method
|
|
60
|
+
|
|
61
|
+
• `Readonly` **method**: `string`
|
|
62
|
+
|
|
63
|
+
#### Inherited from
|
|
64
|
+
|
|
65
|
+
[RestResponseError](RestResponseError.md).[method](RestResponseError.md#method)
|
|
66
|
+
|
|
67
|
+
#### Defined in
|
|
68
|
+
|
|
69
|
+
[src/errors/RestResponseError.ts:12](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L12)
|
|
70
|
+
|
|
71
|
+
___
|
|
72
|
+
|
|
73
|
+
### host
|
|
74
|
+
|
|
75
|
+
• `Readonly` **host**: `string`
|
|
76
|
+
|
|
77
|
+
#### Inherited from
|
|
78
|
+
|
|
79
|
+
[RestResponseError](RestResponseError.md).[host](RestResponseError.md#host)
|
|
80
|
+
|
|
81
|
+
#### Defined in
|
|
82
|
+
|
|
83
|
+
[src/errors/RestResponseError.ts:13](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L13)
|
|
84
|
+
|
|
85
|
+
___
|
|
86
|
+
|
|
87
|
+
### pathname
|
|
88
|
+
|
|
89
|
+
• `Readonly` **pathname**: `string`
|
|
90
|
+
|
|
91
|
+
#### Inherited from
|
|
92
|
+
|
|
93
|
+
[RestResponseError](RestResponseError.md).[pathname](RestResponseError.md#pathname)
|
|
94
|
+
|
|
95
|
+
#### Defined in
|
|
96
|
+
|
|
97
|
+
[src/errors/RestResponseError.ts:14](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L14)
|
|
98
|
+
|
|
99
|
+
___
|
|
100
|
+
|
|
101
|
+
### requestArgs
|
|
102
|
+
|
|
103
|
+
• `Readonly` **requestArgs**: `string`
|
|
104
|
+
|
|
105
|
+
#### Inherited from
|
|
106
|
+
|
|
107
|
+
[RestResponseError](RestResponseError.md).[requestArgs](RestResponseError.md#requestargs)
|
|
108
|
+
|
|
109
|
+
#### Defined in
|
|
110
|
+
|
|
111
|
+
[src/errors/RestResponseError.ts:15](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L15)
|
|
112
|
+
|
|
113
|
+
___
|
|
114
|
+
|
|
115
|
+
### requestBody
|
|
116
|
+
|
|
117
|
+
• `Readonly` **requestBody**: `string`
|
|
118
|
+
|
|
119
|
+
#### Inherited from
|
|
120
|
+
|
|
121
|
+
[RestResponseError](RestResponseError.md).[requestBody](RestResponseError.md#requestbody)
|
|
122
|
+
|
|
123
|
+
#### Defined in
|
|
124
|
+
|
|
125
|
+
[src/errors/RestResponseError.ts:16](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L16)
|
|
126
|
+
|
|
127
|
+
___
|
|
128
|
+
|
|
129
|
+
### responseHeaders
|
|
130
|
+
|
|
131
|
+
• `Readonly` **responseHeaders**: `string`
|
|
132
|
+
|
|
133
|
+
#### Inherited from
|
|
134
|
+
|
|
135
|
+
[RestResponseError](RestResponseError.md).[responseHeaders](RestResponseError.md#responseheaders)
|
|
136
|
+
|
|
137
|
+
#### Defined in
|
|
138
|
+
|
|
139
|
+
[src/errors/RestResponseError.ts:17](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L17)
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestRequest
|
|
2
|
+
|
|
3
|
+
# Class: RestRequest<TAssertShape\>
|
|
4
|
+
|
|
5
|
+
Type TAssertShape allows to limit json()'s assert callbacks to only those
|
|
6
|
+
which return an object compatible with TAssertShape.
|
|
7
|
+
|
|
8
|
+
## Type parameters
|
|
9
|
+
|
|
10
|
+
| Name | Type |
|
|
11
|
+
| :------ | :------ |
|
|
12
|
+
| `TAssertShape` | `any` |
|
|
13
|
+
|
|
14
|
+
## Constructors
|
|
15
|
+
|
|
16
|
+
### constructor
|
|
17
|
+
|
|
18
|
+
• **new RestRequest**<`TAssertShape`\>(`options`, `method`, `url`, `headers`, `body`, `shape?`)
|
|
19
|
+
|
|
20
|
+
#### Type parameters
|
|
21
|
+
|
|
22
|
+
| Name | Type |
|
|
23
|
+
| :------ | :------ |
|
|
24
|
+
| `TAssertShape` | `any` |
|
|
25
|
+
|
|
26
|
+
#### Parameters
|
|
27
|
+
|
|
28
|
+
| Name | Type |
|
|
29
|
+
| :------ | :------ |
|
|
30
|
+
| `options` | [`RestOptions`](../interfaces/RestOptions.md) |
|
|
31
|
+
| `method` | ``"GET"`` \| ``"POST"`` \| ``"PUT"`` \| ``"PATCH"`` \| ``"DELETE"`` |
|
|
32
|
+
| `url` | `string` |
|
|
33
|
+
| `headers` | `Headers` |
|
|
34
|
+
| `body` | `string` \| `Buffer` \| `ReadableStream` |
|
|
35
|
+
| `shape?` | `string` |
|
|
36
|
+
|
|
37
|
+
#### Defined in
|
|
38
|
+
|
|
39
|
+
[src/RestRequest.ts:30](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L30)
|
|
40
|
+
|
|
41
|
+
## Properties
|
|
42
|
+
|
|
43
|
+
### options
|
|
44
|
+
|
|
45
|
+
• `Readonly` **options**: [`RestOptions`](../interfaces/RestOptions.md)
|
|
46
|
+
|
|
47
|
+
#### Defined in
|
|
48
|
+
|
|
49
|
+
[src/RestRequest.ts:28](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L28)
|
|
50
|
+
|
|
51
|
+
___
|
|
52
|
+
|
|
53
|
+
### method
|
|
54
|
+
|
|
55
|
+
• `Readonly` **method**: ``"GET"`` \| ``"POST"`` \| ``"PUT"`` \| ``"PATCH"`` \| ``"DELETE"``
|
|
56
|
+
|
|
57
|
+
#### Defined in
|
|
58
|
+
|
|
59
|
+
[src/RestRequest.ts:32](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L32)
|
|
60
|
+
|
|
61
|
+
___
|
|
62
|
+
|
|
63
|
+
### url
|
|
64
|
+
|
|
65
|
+
• **url**: `string`
|
|
66
|
+
|
|
67
|
+
#### Defined in
|
|
68
|
+
|
|
69
|
+
[src/RestRequest.ts:33](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L33)
|
|
70
|
+
|
|
71
|
+
___
|
|
72
|
+
|
|
73
|
+
### headers
|
|
74
|
+
|
|
75
|
+
• `Readonly` **headers**: `Headers`
|
|
76
|
+
|
|
77
|
+
#### Defined in
|
|
78
|
+
|
|
79
|
+
[src/RestRequest.ts:34](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L34)
|
|
80
|
+
|
|
81
|
+
___
|
|
82
|
+
|
|
83
|
+
### body
|
|
84
|
+
|
|
85
|
+
• `Readonly` **body**: `string` \| `Buffer` \| `ReadableStream`
|
|
86
|
+
|
|
87
|
+
#### Defined in
|
|
88
|
+
|
|
89
|
+
[src/RestRequest.ts:35](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L35)
|
|
90
|
+
|
|
91
|
+
___
|
|
92
|
+
|
|
93
|
+
### shape
|
|
94
|
+
|
|
95
|
+
• `Optional` `Readonly` **shape**: `string`
|
|
96
|
+
|
|
97
|
+
#### Defined in
|
|
98
|
+
|
|
99
|
+
[src/RestRequest.ts:36](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L36)
|
|
100
|
+
|
|
101
|
+
## Methods
|
|
102
|
+
|
|
103
|
+
### setHeader
|
|
104
|
+
|
|
105
|
+
▸ **setHeader**(`name`, `value`): [`RestRequest`](RestRequest.md)<`TAssertShape`\>
|
|
106
|
+
|
|
107
|
+
Modifies the request by adding a custom HTTP header.
|
|
108
|
+
|
|
109
|
+
#### Parameters
|
|
110
|
+
|
|
111
|
+
| Name | Type |
|
|
112
|
+
| :------ | :------ |
|
|
113
|
+
| `name` | `string` |
|
|
114
|
+
| `value` | `string` |
|
|
115
|
+
|
|
116
|
+
#### Returns
|
|
117
|
+
|
|
118
|
+
[`RestRequest`](RestRequest.md)<`TAssertShape`\>
|
|
119
|
+
|
|
120
|
+
#### Defined in
|
|
121
|
+
|
|
122
|
+
[src/RestRequest.ts:44](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L44)
|
|
123
|
+
|
|
124
|
+
___
|
|
125
|
+
|
|
126
|
+
### setOptions
|
|
127
|
+
|
|
128
|
+
▸ **setOptions**(`options`): [`RestRequest`](RestRequest.md)<`TAssertShape`\>
|
|
129
|
+
|
|
130
|
+
Modifies the request by adding a custom request option.
|
|
131
|
+
|
|
132
|
+
#### Parameters
|
|
133
|
+
|
|
134
|
+
| Name | Type |
|
|
135
|
+
| :------ | :------ |
|
|
136
|
+
| `options` | `Partial`<[`RestOptions`](../interfaces/RestOptions.md)\> |
|
|
137
|
+
|
|
138
|
+
#### Returns
|
|
139
|
+
|
|
140
|
+
[`RestRequest`](RestRequest.md)<`TAssertShape`\>
|
|
141
|
+
|
|
142
|
+
#### Defined in
|
|
143
|
+
|
|
144
|
+
[src/RestRequest.ts:52](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L52)
|
|
145
|
+
|
|
146
|
+
___
|
|
147
|
+
|
|
148
|
+
### setDebug
|
|
149
|
+
|
|
150
|
+
▸ **setDebug**(`flag?`): [`RestRequest`](RestRequest.md)<`TAssertShape`\>
|
|
151
|
+
|
|
152
|
+
Forces RestClient to debug-output the request and response to console.
|
|
153
|
+
Never use in production.
|
|
154
|
+
|
|
155
|
+
#### Parameters
|
|
156
|
+
|
|
157
|
+
| Name | Type | Default value |
|
|
158
|
+
| :------ | :------ | :------ |
|
|
159
|
+
| `flag` | `boolean` | `true` |
|
|
160
|
+
|
|
161
|
+
#### Returns
|
|
162
|
+
|
|
163
|
+
[`RestRequest`](RestRequest.md)<`TAssertShape`\>
|
|
164
|
+
|
|
165
|
+
#### Defined in
|
|
166
|
+
|
|
167
|
+
[src/RestRequest.ts:64](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L64)
|
|
168
|
+
|
|
169
|
+
___
|
|
170
|
+
|
|
171
|
+
### json
|
|
172
|
+
|
|
173
|
+
▸ **json**<`TJson`\>(`assert`, `...checkers`): `Promise`<`TJson`\>
|
|
174
|
+
|
|
175
|
+
Sends the request and reads the response a JSON. In absolute most of the
|
|
176
|
+
cases, this method is used to reach API responses. The assert callback
|
|
177
|
+
(typically generated by typescript-is) is intentionally made mandatory to
|
|
178
|
+
not let people to do anti-patterns.
|
|
179
|
+
|
|
180
|
+
#### Type parameters
|
|
181
|
+
|
|
182
|
+
| Name |
|
|
183
|
+
| :------ |
|
|
184
|
+
| `TJson` |
|
|
185
|
+
|
|
186
|
+
#### Parameters
|
|
187
|
+
|
|
188
|
+
| Name | Type |
|
|
189
|
+
| :------ | :------ |
|
|
190
|
+
| `assert` | { `mask`: (`obj`: `any`) => `TJson` } \| { `$assert`: (`obj`: `any`) => `TJson` } \| (`obj`: `any`) => `TJson` |
|
|
191
|
+
| `...checkers` | (`json`: `TJson`, `res`: [`RestResponse`](RestResponse.md)) => ``false`` \| `Error`[] |
|
|
192
|
+
|
|
193
|
+
#### Returns
|
|
194
|
+
|
|
195
|
+
`Promise`<`TJson`\>
|
|
196
|
+
|
|
197
|
+
#### Defined in
|
|
198
|
+
|
|
199
|
+
[src/RestRequest.ts:75](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L75)
|
|
200
|
+
|
|
201
|
+
___
|
|
202
|
+
|
|
203
|
+
### text
|
|
204
|
+
|
|
205
|
+
▸ **text**(): `Promise`<`string`\>
|
|
206
|
+
|
|
207
|
+
Sends the request and returns plaintext response.
|
|
208
|
+
|
|
209
|
+
#### Returns
|
|
210
|
+
|
|
211
|
+
`Promise`<`string`\>
|
|
212
|
+
|
|
213
|
+
#### Defined in
|
|
214
|
+
|
|
215
|
+
[src/RestRequest.ts:107](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L107)
|
|
216
|
+
|
|
217
|
+
___
|
|
218
|
+
|
|
219
|
+
### response
|
|
220
|
+
|
|
221
|
+
▸ **response**(): `Promise`<[`RestResponse`](RestResponse.md)\>
|
|
222
|
+
|
|
223
|
+
Returns the entire RestResponse object with response status and headers
|
|
224
|
+
information in it. Try to minimize usage of this method, because it doesn't
|
|
225
|
+
make any assumptions on the response structure.
|
|
226
|
+
|
|
227
|
+
#### Returns
|
|
228
|
+
|
|
229
|
+
`Promise`<[`RestResponse`](RestResponse.md)\>
|
|
230
|
+
|
|
231
|
+
#### Defined in
|
|
232
|
+
|
|
233
|
+
[src/RestRequest.ts:118](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L118)
|
|
234
|
+
|
|
235
|
+
___
|
|
236
|
+
|
|
237
|
+
### stream
|
|
238
|
+
|
|
239
|
+
▸ **stream**(`preloadChars?`): `Promise`<[`RestStream`](RestStream.md)\>
|
|
240
|
+
|
|
241
|
+
Sends the requests and returns RestStream object. You MUST iterate over
|
|
242
|
+
this object entirely (or call its return() method), otherwise the
|
|
243
|
+
connection will remain dangling.
|
|
244
|
+
|
|
245
|
+
#### Parameters
|
|
246
|
+
|
|
247
|
+
| Name | Type |
|
|
248
|
+
| :------ | :------ |
|
|
249
|
+
| `preloadChars` | `number` |
|
|
250
|
+
|
|
251
|
+
#### Returns
|
|
252
|
+
|
|
253
|
+
`Promise`<[`RestStream`](RestStream.md)\>
|
|
254
|
+
|
|
255
|
+
#### Defined in
|
|
256
|
+
|
|
257
|
+
[src/RestRequest.ts:134](https://github.com/clickup/rest-client/blob/master/src/RestRequest.ts#L134)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestResponse
|
|
2
|
+
|
|
3
|
+
# Class: RestResponse
|
|
4
|
+
|
|
5
|
+
RestResponse is intentionally not aware of the data structure it carries, and
|
|
6
|
+
it doesn't do any assertions/validations which is the responsibility of
|
|
7
|
+
RestRequest helper methods.
|
|
8
|
+
|
|
9
|
+
We also use a concept of "body preloading". Sometimes, e.g. on non-successful
|
|
10
|
+
HTTP status codes, we also need to know the body content (at least its
|
|
11
|
+
beginning), do double check whether should we retry, throw through or through
|
|
12
|
+
a user-friendly error. To do this, we need to preload the beginning of the
|
|
13
|
+
body and make it a part of RestResponse abstraction.
|
|
14
|
+
|
|
15
|
+
## Constructors
|
|
16
|
+
|
|
17
|
+
### constructor
|
|
18
|
+
|
|
19
|
+
• **new RestResponse**(`req`, `status`, `headers`, `text`, `textIsPartial`)
|
|
20
|
+
|
|
21
|
+
#### Parameters
|
|
22
|
+
|
|
23
|
+
| Name | Type |
|
|
24
|
+
| :------ | :------ |
|
|
25
|
+
| `req` | [`RestRequest`](RestRequest.md)<`any`\> |
|
|
26
|
+
| `status` | `number` |
|
|
27
|
+
| `headers` | `Headers` |
|
|
28
|
+
| `text` | `string` |
|
|
29
|
+
| `textIsPartial` | `boolean` |
|
|
30
|
+
|
|
31
|
+
#### Defined in
|
|
32
|
+
|
|
33
|
+
[src/RestResponse.ts:17](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L17)
|
|
34
|
+
|
|
35
|
+
## Properties
|
|
36
|
+
|
|
37
|
+
### req
|
|
38
|
+
|
|
39
|
+
• `Readonly` **req**: [`RestRequest`](RestRequest.md)<`any`\>
|
|
40
|
+
|
|
41
|
+
#### Defined in
|
|
42
|
+
|
|
43
|
+
[src/RestResponse.ts:18](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L18)
|
|
44
|
+
|
|
45
|
+
___
|
|
46
|
+
|
|
47
|
+
### status
|
|
48
|
+
|
|
49
|
+
• `Readonly` **status**: `number`
|
|
50
|
+
|
|
51
|
+
#### Defined in
|
|
52
|
+
|
|
53
|
+
[src/RestResponse.ts:19](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L19)
|
|
54
|
+
|
|
55
|
+
___
|
|
56
|
+
|
|
57
|
+
### headers
|
|
58
|
+
|
|
59
|
+
• `Readonly` **headers**: `Headers`
|
|
60
|
+
|
|
61
|
+
#### Defined in
|
|
62
|
+
|
|
63
|
+
[src/RestResponse.ts:20](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L20)
|
|
64
|
+
|
|
65
|
+
___
|
|
66
|
+
|
|
67
|
+
### text
|
|
68
|
+
|
|
69
|
+
• `Readonly` **text**: `string`
|
|
70
|
+
|
|
71
|
+
#### Defined in
|
|
72
|
+
|
|
73
|
+
[src/RestResponse.ts:21](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L21)
|
|
74
|
+
|
|
75
|
+
___
|
|
76
|
+
|
|
77
|
+
### textIsPartial
|
|
78
|
+
|
|
79
|
+
• `Readonly` **textIsPartial**: `boolean`
|
|
80
|
+
|
|
81
|
+
#### Defined in
|
|
82
|
+
|
|
83
|
+
[src/RestResponse.ts:22](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L22)
|
|
84
|
+
|
|
85
|
+
## Accessors
|
|
86
|
+
|
|
87
|
+
### json
|
|
88
|
+
|
|
89
|
+
• `get` **json**(): `undefined` \| ``null`` \| `string` \| `number` \| `boolean` \| `object`
|
|
90
|
+
|
|
91
|
+
A safe way to treat the response as JSON.
|
|
92
|
+
- Never throws, i.e. we imply that the caller will verify the structure of
|
|
93
|
+
the response and do its own errors processing.
|
|
94
|
+
- It's a getter, so we can use typescript-is'es is<xyz>() type guard, e.g.:
|
|
95
|
+
`if (is<{ errors: any[] }>(res.json) && res.json.errors.length) { ... }`
|
|
96
|
+
|
|
97
|
+
Notice that there is NO `assert()` abstraction inside RestResponse class.
|
|
98
|
+
This is because RestClient sometimes substitutes the response with some
|
|
99
|
+
sub-field (e.g. see writeGraphQLX() method), and we still need to run the
|
|
100
|
+
assertion in such cases. By not having strong typing here, we intentionally
|
|
101
|
+
make the use of this method harder, so people will prefer using
|
|
102
|
+
RestRequest.json() instead.
|
|
103
|
+
|
|
104
|
+
#### Returns
|
|
105
|
+
|
|
106
|
+
`undefined` \| ``null`` \| `string` \| `number` \| `boolean` \| `object`
|
|
107
|
+
|
|
108
|
+
#### Defined in
|
|
109
|
+
|
|
110
|
+
[src/RestResponse.ts:40](https://github.com/clickup/rest-client/blob/master/src/RestResponse.ts#L40)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
[@clickup/rest-client](../README.md) / [Exports](../modules.md) / RestResponseError
|
|
2
|
+
|
|
3
|
+
# Class: RestResponseError
|
|
4
|
+
|
|
5
|
+
## Hierarchy
|
|
6
|
+
|
|
7
|
+
- [`RestError`](RestError.md)
|
|
8
|
+
|
|
9
|
+
↳ **`RestResponseError`**
|
|
10
|
+
|
|
11
|
+
↳↳ [`RestContentSizeOverLimitError`](RestContentSizeOverLimitError.md)
|
|
12
|
+
|
|
13
|
+
↳↳ [`RestRateLimitError`](RestRateLimitError.md)
|
|
14
|
+
|
|
15
|
+
↳↳ [`RestRetriableError`](RestRetriableError.md)
|
|
16
|
+
|
|
17
|
+
↳↳ [`RestTimeoutError`](RestTimeoutError.md)
|
|
18
|
+
|
|
19
|
+
↳↳ [`RestTokenInvalidError`](RestTokenInvalidError.md)
|
|
20
|
+
|
|
21
|
+
## Constructors
|
|
22
|
+
|
|
23
|
+
### constructor
|
|
24
|
+
|
|
25
|
+
• **new RestResponseError**(`message`, `res`)
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
| Name | Type |
|
|
30
|
+
| :------ | :------ |
|
|
31
|
+
| `message` | `string` |
|
|
32
|
+
| `res` | [`RestResponse`](RestResponse.md) |
|
|
33
|
+
|
|
34
|
+
#### Overrides
|
|
35
|
+
|
|
36
|
+
[RestError](RestError.md).[constructor](RestError.md#constructor)
|
|
37
|
+
|
|
38
|
+
#### Defined in
|
|
39
|
+
|
|
40
|
+
[src/errors/RestResponseError.ts:19](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L19)
|
|
41
|
+
|
|
42
|
+
## Properties
|
|
43
|
+
|
|
44
|
+
### res
|
|
45
|
+
|
|
46
|
+
• `Readonly` **res**: [`RestResponse`](RestResponse.md)
|
|
47
|
+
|
|
48
|
+
#### Defined in
|
|
49
|
+
|
|
50
|
+
[src/errors/RestResponseError.ts:10](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L10)
|
|
51
|
+
|
|
52
|
+
___
|
|
53
|
+
|
|
54
|
+
### method
|
|
55
|
+
|
|
56
|
+
• `Readonly` **method**: `string`
|
|
57
|
+
|
|
58
|
+
#### Defined in
|
|
59
|
+
|
|
60
|
+
[src/errors/RestResponseError.ts:12](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L12)
|
|
61
|
+
|
|
62
|
+
___
|
|
63
|
+
|
|
64
|
+
### host
|
|
65
|
+
|
|
66
|
+
• `Readonly` **host**: `string`
|
|
67
|
+
|
|
68
|
+
#### Defined in
|
|
69
|
+
|
|
70
|
+
[src/errors/RestResponseError.ts:13](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L13)
|
|
71
|
+
|
|
72
|
+
___
|
|
73
|
+
|
|
74
|
+
### pathname
|
|
75
|
+
|
|
76
|
+
• `Readonly` **pathname**: `string`
|
|
77
|
+
|
|
78
|
+
#### Defined in
|
|
79
|
+
|
|
80
|
+
[src/errors/RestResponseError.ts:14](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L14)
|
|
81
|
+
|
|
82
|
+
___
|
|
83
|
+
|
|
84
|
+
### requestArgs
|
|
85
|
+
|
|
86
|
+
• `Readonly` **requestArgs**: `string`
|
|
87
|
+
|
|
88
|
+
#### Defined in
|
|
89
|
+
|
|
90
|
+
[src/errors/RestResponseError.ts:15](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L15)
|
|
91
|
+
|
|
92
|
+
___
|
|
93
|
+
|
|
94
|
+
### requestBody
|
|
95
|
+
|
|
96
|
+
• `Readonly` **requestBody**: `string`
|
|
97
|
+
|
|
98
|
+
#### Defined in
|
|
99
|
+
|
|
100
|
+
[src/errors/RestResponseError.ts:16](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L16)
|
|
101
|
+
|
|
102
|
+
___
|
|
103
|
+
|
|
104
|
+
### responseHeaders
|
|
105
|
+
|
|
106
|
+
• `Readonly` **responseHeaders**: `string`
|
|
107
|
+
|
|
108
|
+
#### Defined in
|
|
109
|
+
|
|
110
|
+
[src/errors/RestResponseError.ts:17](https://github.com/clickup/rest-client/blob/master/src/errors/RestResponseError.ts#L17)
|