@corsair-dev/worldnewsapi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +119 -0
- package/dist/api.test.d.ts +2 -0
- package/dist/api.test.d.ts.map +1 -0
- package/dist/client.d.ts +57 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/endpoints/extract-news-links.d.ts +3 -0
- package/dist/endpoints/extract-news-links.d.ts.map +1 -0
- package/dist/endpoints/extract-news.d.ts +3 -0
- package/dist/endpoints/extract-news.d.ts.map +1 -0
- package/dist/endpoints/get-geo-coordinates.d.ts +3 -0
- package/dist/endpoints/get-geo-coordinates.d.ts.map +1 -0
- package/dist/endpoints/index.d.ts +153 -0
- package/dist/endpoints/index.d.ts.map +1 -0
- package/dist/endpoints/news-website-to-rss-feed.d.ts +3 -0
- package/dist/endpoints/news-website-to-rss-feed.d.ts.map +1 -0
- package/dist/endpoints/search-news-sources.d.ts +3 -0
- package/dist/endpoints/search-news-sources.d.ts.map +1 -0
- package/dist/endpoints/search-news.d.ts +3 -0
- package/dist/endpoints/search-news.d.ts.map +1 -0
- package/dist/endpoints/top-news.d.ts +3 -0
- package/dist/endpoints/top-news.d.ts.map +1 -0
- package/dist/endpoints/types.d.ts +395 -0
- package/dist/endpoints/types.d.ts.map +1 -0
- package/dist/endpoints.test.d.ts +2 -0
- package/dist/endpoints.test.d.ts.map +1 -0
- package/dist/error-handlers.d.ts +46 -0
- package/dist/error-handlers.d.ts.map +1 -0
- package/dist/error-handlers.test.d.ts +2 -0
- package/dist/error-handlers.test.d.ts.map +1 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/schema/database.d.ts +55 -0
- package/dist/schema/database.d.ts.map +1 -0
- package/dist/schema/index.d.ts +52 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema.test.d.ts +2 -0
- package/dist/schema.test.d.ts.map +1 -0
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(which shall not include Communications that are clearly marked or
|
|
39
|
+
otherwise designated in writing by the copyright owner as "Not a Work").
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution".
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright (c) 2026 Corsair
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @corsair-dev/worldnewsapi
|
|
2
|
+
|
|
3
|
+
World News API plugin for Corsair. Provides access to global news coverage, top headlines clustering, full article extraction, website link discovery, geolocation coordinates, website-to-RSS feeds, and news source directory lookups.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Top & Breaking News**: Retrieve breaking headlines clustered across sources by country and language.
|
|
8
|
+
- **Full Article Extraction**: Parse article web pages into structured data (title, text, images, videos, authors, sentiment, and named entities).
|
|
9
|
+
- **Global News Search**: Filter articles by text, author, publisher, sentiment, category, publish dates, and geographic proximity.
|
|
10
|
+
- **Link Discovery**: Discover all news links published on a website or news portal.
|
|
11
|
+
- **Geocoding for News**: Resolve location strings to latitude/longitude coordinates for radial search.
|
|
12
|
+
- **Website to RSS**: Transform any news website into a standard RSS 2.0 feed.
|
|
13
|
+
- **Production-Grade Security**: Header-based authentication (`x-api-key`), SSRF protection against private IP ranges, XXE-safe RSS parsing, and automatic rate-limit backoff.
|
|
14
|
+
|
|
15
|
+
## Auth Setup
|
|
16
|
+
|
|
17
|
+
World News API uses API key authentication. Get your API key from [World News API](https://worldnewsapi.com/).
|
|
18
|
+
|
|
19
|
+
Set your environment variable:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
WORLD_NEWS_API_KEY=your_api_key_here
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Plugin Initialization
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createCorsair } from 'corsair';
|
|
29
|
+
import { worldNewsApi } from '@corsair-dev/worldnewsapi';
|
|
30
|
+
|
|
31
|
+
const app = createCorsair({
|
|
32
|
+
plugins: [
|
|
33
|
+
worldNewsApi({
|
|
34
|
+
// Explicit key, or automatically resolved from WORLD_NEWS_API_KEY / key manager
|
|
35
|
+
key: process.env.WORLD_NEWS_API_KEY,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Tools & Endpoints
|
|
42
|
+
|
|
43
|
+
All tools are mounted under the `news` namespace.
|
|
44
|
+
|
|
45
|
+
| Tool / Endpoint | Risk Level | Description |
|
|
46
|
+
| :--- | :--- | :--- |
|
|
47
|
+
| `news.topNews` | `read` | Retrieve top news clusters by country and language (`GET /top-news`). |
|
|
48
|
+
| `news.extractNews` | `read` | Extract clean article text, metadata, images, and entities from a URL (`GET /extract-news`). |
|
|
49
|
+
| `news.extractNewsLinks` | `read` | Extract news article URLs from a webpage or portal (`GET /extract-news-links`). |
|
|
50
|
+
| `news.getGeoCoordinates` | `read` | Resolve addresses/locations to geographic coordinates (`GET /geo-coordinates`). |
|
|
51
|
+
| `news.newsWebsiteToRssFeed` | `read` | Convert any news site or page to structured RSS 2.0 XML / items (`GET /feed.rss`). |
|
|
52
|
+
| `news.searchNewsSources` | `read` | Search news sources monitored by the API (`GET /search-news-sources`). |
|
|
53
|
+
| `news.searchNews` | `read` | Search global news articles with rich filters and pagination (`GET /search-news`). |
|
|
54
|
+
|
|
55
|
+
## Usage Examples
|
|
56
|
+
|
|
57
|
+
### 1. Retrieve Top News for a Country
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const top = await app.call('worldnewsapi.news.topNews', {
|
|
61
|
+
sourceCountry: 'us',
|
|
62
|
+
language: 'en',
|
|
63
|
+
maxNewsPerCluster: 3,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
console.log(top.top_news);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Search News by Sentiment & Category
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const results = await app.call('worldnewsapi.news.searchNews', {
|
|
73
|
+
text: 'Artificial Intelligence',
|
|
74
|
+
categories: 'technology,science',
|
|
75
|
+
minSentiment: 0.2, // Positive sentiment only
|
|
76
|
+
number: 10,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
for (const article of results.news) {
|
|
80
|
+
console.log(`${article.title} (${article.url})`);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 3. Extract Full Article with Entity Analysis
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const article = await app.call('worldnewsapi.news.extractNews', {
|
|
88
|
+
url: 'https://www.example.com/news/article-1',
|
|
89
|
+
analyze: true,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
console.log(article.title, article.sentiment, article.entities);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 4. Convert Website to RSS Feed
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const feed = await app.call('worldnewsapi.news.newsWebsiteToRssFeed', {
|
|
99
|
+
url: 'https://www.example.com/tech-news',
|
|
100
|
+
extractNews: false,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
console.log(`Feed Title: ${feed.title}, Items: ${feed.items.length}`);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Entities & Database
|
|
107
|
+
|
|
108
|
+
Results are automatically persisted to the plugin database for caching and offline querying:
|
|
109
|
+
- `articles`: World news articles (`id`, `title`, `url`, `text`, `summary`, `sentiment`, `authors`, etc.)
|
|
110
|
+
- `extractedArticles`: Extracted article data keyed by URL
|
|
111
|
+
- `geoCoordinates`: Geocoded coordinates keyed by location string
|
|
112
|
+
- `sources`: News sources directory items
|
|
113
|
+
|
|
114
|
+
## Rate Limiting & Error Handling
|
|
115
|
+
|
|
116
|
+
- **429 Too Many Requests**: Automatically retries with exponential backoff respecting the `Retry-After` header.
|
|
117
|
+
- **401 Unauthorized**: Actionable logging when `WORLD_NEWS_API_KEY` is missing or invalid.
|
|
118
|
+
- **SSRF Protection**: Requests to local or private network ranges (`127.0.0.1`, `localhost`, `10.0.0.0/8`, `192.168.0.0/16`, `172.16.0.0/12`, `169.254.0.0/16`) are blocked immediately.
|
|
119
|
+
- **Safe RSS Parsing**: Pure TypeScript entity decoding and XML parsing safe from entity expansion (XXE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../api.test.ts"],"names":[],"mappings":""}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export declare class WorldNewsApiError extends Error {
|
|
3
|
+
readonly status?: number | undefined;
|
|
4
|
+
readonly code?: string | undefined;
|
|
5
|
+
constructor(message: string, status?: number | undefined, code?: string | undefined);
|
|
6
|
+
}
|
|
7
|
+
export type WorldNewsQuotaInfo = {
|
|
8
|
+
quotaRequest?: number;
|
|
9
|
+
quotaUsed?: number;
|
|
10
|
+
quotaLeft?: number;
|
|
11
|
+
};
|
|
12
|
+
export type WorldNewsClientResponse<T> = {
|
|
13
|
+
data: T;
|
|
14
|
+
quota?: WorldNewsQuotaInfo;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Validates whether a URL is a valid public HTTP/HTTPS URL and guards against SSRF.
|
|
18
|
+
*/
|
|
19
|
+
export declare function validatePublicUrl(rawUrl: string): URL;
|
|
20
|
+
/** Origin + path with userinfo and query stripped, for cache keys and logs. */
|
|
21
|
+
export declare function publicUrlKey(rawUrl: string): string;
|
|
22
|
+
export type ParsedRssItem = {
|
|
23
|
+
title?: string;
|
|
24
|
+
link?: string;
|
|
25
|
+
guid?: string;
|
|
26
|
+
pubDate?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
author?: string;
|
|
29
|
+
category?: string;
|
|
30
|
+
enclosureUrl?: string;
|
|
31
|
+
};
|
|
32
|
+
export type ParsedRssFeed = {
|
|
33
|
+
title?: string;
|
|
34
|
+
link?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
pubDate?: string;
|
|
37
|
+
lastBuildDate?: string;
|
|
38
|
+
language?: string;
|
|
39
|
+
items: ParsedRssItem[];
|
|
40
|
+
rawXml: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Parses RSS 2.0 XML safely without external entity expansion (XXE-safe).
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseRssFeedXml(xmlContent: string): ParsedRssFeed;
|
|
46
|
+
export type WorldNewsRequestOptions = {
|
|
47
|
+
method?: 'GET' | 'POST';
|
|
48
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
49
|
+
timeout?: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Performs an authenticated HTTP request to the World News API.
|
|
53
|
+
* Uses x-api-key header for production authentication.
|
|
54
|
+
* If a Zod schema is provided, the response payload is parsed and validated at runtime.
|
|
55
|
+
*/
|
|
56
|
+
export declare function makeWorldNewsApiRequest<T>(endpoint: string, apiKey: string, options: WorldNewsRequestOptions | undefined, schema: z.ZodType<T>): Promise<T>;
|
|
57
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,qBAAa,iBAAkB,SAAQ,KAAK;aAG1B,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,MAAM;gBAF7B,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,MAAM,YAAA;CAK9B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IACxC,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAIF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAsCrD;AA+CD,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKnD;AAgDD,MAAM,MAAM,aAAa,GAAG;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAsEjE;AAED,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,EAC9C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,YAAK,EACrC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,CAAC,CAAC,CA+CZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../client.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-news-links.d.ts","sourceRoot":"","sources":["../../endpoints/extract-news-links.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,gBAAgB,EAAE,qBAAqB,CAAC,sBAAsB,CAgCzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-news.d.ts","sourceRoot":"","sources":["../../endpoints/extract-news.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,WAAW,EAAE,qBAAqB,CAAC,iBAAiB,CAiDhE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-geo-coordinates.d.ts","sourceRoot":"","sources":["../../endpoints/get-geo-coordinates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,uBAAuB,CAwC3E,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export declare const News: {
|
|
2
|
+
topNews: (ctx: import("..").WorldNewsApiContext, args: {
|
|
3
|
+
sourceCountry: string;
|
|
4
|
+
language: string;
|
|
5
|
+
date?: string | undefined;
|
|
6
|
+
headlinesOnly?: boolean | undefined;
|
|
7
|
+
maxNewsPerCluster?: number | undefined;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
top_news: {
|
|
10
|
+
news: {
|
|
11
|
+
id: number;
|
|
12
|
+
title: string;
|
|
13
|
+
url: string;
|
|
14
|
+
text?: string | undefined;
|
|
15
|
+
summary?: string | null | undefined;
|
|
16
|
+
image?: string | null | undefined;
|
|
17
|
+
video?: string | null | undefined;
|
|
18
|
+
publish_date?: string | undefined;
|
|
19
|
+
author?: string | null | undefined;
|
|
20
|
+
authors?: (string | null)[] | undefined;
|
|
21
|
+
category?: string | undefined;
|
|
22
|
+
language?: string | undefined;
|
|
23
|
+
source_country?: string | undefined;
|
|
24
|
+
sentiment?: number | undefined;
|
|
25
|
+
}[];
|
|
26
|
+
}[];
|
|
27
|
+
language?: string | undefined;
|
|
28
|
+
country?: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
extractNews: (ctx: import("..").WorldNewsApiContext, args: {
|
|
31
|
+
url: string;
|
|
32
|
+
analyze?: boolean | undefined;
|
|
33
|
+
}) => Promise<{
|
|
34
|
+
title?: string | undefined;
|
|
35
|
+
text?: string | undefined;
|
|
36
|
+
url?: string | undefined;
|
|
37
|
+
image?: string | null | undefined;
|
|
38
|
+
images?: {
|
|
39
|
+
url: string;
|
|
40
|
+
title?: string | undefined;
|
|
41
|
+
width?: number | undefined;
|
|
42
|
+
height?: number | undefined;
|
|
43
|
+
}[] | undefined;
|
|
44
|
+
video?: string | null | undefined;
|
|
45
|
+
videos?: {
|
|
46
|
+
url: string;
|
|
47
|
+
title?: string | undefined;
|
|
48
|
+
summary?: string | undefined;
|
|
49
|
+
duration?: number | undefined;
|
|
50
|
+
thumbnail?: string | undefined;
|
|
51
|
+
}[] | undefined;
|
|
52
|
+
publish_date?: string | undefined;
|
|
53
|
+
author?: string | null | undefined;
|
|
54
|
+
authors?: (string | null)[] | undefined;
|
|
55
|
+
language?: string | undefined;
|
|
56
|
+
source_country?: string | undefined;
|
|
57
|
+
sentiment?: number | undefined;
|
|
58
|
+
entities?: {
|
|
59
|
+
name: string;
|
|
60
|
+
type: string;
|
|
61
|
+
sentiment?: number | undefined;
|
|
62
|
+
}[] | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
extractNewsLinks: (ctx: import("..").WorldNewsApiContext, args: {
|
|
65
|
+
url: string;
|
|
66
|
+
analyze?: boolean | undefined;
|
|
67
|
+
prefix?: string | undefined;
|
|
68
|
+
subDomain?: boolean | undefined;
|
|
69
|
+
}) => Promise<{
|
|
70
|
+
news_links: string[];
|
|
71
|
+
status?: string | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
getGeoCoordinates: (ctx: import("..").WorldNewsApiContext, args: {
|
|
74
|
+
location: string;
|
|
75
|
+
}) => Promise<{
|
|
76
|
+
latitude: number;
|
|
77
|
+
longitude: number;
|
|
78
|
+
city?: string | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
newsWebsiteToRssFeed: (ctx: import("..").WorldNewsApiContext, args: {
|
|
81
|
+
url: string;
|
|
82
|
+
extractNews?: boolean | undefined;
|
|
83
|
+
}) => Promise<{
|
|
84
|
+
items: {
|
|
85
|
+
title?: string | undefined;
|
|
86
|
+
link?: string | undefined;
|
|
87
|
+
guid?: string | undefined;
|
|
88
|
+
pubDate?: string | undefined;
|
|
89
|
+
description?: string | undefined;
|
|
90
|
+
author?: string | undefined;
|
|
91
|
+
category?: string | undefined;
|
|
92
|
+
enclosureUrl?: string | undefined;
|
|
93
|
+
}[];
|
|
94
|
+
title?: string | undefined;
|
|
95
|
+
link?: string | undefined;
|
|
96
|
+
description?: string | undefined;
|
|
97
|
+
pubDate?: string | undefined;
|
|
98
|
+
lastBuildDate?: string | undefined;
|
|
99
|
+
language?: string | undefined;
|
|
100
|
+
rawXml?: string | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
searchNewsSources: (ctx: import("..").WorldNewsApiContext, args: {
|
|
103
|
+
name: string;
|
|
104
|
+
}) => Promise<{
|
|
105
|
+
available: number;
|
|
106
|
+
sources: {
|
|
107
|
+
name: string;
|
|
108
|
+
url: string;
|
|
109
|
+
language?: string | undefined;
|
|
110
|
+
country?: string | undefined;
|
|
111
|
+
}[];
|
|
112
|
+
}>;
|
|
113
|
+
searchNews: (ctx: import("..").WorldNewsApiContext, args: {
|
|
114
|
+
text?: string | undefined;
|
|
115
|
+
textMatchIndexes?: string | undefined;
|
|
116
|
+
sourceCountry?: string | undefined;
|
|
117
|
+
language?: string | undefined;
|
|
118
|
+
minSentiment?: number | undefined;
|
|
119
|
+
maxSentiment?: number | undefined;
|
|
120
|
+
earliestPublishDate?: string | undefined;
|
|
121
|
+
latestPublishDate?: string | undefined;
|
|
122
|
+
newsSources?: string | undefined;
|
|
123
|
+
authors?: string | undefined;
|
|
124
|
+
categories?: string | undefined;
|
|
125
|
+
entities?: string | undefined;
|
|
126
|
+
locationFilter?: string | undefined;
|
|
127
|
+
sort?: string | undefined;
|
|
128
|
+
sortDirection?: "ASC" | "DESC" | undefined;
|
|
129
|
+
offset?: number | undefined;
|
|
130
|
+
number?: number | undefined;
|
|
131
|
+
}) => Promise<{
|
|
132
|
+
offset: number;
|
|
133
|
+
number: number;
|
|
134
|
+
available: number;
|
|
135
|
+
news: {
|
|
136
|
+
id: number;
|
|
137
|
+
title: string;
|
|
138
|
+
url: string;
|
|
139
|
+
text?: string | undefined;
|
|
140
|
+
summary?: string | null | undefined;
|
|
141
|
+
image?: string | null | undefined;
|
|
142
|
+
video?: string | null | undefined;
|
|
143
|
+
publish_date?: string | undefined;
|
|
144
|
+
author?: string | null | undefined;
|
|
145
|
+
authors?: (string | null)[] | undefined;
|
|
146
|
+
category?: string | undefined;
|
|
147
|
+
language?: string | undefined;
|
|
148
|
+
source_country?: string | undefined;
|
|
149
|
+
sentiment?: number | undefined;
|
|
150
|
+
}[];
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../endpoints/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"news-website-to-rss-feed.d.ts","sourceRoot":"","sources":["../../endpoints/news-website-to-rss-feed.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,oBAAoB,EAAE,qBAAqB,CAAC,0BAA0B,CAwCjF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-news-sources.d.ts","sourceRoot":"","sources":["../../endpoints/search-news-sources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,iBAAiB,EAAE,qBAAqB,CAAC,uBAAuB,CAqC3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-news.d.ts","sourceRoot":"","sources":["../../endpoints/search-news.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,UAAU,EAAE,qBAAqB,CAAC,gBAAgB,CA2D9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-news.d.ts","sourceRoot":"","sources":["../../endpoints/top-news.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,OAAO,EAAE,qBAAqB,CAAC,aAAa,CAoDxD,CAAC"}
|