newscatcher-catchall-sdk 1.1.2 → 1.3.1
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/README.md +305 -284
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +12 -0
- package/dist/cjs/Client.js +67 -0
- package/dist/cjs/api/resources/jobs/client/Client.d.ts +2 -1
- package/dist/cjs/api/resources/jobs/client/Client.js +2 -1
- package/dist/cjs/api/resources/jobs/client/requests/SubmitRequestDto.d.ts +22 -1
- package/dist/cjs/api/resources/jobs/client/requests/SubmitRequestDto.js +14 -0
- package/dist/cjs/api/resources/jobs/client/requests/index.d.ts +1 -1
- package/dist/cjs/api/resources/jobs/client/requests/index.js +3 -0
- package/dist/cjs/api/resources/meta/client/Client.d.ts +15 -3
- package/dist/cjs/api/resources/meta/client/Client.js +49 -1
- package/dist/cjs/api/types/GetPlanLimitsResponseDto.d.ts +5 -0
- package/dist/cjs/api/types/GetPlanLimitsResponseDto.js +3 -0
- package/dist/cjs/api/types/MonitorListItemDto.d.ts +4 -2
- package/dist/cjs/api/types/PlanFeature.d.ts +12 -0
- package/dist/cjs/api/types/PlanFeature.js +3 -0
- package/dist/cjs/api/types/PullJobResponseDto.d.ts +12 -8
- package/dist/cjs/api/types/PullJobResponseDto.js +9 -0
- package/dist/cjs/api/types/UserJob.d.ts +12 -0
- package/dist/cjs/api/types/UserJob.js +9 -0
- package/dist/cjs/api/types/index.d.ts +2 -0
- package/dist/cjs/api/types/index.js +2 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/index.js +3 -1
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +12 -0
- package/dist/esm/Client.mjs +34 -0
- package/dist/esm/api/resources/jobs/client/Client.d.mts +2 -1
- package/dist/esm/api/resources/jobs/client/Client.mjs +2 -1
- package/dist/esm/api/resources/jobs/client/requests/SubmitRequestDto.d.mts +22 -1
- package/dist/esm/api/resources/jobs/client/requests/SubmitRequestDto.mjs +13 -1
- package/dist/esm/api/resources/jobs/client/requests/index.d.mts +1 -1
- package/dist/esm/api/resources/jobs/client/requests/index.mjs +1 -1
- package/dist/esm/api/resources/meta/client/Client.d.mts +15 -3
- package/dist/esm/api/resources/meta/client/Client.mjs +50 -2
- package/dist/esm/api/types/GetPlanLimitsResponseDto.d.mts +5 -0
- package/dist/esm/api/types/GetPlanLimitsResponseDto.mjs +2 -0
- package/dist/esm/api/types/MonitorListItemDto.d.mts +4 -2
- package/dist/esm/api/types/PlanFeature.d.mts +12 -0
- package/dist/esm/api/types/PlanFeature.mjs +2 -0
- package/dist/esm/api/types/PullJobResponseDto.d.mts +12 -8
- package/dist/esm/api/types/PullJobResponseDto.mjs +8 -1
- package/dist/esm/api/types/UserJob.d.mts +12 -0
- package/dist/esm/api/types/UserJob.mjs +8 -1
- package/dist/esm/api/types/index.d.mts +2 -0
- package/dist/esm/api/types/index.mjs +2 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/index.d.mts +2 -0
- package/dist/esm/core/fetcher/index.mjs +1 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +57 -1
package/README.md
CHANGED
|
@@ -1,284 +1,305 @@
|
|
|
1
|
-
# Newscatcher
|
|
2
|
-
|
|
3
|
-
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FNewscatcher%2Fnewscatcher-catchall-typescript)
|
|
4
|
-
[](https://www.npmjs.com/package/newscatcher-catchall-sdk)
|
|
5
|
-
|
|
6
|
-
The Newscatcher
|
|
7
|
-
|
|
8
|
-
## Table of Contents
|
|
9
|
-
|
|
10
|
-
- [Documentation](#documentation)
|
|
11
|
-
- [Installation](#installation)
|
|
12
|
-
- [Reference](#reference)
|
|
13
|
-
- [Usage](#usage)
|
|
14
|
-
- [Request and Response Types](#request-and-response-types)
|
|
15
|
-
- [Exception Handling](#exception-handling)
|
|
16
|
-
- [Advanced](#advanced)
|
|
17
|
-
- [
|
|
18
|
-
- [Additional
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.log(err.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
The
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
```typescript
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
-
|
|
1
|
+
# Newscatcher TypeScript Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FNewscatcher%2Fnewscatcher-catchall-typescript)
|
|
4
|
+
[](https://www.npmjs.com/package/newscatcher-catchall-sdk)
|
|
5
|
+
|
|
6
|
+
The Newscatcher TypeScript library provides convenient access to the Newscatcher APIs from TypeScript.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Documentation](#documentation)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Reference](#reference)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Request and Response Types](#request-and-response-types)
|
|
15
|
+
- [Exception Handling](#exception-handling)
|
|
16
|
+
- [Advanced](#advanced)
|
|
17
|
+
- [Subpackage Exports](#subpackage-exports)
|
|
18
|
+
- [Additional Headers](#additional-headers)
|
|
19
|
+
- [Additional Query String Parameters](#additional-query-string-parameters)
|
|
20
|
+
- [Retries](#retries)
|
|
21
|
+
- [Timeouts](#timeouts)
|
|
22
|
+
- [Aborting Requests](#aborting-requests)
|
|
23
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
24
|
+
- [Logging](#logging)
|
|
25
|
+
- [Custom Fetch](#custom-fetch)
|
|
26
|
+
- [Runtime Compatibility](#runtime-compatibility)
|
|
27
|
+
- [Contributing](#contributing)
|
|
28
|
+
- [Support](#support)
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
API reference documentation is available [here](https://www.newscatcherapi.com/docs/web-search-api/api-reference/jobs/initialize-job).
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npm i -s newscatcher-catchall-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Reference
|
|
41
|
+
|
|
42
|
+
A full reference for this library is available [here](https://github.com/Newscatcher/newscatcher-catchall-typescript/blob/HEAD/./reference.md).
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
Instantiate and use the client with the following:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { CatchAllApiClient } from "newscatcher-catchall-sdk";
|
|
50
|
+
|
|
51
|
+
const client = new CatchAllApiClient({ apiKey: "YOUR_API_KEY" });
|
|
52
|
+
await client.jobs.createJob({
|
|
53
|
+
query: "Series B funding rounds for SaaS startups",
|
|
54
|
+
context: "Focus on funding amount and company name",
|
|
55
|
+
limit: 10,
|
|
56
|
+
start_date: "2026-02-18T00:00:00Z",
|
|
57
|
+
end_date: "2026-02-23T00:00:00Z",
|
|
58
|
+
mode: "base"
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Request and Response Types
|
|
63
|
+
|
|
64
|
+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
|
|
65
|
+
following namespace:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { CatchAllApi } from "newscatcher-catchall-sdk";
|
|
69
|
+
|
|
70
|
+
const request: CatchAllApi.InitializeRequestDto = {
|
|
71
|
+
...
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Exception Handling
|
|
76
|
+
|
|
77
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
78
|
+
will be thrown.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { CatchAllApiError } from "newscatcher-catchall-sdk";
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
await client.jobs.createJob(...);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
if (err instanceof CatchAllApiError) {
|
|
87
|
+
console.log(err.statusCode);
|
|
88
|
+
console.log(err.message);
|
|
89
|
+
console.log(err.body);
|
|
90
|
+
console.log(err.rawResponse);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Advanced
|
|
96
|
+
|
|
97
|
+
### Subpackage Exports
|
|
98
|
+
|
|
99
|
+
This SDK supports direct imports of subpackage clients, which allows JavaScript bundlers to tree-shake and include only the imported subpackage code. This results in much smaller bundle sizes.
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { JobsClient } from 'newscatcher-catchall-sdk/jobs';
|
|
103
|
+
|
|
104
|
+
const client = new JobsClient({...});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Additional Headers
|
|
108
|
+
|
|
109
|
+
If you would like to send additional headers as part of the request, use the `headers` request option.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { CatchAllApiClient } from "newscatcher-catchall-sdk";
|
|
113
|
+
|
|
114
|
+
const client = new CatchAllApiClient({
|
|
115
|
+
...
|
|
116
|
+
headers: {
|
|
117
|
+
'X-Custom-Header': 'custom value'
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const response = await client.jobs.createJob(..., {
|
|
122
|
+
headers: {
|
|
123
|
+
'X-Custom-Header': 'custom value'
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Additional Query String Parameters
|
|
129
|
+
|
|
130
|
+
If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const response = await client.jobs.createJob(..., {
|
|
134
|
+
queryParams: {
|
|
135
|
+
'customQueryParamKey': 'custom query param value'
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Retries
|
|
141
|
+
|
|
142
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
143
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
144
|
+
retry limit (default: 2).
|
|
145
|
+
|
|
146
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
147
|
+
|
|
148
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
149
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
150
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
151
|
+
|
|
152
|
+
Use the `maxRetries` request option to configure this behavior.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
const response = await client.jobs.createJob(..., {
|
|
156
|
+
maxRetries: 0 // override maxRetries at the request level
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Timeouts
|
|
161
|
+
|
|
162
|
+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const response = await client.jobs.createJob(..., {
|
|
166
|
+
timeoutInSeconds: 30 // override timeout to 30s
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Aborting Requests
|
|
171
|
+
|
|
172
|
+
The SDK allows users to abort requests at any point by passing in an abort signal.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const controller = new AbortController();
|
|
176
|
+
const response = await client.jobs.createJob(..., {
|
|
177
|
+
abortSignal: controller.signal
|
|
178
|
+
});
|
|
179
|
+
controller.abort(); // aborts the request
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Access Raw Response Data
|
|
183
|
+
|
|
184
|
+
The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method.
|
|
185
|
+
The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const { data, rawResponse } = await client.jobs.createJob(...).withRawResponse();
|
|
189
|
+
|
|
190
|
+
console.log(data);
|
|
191
|
+
console.log(rawResponse.headers['X-My-Header']);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Logging
|
|
195
|
+
|
|
196
|
+
The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options.
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { CatchAllApiClient, logging } from "newscatcher-catchall-sdk";
|
|
200
|
+
|
|
201
|
+
const client = new CatchAllApiClient({
|
|
202
|
+
...
|
|
203
|
+
logging: {
|
|
204
|
+
level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info
|
|
205
|
+
logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger
|
|
206
|
+
silent: false, // defaults to true, set to false to enable logging
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
The `logging` object can have the following properties:
|
|
211
|
+
- `level`: The log level to use. Defaults to `logging.LogLevel.Info`.
|
|
212
|
+
- `logger`: The logger to use. Defaults to a `logging.ConsoleLogger`.
|
|
213
|
+
- `silent`: Whether to silence the logger. Defaults to `true`.
|
|
214
|
+
|
|
215
|
+
The `level` property can be one of the following values:
|
|
216
|
+
- `logging.LogLevel.Debug`
|
|
217
|
+
- `logging.LogLevel.Info`
|
|
218
|
+
- `logging.LogLevel.Warn`
|
|
219
|
+
- `logging.LogLevel.Error`
|
|
220
|
+
|
|
221
|
+
To provide a custom logger, you can pass in an object that implements the `logging.ILogger` interface.
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary>Custom logger examples</summary>
|
|
225
|
+
|
|
226
|
+
Here's an example using the popular `winston` logging library.
|
|
227
|
+
```ts
|
|
228
|
+
import winston from 'winston';
|
|
229
|
+
|
|
230
|
+
const winstonLogger = winston.createLogger({...});
|
|
231
|
+
|
|
232
|
+
const logger: logging.ILogger = {
|
|
233
|
+
debug: (msg, ...args) => winstonLogger.debug(msg, ...args),
|
|
234
|
+
info: (msg, ...args) => winstonLogger.info(msg, ...args),
|
|
235
|
+
warn: (msg, ...args) => winstonLogger.warn(msg, ...args),
|
|
236
|
+
error: (msg, ...args) => winstonLogger.error(msg, ...args),
|
|
237
|
+
};
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Here's an example using the popular `pino` logging library.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
import pino from 'pino';
|
|
244
|
+
|
|
245
|
+
const pinoLogger = pino({...});
|
|
246
|
+
|
|
247
|
+
const logger: logging.ILogger = {
|
|
248
|
+
debug: (msg, ...args) => pinoLogger.debug(args, msg),
|
|
249
|
+
info: (msg, ...args) => pinoLogger.info(args, msg),
|
|
250
|
+
warn: (msg, ...args) => pinoLogger.warn(args, msg),
|
|
251
|
+
error: (msg, ...args) => pinoLogger.error(args, msg),
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
</details>
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
### Custom Fetch
|
|
258
|
+
|
|
259
|
+
The SDK provides a low-level `fetch` method for making custom HTTP requests while still
|
|
260
|
+
benefiting from SDK-level configuration like authentication, retries, timeouts, and logging.
|
|
261
|
+
This is useful for calling API endpoints not yet supported in the SDK.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
const response = await client.fetch("/v1/custom/endpoint", {
|
|
265
|
+
method: "GET",
|
|
266
|
+
}, {
|
|
267
|
+
timeoutInSeconds: 30,
|
|
268
|
+
maxRetries: 3,
|
|
269
|
+
headers: {
|
|
270
|
+
"X-Custom-Header": "custom-value",
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const data = await response.json();
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Runtime Compatibility
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
The SDK works in the following runtimes:
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
- Node.js 18+
|
|
285
|
+
- Vercel
|
|
286
|
+
- Cloudflare Workers
|
|
287
|
+
- Deno v1.25+
|
|
288
|
+
- Bun 1.0+
|
|
289
|
+
- React Native
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
## Contributing
|
|
293
|
+
|
|
294
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
295
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
296
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
297
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
298
|
+
an issue first to discuss with us!
|
|
299
|
+
|
|
300
|
+
On the other hand, contributions to the README are always very welcome!
|
|
301
|
+
## Support
|
|
302
|
+
|
|
303
|
+
- Documentation: [www.newscatcherapi.com/docs/web-search-api](https://www.newscatcherapi.com/docs/web-search-api/get-started/introduction)
|
|
304
|
+
- Support: <support@newscatcherapi.com>
|
|
305
|
+
|
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "newscatcher-catchall-sdk",
|
|
46
|
-
"X-Fern-SDK-Version": "1.1
|
|
47
|
-
"User-Agent": "newscatcher-catchall-sdk/1.1
|
|
46
|
+
"X-Fern-SDK-Version": "1.3.1",
|
|
47
|
+
"User-Agent": "newscatcher-catchall-sdk/1.3.1",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { MetaClient } from "./api/resources/meta/client/Client.js";
|
|
|
3
3
|
import { MonitorsClient } from "./api/resources/monitors/client/Client.js";
|
|
4
4
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
5
5
|
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
|
|
6
|
+
import * as core from "./core/index.js";
|
|
6
7
|
export declare namespace CatchAllApiClient {
|
|
7
8
|
type Options = BaseClientOptions;
|
|
8
9
|
interface RequestOptions extends BaseRequestOptions {
|
|
@@ -17,4 +18,15 @@ export declare class CatchAllApiClient {
|
|
|
17
18
|
get jobs(): JobsClient;
|
|
18
19
|
get monitors(): MonitorsClient;
|
|
19
20
|
get meta(): MetaClient;
|
|
21
|
+
/**
|
|
22
|
+
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
23
|
+
* This is useful for making requests to endpoints not yet supported in the SDK.
|
|
24
|
+
* The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
|
|
25
|
+
*
|
|
26
|
+
* @param {Request | string | URL} input - The URL, path, or Request object.
|
|
27
|
+
* @param {RequestInit} init - Standard fetch RequestInit options.
|
|
28
|
+
* @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
|
|
29
|
+
* @returns {Promise<Response>} A standard Response object.
|
|
30
|
+
*/
|
|
31
|
+
fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
|
|
20
32
|
}
|