@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.
Files changed (44) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +119 -0
  3. package/dist/api.test.d.ts +2 -0
  4. package/dist/api.test.d.ts.map +1 -0
  5. package/dist/client.d.ts +57 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.test.d.ts +2 -0
  8. package/dist/client.test.d.ts.map +1 -0
  9. package/dist/endpoints/extract-news-links.d.ts +3 -0
  10. package/dist/endpoints/extract-news-links.d.ts.map +1 -0
  11. package/dist/endpoints/extract-news.d.ts +3 -0
  12. package/dist/endpoints/extract-news.d.ts.map +1 -0
  13. package/dist/endpoints/get-geo-coordinates.d.ts +3 -0
  14. package/dist/endpoints/get-geo-coordinates.d.ts.map +1 -0
  15. package/dist/endpoints/index.d.ts +153 -0
  16. package/dist/endpoints/index.d.ts.map +1 -0
  17. package/dist/endpoints/news-website-to-rss-feed.d.ts +3 -0
  18. package/dist/endpoints/news-website-to-rss-feed.d.ts.map +1 -0
  19. package/dist/endpoints/search-news-sources.d.ts +3 -0
  20. package/dist/endpoints/search-news-sources.d.ts.map +1 -0
  21. package/dist/endpoints/search-news.d.ts +3 -0
  22. package/dist/endpoints/search-news.d.ts.map +1 -0
  23. package/dist/endpoints/top-news.d.ts +3 -0
  24. package/dist/endpoints/top-news.d.ts.map +1 -0
  25. package/dist/endpoints/types.d.ts +395 -0
  26. package/dist/endpoints/types.d.ts.map +1 -0
  27. package/dist/endpoints.test.d.ts +2 -0
  28. package/dist/endpoints.test.d.ts.map +1 -0
  29. package/dist/error-handlers.d.ts +46 -0
  30. package/dist/error-handlers.d.ts.map +1 -0
  31. package/dist/error-handlers.test.d.ts +2 -0
  32. package/dist/error-handlers.test.d.ts.map +1 -0
  33. package/dist/index.d.ts +222 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/schema/database.d.ts +55 -0
  37. package/dist/schema/database.d.ts.map +1 -0
  38. package/dist/schema/index.d.ts +52 -0
  39. package/dist/schema/index.d.ts.map +1 -0
  40. package/dist/schema.test.d.ts +2 -0
  41. package/dist/schema.test.d.ts.map +1 -0
  42. package/dist/tsup.config.d.ts +3 -0
  43. package/dist/tsup.config.d.ts.map +1 -0
  44. package/package.json +44 -0
@@ -0,0 +1,222 @@
1
+ import type { AuthTypes, BindEndpoints, CorsairEndpoint, CorsairErrorHandler, CorsairPlugin, CorsairPluginContext, KeyBuilderContext, PickAuth, PluginPermissionsConfig } from 'corsair/core';
2
+ import type { WorldNewsApiEndpointInputs, WorldNewsApiEndpointOutputs } from './endpoints/types';
3
+ import { WorldNewsApiSchema } from './schema';
4
+ export type WorldNewsApiPluginOptions = {
5
+ authType?: PickAuth<'api_key'>;
6
+ key?: string;
7
+ hooks?: InternalWorldNewsApiPlugin['hooks'];
8
+ errorHandlers?: CorsairErrorHandler;
9
+ permissions?: PluginPermissionsConfig<typeof worldNewsApiEndpointsNested>;
10
+ };
11
+ export type WorldNewsApiContext = CorsairPluginContext<typeof WorldNewsApiSchema, WorldNewsApiPluginOptions>;
12
+ export type WorldNewsApiKeyBuilderContext = KeyBuilderContext<WorldNewsApiPluginOptions>;
13
+ export type WorldNewsApiBoundEndpoints = BindEndpoints<typeof worldNewsApiEndpointsNested>;
14
+ type WorldNewsApiEndpoint<K extends keyof WorldNewsApiEndpointOutputs> = CorsairEndpoint<WorldNewsApiContext, WorldNewsApiEndpointInputs[K], WorldNewsApiEndpointOutputs[K]>;
15
+ export type WorldNewsApiEndpoints = {
16
+ newsTopNews: WorldNewsApiEndpoint<'news.topNews'>;
17
+ newsExtractNews: WorldNewsApiEndpoint<'news.extractNews'>;
18
+ newsExtractNewsLinks: WorldNewsApiEndpoint<'news.extractNewsLinks'>;
19
+ newsGetGeoCoordinates: WorldNewsApiEndpoint<'news.getGeoCoordinates'>;
20
+ newsNewsWebsiteToRssFeed: WorldNewsApiEndpoint<'news.newsWebsiteToRssFeed'>;
21
+ newsSearchNewsSources: WorldNewsApiEndpoint<'news.searchNewsSources'>;
22
+ newsSearchNews: WorldNewsApiEndpoint<'news.searchNews'>;
23
+ };
24
+ declare const worldNewsApiEndpointsNested: {
25
+ readonly news: {
26
+ readonly topNews: WorldNewsApiEndpoint<"news.topNews">;
27
+ readonly extractNews: WorldNewsApiEndpoint<"news.extractNews">;
28
+ readonly extractNewsLinks: WorldNewsApiEndpoint<"news.extractNewsLinks">;
29
+ readonly getGeoCoordinates: WorldNewsApiEndpoint<"news.getGeoCoordinates">;
30
+ readonly newsWebsiteToRssFeed: WorldNewsApiEndpoint<"news.newsWebsiteToRssFeed">;
31
+ readonly searchNewsSources: WorldNewsApiEndpoint<"news.searchNewsSources">;
32
+ readonly searchNews: WorldNewsApiEndpoint<"news.searchNews">;
33
+ };
34
+ };
35
+ declare const worldNewsApiWebhooksNested: {};
36
+ export declare const worldNewsApiEndpointSchemas: {
37
+ readonly 'news.topNews': {
38
+ readonly input: import("zod").ZodObject<{
39
+ sourceCountry: import("zod").ZodString;
40
+ language: import("zod").ZodString;
41
+ date: import("zod").ZodOptional<import("zod").ZodISODate>;
42
+ headlinesOnly: import("zod").ZodOptional<import("zod").ZodBoolean>;
43
+ maxNewsPerCluster: import("zod").ZodOptional<import("zod").ZodNumber>;
44
+ }, import("zod/v4/core").$strip>;
45
+ readonly output: import("zod").ZodObject<{
46
+ top_news: import("zod").ZodArray<import("zod").ZodObject<{
47
+ news: import("zod").ZodArray<import("zod").ZodObject<{
48
+ id: import("zod").ZodNumber;
49
+ title: import("zod").ZodString;
50
+ text: import("zod").ZodOptional<import("zod").ZodString>;
51
+ summary: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
52
+ url: import("zod").ZodString;
53
+ image: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
54
+ video: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
55
+ publish_date: import("zod").ZodOptional<import("zod").ZodString>;
56
+ author: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
57
+ authors: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNullable<import("zod").ZodString>>>;
58
+ category: import("zod").ZodOptional<import("zod").ZodString>;
59
+ language: import("zod").ZodOptional<import("zod").ZodString>;
60
+ source_country: import("zod").ZodOptional<import("zod").ZodString>;
61
+ sentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
62
+ }, import("zod/v4/core").$strip>>;
63
+ }, import("zod/v4/core").$strip>>;
64
+ language: import("zod").ZodOptional<import("zod").ZodString>;
65
+ country: import("zod").ZodOptional<import("zod").ZodString>;
66
+ }, import("zod/v4/core").$strip>;
67
+ };
68
+ readonly 'news.extractNews': {
69
+ readonly input: import("zod").ZodObject<{
70
+ url: import("zod").ZodString;
71
+ analyze: import("zod").ZodOptional<import("zod").ZodBoolean>;
72
+ }, import("zod/v4/core").$strip>;
73
+ readonly output: import("zod").ZodObject<{
74
+ title: import("zod").ZodOptional<import("zod").ZodString>;
75
+ text: import("zod").ZodOptional<import("zod").ZodString>;
76
+ url: import("zod").ZodOptional<import("zod").ZodString>;
77
+ image: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
78
+ images: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
79
+ title: import("zod").ZodOptional<import("zod").ZodString>;
80
+ url: import("zod").ZodString;
81
+ width: import("zod").ZodOptional<import("zod").ZodNumber>;
82
+ height: import("zod").ZodOptional<import("zod").ZodNumber>;
83
+ }, import("zod/v4/core").$strip>>>;
84
+ video: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
85
+ videos: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
86
+ title: import("zod").ZodOptional<import("zod").ZodString>;
87
+ url: import("zod").ZodString;
88
+ summary: import("zod").ZodOptional<import("zod").ZodString>;
89
+ duration: import("zod").ZodOptional<import("zod").ZodNumber>;
90
+ thumbnail: import("zod").ZodOptional<import("zod").ZodString>;
91
+ }, import("zod/v4/core").$strip>>>;
92
+ publish_date: import("zod").ZodOptional<import("zod").ZodString>;
93
+ author: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
94
+ authors: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNullable<import("zod").ZodString>>>;
95
+ language: import("zod").ZodOptional<import("zod").ZodString>;
96
+ source_country: import("zod").ZodOptional<import("zod").ZodString>;
97
+ sentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
98
+ entities: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
99
+ name: import("zod").ZodString;
100
+ type: import("zod").ZodString;
101
+ sentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
102
+ }, import("zod/v4/core").$strip>>>;
103
+ }, import("zod/v4/core").$strip>;
104
+ };
105
+ readonly 'news.extractNewsLinks': {
106
+ readonly input: import("zod").ZodObject<{
107
+ url: import("zod").ZodString;
108
+ analyze: import("zod").ZodOptional<import("zod").ZodBoolean>;
109
+ prefix: import("zod").ZodOptional<import("zod").ZodString>;
110
+ subDomain: import("zod").ZodOptional<import("zod").ZodBoolean>;
111
+ }, import("zod/v4/core").$strip>;
112
+ readonly output: import("zod").ZodObject<{
113
+ status: import("zod").ZodOptional<import("zod").ZodString>;
114
+ news_links: import("zod").ZodArray<import("zod").ZodString>;
115
+ }, import("zod/v4/core").$strip>;
116
+ };
117
+ readonly 'news.getGeoCoordinates': {
118
+ readonly input: import("zod").ZodObject<{
119
+ location: import("zod").ZodString;
120
+ }, import("zod/v4/core").$strip>;
121
+ readonly output: import("zod").ZodObject<{
122
+ latitude: import("zod").ZodNumber;
123
+ longitude: import("zod").ZodNumber;
124
+ city: import("zod").ZodOptional<import("zod").ZodString>;
125
+ }, import("zod/v4/core").$strip>;
126
+ };
127
+ readonly 'news.newsWebsiteToRssFeed': {
128
+ readonly input: import("zod").ZodObject<{
129
+ url: import("zod").ZodString;
130
+ extractNews: import("zod").ZodOptional<import("zod").ZodBoolean>;
131
+ }, import("zod/v4/core").$strip>;
132
+ readonly output: import("zod").ZodObject<{
133
+ title: import("zod").ZodOptional<import("zod").ZodString>;
134
+ link: import("zod").ZodOptional<import("zod").ZodString>;
135
+ description: import("zod").ZodOptional<import("zod").ZodString>;
136
+ pubDate: import("zod").ZodOptional<import("zod").ZodString>;
137
+ lastBuildDate: import("zod").ZodOptional<import("zod").ZodString>;
138
+ language: import("zod").ZodOptional<import("zod").ZodString>;
139
+ items: import("zod").ZodArray<import("zod").ZodObject<{
140
+ title: import("zod").ZodOptional<import("zod").ZodString>;
141
+ link: import("zod").ZodOptional<import("zod").ZodString>;
142
+ guid: import("zod").ZodOptional<import("zod").ZodString>;
143
+ pubDate: import("zod").ZodOptional<import("zod").ZodString>;
144
+ description: import("zod").ZodOptional<import("zod").ZodString>;
145
+ author: import("zod").ZodOptional<import("zod").ZodString>;
146
+ category: import("zod").ZodOptional<import("zod").ZodString>;
147
+ enclosureUrl: import("zod").ZodOptional<import("zod").ZodString>;
148
+ }, import("zod/v4/core").$strip>>;
149
+ rawXml: import("zod").ZodOptional<import("zod").ZodString>;
150
+ }, import("zod/v4/core").$strip>;
151
+ };
152
+ readonly 'news.searchNewsSources': {
153
+ readonly input: import("zod").ZodObject<{
154
+ name: import("zod").ZodString;
155
+ }, import("zod/v4/core").$strip>;
156
+ readonly output: import("zod").ZodObject<{
157
+ available: import("zod").ZodNumber;
158
+ sources: import("zod").ZodArray<import("zod").ZodObject<{
159
+ name: import("zod").ZodString;
160
+ url: import("zod").ZodString;
161
+ language: import("zod").ZodOptional<import("zod").ZodString>;
162
+ country: import("zod").ZodOptional<import("zod").ZodString>;
163
+ }, import("zod/v4/core").$strip>>;
164
+ }, import("zod/v4/core").$strip>;
165
+ };
166
+ readonly 'news.searchNews': {
167
+ readonly input: import("zod").ZodObject<{
168
+ text: import("zod").ZodOptional<import("zod").ZodString>;
169
+ textMatchIndexes: import("zod").ZodOptional<import("zod").ZodString>;
170
+ sourceCountry: import("zod").ZodOptional<import("zod").ZodString>;
171
+ language: import("zod").ZodOptional<import("zod").ZodString>;
172
+ minSentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
173
+ maxSentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
174
+ earliestPublishDate: import("zod").ZodOptional<import("zod").ZodString>;
175
+ latestPublishDate: import("zod").ZodOptional<import("zod").ZodString>;
176
+ newsSources: import("zod").ZodOptional<import("zod").ZodString>;
177
+ authors: import("zod").ZodOptional<import("zod").ZodString>;
178
+ categories: import("zod").ZodOptional<import("zod").ZodString>;
179
+ entities: import("zod").ZodOptional<import("zod").ZodString>;
180
+ locationFilter: import("zod").ZodOptional<import("zod").ZodString>;
181
+ sort: import("zod").ZodOptional<import("zod").ZodString>;
182
+ sortDirection: import("zod").ZodOptional<import("zod").ZodEnum<{
183
+ ASC: "ASC";
184
+ DESC: "DESC";
185
+ }>>;
186
+ offset: import("zod").ZodOptional<import("zod").ZodNumber>;
187
+ number: import("zod").ZodOptional<import("zod").ZodNumber>;
188
+ }, import("zod/v4/core").$strip>;
189
+ readonly output: import("zod").ZodObject<{
190
+ offset: import("zod").ZodNumber;
191
+ number: import("zod").ZodNumber;
192
+ available: import("zod").ZodNumber;
193
+ news: import("zod").ZodArray<import("zod").ZodObject<{
194
+ id: import("zod").ZodNumber;
195
+ title: import("zod").ZodString;
196
+ text: import("zod").ZodOptional<import("zod").ZodString>;
197
+ summary: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
198
+ url: import("zod").ZodString;
199
+ image: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
200
+ video: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
201
+ publish_date: import("zod").ZodOptional<import("zod").ZodString>;
202
+ author: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
203
+ authors: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNullable<import("zod").ZodString>>>;
204
+ category: import("zod").ZodOptional<import("zod").ZodString>;
205
+ language: import("zod").ZodOptional<import("zod").ZodString>;
206
+ source_country: import("zod").ZodOptional<import("zod").ZodString>;
207
+ sentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
208
+ }, import("zod/v4/core").$strip>>;
209
+ }, import("zod/v4/core").$strip>;
210
+ };
211
+ };
212
+ declare const defaultAuthType: AuthTypes;
213
+ export declare const worldNewsApiAuthConfig: {
214
+ readonly api_key: {};
215
+ };
216
+ export type BaseWorldNewsApiPlugin<T extends WorldNewsApiPluginOptions> = CorsairPlugin<'worldnewsapi', typeof WorldNewsApiSchema, typeof worldNewsApiEndpointsNested, typeof worldNewsApiWebhooksNested, T, typeof defaultAuthType>;
217
+ export type InternalWorldNewsApiPlugin = BaseWorldNewsApiPlugin<WorldNewsApiPluginOptions>;
218
+ export type ExternalWorldNewsApiPlugin<T extends WorldNewsApiPluginOptions> = BaseWorldNewsApiPlugin<T>;
219
+ export declare function worldNewsApi<const T extends WorldNewsApiPluginOptions>(incomingOptions?: WorldNewsApiPluginOptions & T): ExternalWorldNewsApiPlugin<T>;
220
+ export type { ParsedRssFeed, ParsedRssItem, WorldNewsQuotaInfo, } from './client';
221
+ export type { WorldNewsApiEndpointInputs, WorldNewsApiEndpointOutputs, WorldNewsArticle, } from './endpoints/types';
222
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"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"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{AuthMissingError as Pe}from"corsair/core";import{logEventFromContext as We}from"corsair/core";import{request as ae}from"corsair/http";import{ZodError as le}from"zod";var u=class extends Error{constructor(o,s,i){super(o);this.status=s;this.code=i;this.name="WorldNewsApiError"}},ce="https://api.worldnewsapi.com";function h(t){if(!t||typeof t!="string")throw new u("Invalid URL provided: URL must be a non-empty string",400,"INVALID_URL");let n;try{n=new URL(t)}catch{throw new u(`Malformed URL: "${t}"`,400,"MALFORMED_URL")}if(n.protocol!=="http:"&&n.protocol!=="https:")throw new u(`Unsupported protocol: "${n.protocol}". Only http and https URLs are permitted.`,400,"INVALID_PROTOCOL");let o=n.hostname.toLowerCase();if(ue(o))throw new u(`Access to private or local network hosts (${o}) is not permitted.`,400,"SSRF_PROTECTED");return n}function S(t){return!!(/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)||/^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)||/^192\.168\.\d{1,3}\.\d{1,3}$/.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/.test(t)||/^169\.254\.\d{1,3}\.\d{1,3}$/.test(t)||t==="0.0.0.0")}function ue(t){let n=t.replace(/^\[|\]$/g,"").toLowerCase();if(n==="localhost"||n==="::1"||n==="::"||n==="0:0:0:0:0:0:0:1"||n.endsWith(".localhost")||n.endsWith(".local")||n.endsWith(".internal"))return!0;let o=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(n);if(o?.[1]&&S(o[1]))return!0;let s=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(n);if(s?.[1]&&s[2]){let i=parseInt(s[1],16),a=parseInt(s[2],16),d=`${i>>8&255}.${i&255}.${a>>8&255}.${a&255}`;if(S(d))return!0}return!!(S(n)||n.includes(":")&&(n.startsWith("fe80:")||n.startsWith("fc")||n.startsWith("fd")))}function f(t){let n=h(t);return n.username="",n.password="",`${n.origin}${n.pathname}`}function de(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").replace(/&#(\d+);/g,(n,o)=>L(parseInt(o,10))).replace(/&#x([0-9a-fA-F]+);/g,(n,o)=>L(parseInt(o,16)))}function L(t){return!Number.isFinite(t)||t<0||t>1114111||t>=55296&&t<=57343?"":String.fromCodePoint(t)}function pe(t){return t.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g,"$1")}function l(t,n){if(!t)return;let o=new RegExp(`<(?:[a-zA-Z0-9_-]+:)?${n}[^>]*>([\\s\\S]*?)<\\/(?:[a-zA-Z0-9_-]+:)?${n}>`,"i"),s=t.match(o);if(!(!s||s[1]===void 0))return de(pe(s[1].trim()))}function v(t){if(!t||typeof t!="string")throw new u("Empty or invalid RSS feed content",422,"MALFORMED_RSS");let n=t.match(/<channel[^>]*>([\s\S]*?)<\/channel>/i);if(!n)throw new u("RSS response is missing a channel element",422,"MALFORMED_RSS");let o=n[1]??"",s=l(o,"title"),i=l(o,"link"),a=l(o,"description"),d=l(o,"pubDate"),x=l(o,"lastBuildDate"),D=l(o,"language"),A=/<item[^>]*>([\s\S]*?)<\/item>/gi,y=[],I;for(;(I=A.exec(o))!==null;){let p=I[1]??"",J=l(p,"title"),ee=l(p,"link"),te=l(p,"guid"),ne=l(p,"pubDate"),oe=l(p,"description"),se=l(p,"author")??l(p,"creator"),re=l(p,"category"),P=p.match(/<enclosure[^>]*url=["']([^"']+)["'][^>]*\/?>/i),ie=P?P[1]:void 0;y.push({title:J,link:ee,guid:te,pubDate:ne,description:oe,author:se,category:re,enclosureUrl:ie})}return{title:s,link:i,description:a,pubDate:d,lastBuildDate:x,language:D,items:y,rawXml:t}}async function c(t,n,o={},s){if(!n||!n.trim())throw new u("World News API key is required. Set WORLD_NEWS_API_KEY environment variable or pass key option.",401,"AUTH_MISSING");let{method:i="GET",query:a,timeout:d=25e3}=o,x={BASE:ce,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TIMEOUT:d,TOKEN:void 0,HEADERS:{"x-api-key":n.trim(),Accept:t.endsWith(".rss")?"application/xml, text/xml, application/rss+xml":"application/json"}},A=await ae(x,{method:i,url:t,mediaType:"application/json; charset=utf-8",query:a});try{return s.parse(A)}catch(y){throw y instanceof le?new u("World News API returned a payload that does not match the documented schema",422,"INVALID_RESPONSE"):y}}import{z as e}from"zod";var E=e.iso.date(),F=e.string().refine(t=>{if(E.safeParse(t).success)return!0;let n=/^(\d{4}-\d{2}-\d{2}) (\d{2}):(\d{2}):(\d{2})$/.exec(t);if(!n||!E.safeParse(n[1]).success)return!1;let o=Number(n[2]),s=Number(n[3]),i=Number(n[4]);return o<24&&s<60&&i<60},"Date must be YYYY-MM-DD or YYYY-MM-DD HH:MM:SS"),M=e.object({id:e.number(),title:e.string(),text:e.string().optional(),summary:e.string().nullable().optional(),url:e.string(),image:e.string().nullable().optional(),video:e.string().nullable().optional(),publish_date:e.string().optional(),author:e.string().nullable().optional(),authors:e.array(e.string().nullable()).optional(),category:e.string().optional(),language:e.string().optional(),source_country:e.string().optional(),sentiment:e.number().optional()}),we=e.object({title:e.string().optional(),url:e.string(),width:e.number().optional(),height:e.number().optional()}),me=e.object({title:e.string().optional(),url:e.string(),summary:e.string().optional(),duration:e.number().optional(),thumbnail:e.string().optional()}),ge=e.object({name:e.string(),type:e.string(),sentiment:e.number().optional()}),he=e.object({title:e.string().optional(),link:e.string().optional(),guid:e.string().optional(),pubDate:e.string().optional(),description:e.string().optional(),author:e.string().optional(),category:e.string().optional(),enclosureUrl:e.string().optional()}),fe=e.object({name:e.string(),url:e.string(),language:e.string().optional(),country:e.string().optional()}),Ne=e.object({sourceCountry:e.string().length(2).describe('The 2-letter ISO 3166 country code for which top news should be retrieved (e.g., "us", "in", "gb").'),language:e.string().length(2).describe('The 2-letter ISO 639-1 language code of the top news (e.g., "en", "es", "fr").'),date:E.optional().describe("The date for which the top news should be retrieved (YYYY-MM-DD). Defaults to today."),headlinesOnly:e.boolean().optional().describe("Whether to only return basic headline fields (id, title, url). Defaults to false."),maxNewsPerCluster:e.number().int().min(1).max(100).optional().describe("How many news articles to return per story cluster. Default is 1.")}),be=e.object({url:e.string().url().describe("The URL of the news article to extract into structured data."),analyze:e.boolean().optional().describe("Whether to analyze the extracted news (extract named entities, detect sentiment, etc.). Defaults to false.")}),ye=e.object({url:e.string().url().describe("The webpage or site URL from which news article links should be extracted."),analyze:e.boolean().optional().describe("Whether to analyze extracted links. Defaults to false."),prefix:e.string().max(100).optional().describe("The prefix that discovered news links must start with."),subDomain:e.boolean().optional().describe("Whether to include links to news articles on sub-domains. Defaults to true.")}),xe=e.object({location:e.string().min(1).max(1e3).describe('The address or location name to geocode (e.g., "Tokyo, Japan" or "Mumbai, India").')}),Ae=e.object({url:e.string().url().describe("The URL of the news website/page to convert into an RSS 2.0 feed."),extractNews:e.boolean().optional().describe("Whether to extract full article text/data for each item in the feed (costs additional quota). Defaults to false.")}),Se=e.object({name:e.string().min(3).max(1e3).describe('The (partial) name of the news source to search for (e.g. "bbc", "reuters", "times").')}),Ee=e.object({text:e.string().min(3).max(100).optional().describe("Search query text. Supports implicit AND, OR, negation with -, parentheses, and quotes for exact phrases."),textMatchIndexes:e.string().optional().describe('Where to search for text: "title", "content", or "title,content".'),sourceCountry:e.string().length(2).optional().describe("Filter by 2-letter ISO 3166 country code."),language:e.string().length(2).optional().describe("Filter by 2-letter ISO 639-1 language code."),minSentiment:e.number().min(-1).max(1).optional().describe("Minimum sentiment score between -1.0 (very negative) and 1.0 (very positive)."),maxSentiment:e.number().min(-1).max(1).optional().describe("Maximum sentiment score between -1.0 and 1.0."),earliestPublishDate:F.optional().describe("Filter for news published on or after this timestamp (YYYY-MM-DD HH:MM:SS or YYYY-MM-DD)."),latestPublishDate:F.optional().describe("Filter for news published on or before this timestamp (YYYY-MM-DD HH:MM:SS or YYYY-MM-DD)."),newsSources:e.string().optional().describe('Comma-separated list of up to 10 news sources (e.g., "bbc.co.uk,nytimes.com").'),authors:e.string().optional().describe("Comma-separated list of author names."),categories:e.string().optional().describe("Comma-separated categories (politics, sports, business, technology, entertainment, health, science, etc.)."),entities:e.string().optional().describe('Filter by semantic entities (e.g., "ORG:Tesla,PER:Elon Musk").'),locationFilter:e.string().optional().describe('Filter by geographic radius in the format "latitude,longitude,radius in km" (radius: 1-100).'),sort:e.string().optional().describe('Sort criteria, typically "publish-time".'),sortDirection:e.enum(["ASC","DESC"]).optional().describe('Sort direction: "ASC" or "DESC". Defaults to DESC for publish-time.'),offset:e.number().int().min(0).max(1e5).optional().describe("Number of results to skip for pagination."),number:e.number().int().min(1).max(100).optional().describe("Number of results to return (1-100). Defaults to 10.")}).refine(t=>t.text!==void 0||t.sourceCountry!==void 0||t.language!==void 0||t.minSentiment!==void 0||t.maxSentiment!==void 0||t.earliestPublishDate!==void 0||t.latestPublishDate!==void 0||t.newsSources!==void 0||t.authors!==void 0||t.categories!==void 0||t.entities!==void 0||t.locationFilter!==void 0,{message:"At least one search filter is required"}),W=e.object({top_news:e.array(e.object({news:e.array(M)})),language:e.string().optional(),country:e.string().optional()}),k=e.object({title:e.string().optional(),text:e.string().optional(),url:e.string().optional(),image:e.string().nullable().optional(),images:e.array(we).optional(),video:e.string().nullable().optional(),videos:e.array(me).optional(),publish_date:e.string().optional(),author:e.string().nullable().optional(),authors:e.array(e.string().nullable()).optional(),language:e.string().optional(),source_country:e.string().optional(),sentiment:e.number().optional(),entities:e.array(ge).optional()}),R=e.object({status:e.string().optional(),news_links:e.array(e.string())}),C=e.object({latitude:e.number(),longitude:e.number(),city:e.string().optional()}),T=e.object({title:e.string().optional(),link:e.string().optional(),description:e.string().optional(),pubDate:e.string().optional(),lastBuildDate:e.string().optional(),language:e.string().optional(),items:e.array(he),rawXml:e.string().optional()}),_=e.object({available:e.number(),sources:e.array(fe)}),O=e.object({offset:e.number(),number:e.number(),available:e.number(),news:e.array(M)}),w={"news.topNews":Ne,"news.extractNews":be,"news.extractNewsLinks":ye,"news.getGeoCoordinates":xe,"news.newsWebsiteToRssFeed":Ae,"news.searchNewsSources":Se,"news.searchNews":Ee},m={"news.topNews":W,"news.extractNews":k,"news.extractNewsLinks":R,"news.getGeoCoordinates":C,"news.newsWebsiteToRssFeed":T,"news.searchNewsSources":_,"news.searchNews":O};var G=async(t,n)=>{h(n.url);let o=f(n.url),s={url:n.url,analyze:n.analyze},i=await c("extract-news",t.key,{method:"GET",query:s},k);try{await t.db.extractedArticles.upsertByEntityId(o,{url:o,title:i.title,text:i.text,image:i.image,video:i.video,publish_date:i.publish_date,author:i.author,authors:i.authors,language:i.language,source_country:i.source_country,sentiment:i.sentiment,extractedAt:new Date})}catch{}return await We(t,"worldnewsapi.news.extractNews",{url:o,title:i.title},"completed"),i};import{logEventFromContext as ke}from"corsair/core";var q=async(t,n)=>{h(n.url);let o={url:n.url,analyze:n.analyze,prefix:n.prefix,"sub-domain":n.subDomain},s=await c("extract-news-links",t.key,{method:"GET",query:o},R);return await ke(t,"worldnewsapi.news.extractNewsLinks",{url:f(n.url),linksCount:s.news_links?.length??0},"completed"),s};import{logEventFromContext as Re}from"corsair/core";var z=async(t,n)=>{let o={location:n.location},s=await c("geo-coordinates",t.key,{method:"GET",query:o},C);try{await t.db.geoCoordinates.upsertByEntityId(n.location,{location:n.location,latitude:s.latitude,longitude:s.longitude,city:s.city,resolvedAt:new Date})}catch{}return await Re(t,"worldnewsapi.news.getGeoCoordinates",{location:n.location,latitude:s.latitude,longitude:s.longitude},"completed"),s};import{logEventFromContext as Ce}from"corsair/core";import{z as Te}from"zod";var U=async(t,n)=>{h(n.url);let o=f(n.url),s={url:n.url,"extract-news":n.extractNews},i=await c("feed.rss",t.key,{method:"GET",query:s},Te.string()),a=v(i),d=T.parse({title:a.title,link:a.link,description:a.description,pubDate:a.pubDate,lastBuildDate:a.lastBuildDate,language:a.language,items:a.items,rawXml:a.rawXml});return await Ce(t,"worldnewsapi.news.newsWebsiteToRssFeed",{url:o,itemsCount:d.items.length},"completed"),d};import{logEventFromContext as _e}from"corsair/core";var Y=async(t,n)=>{let o={text:n.text,"text-match-indexes":n.textMatchIndexes,"source-country":n.sourceCountry,language:n.language,"min-sentiment":n.minSentiment,"max-sentiment":n.maxSentiment,"earliest-publish-date":n.earliestPublishDate,"latest-publish-date":n.latestPublishDate,"news-sources":n.newsSources,authors:n.authors,categories:n.categories,entities:n.entities,"location-filter":n.locationFilter,sort:n.sort,"sort-direction":n.sortDirection,offset:n.offset,number:n.number},s=await c("search-news",t.key,{method:"GET",query:o},O);if(s.news&&Array.isArray(s.news))for(let i of s.news)try{await t.db.articles.upsertByEntityId(String(i.id),{...i,createdAt:new Date})}catch{}return await _e(t,"worldnewsapi.news.searchNews",{query:n.text,resultCount:s.news?.length??0,available:s.available},"completed"),s};import{logEventFromContext as Oe}from"corsair/core";var j=async(t,n)=>{let o={name:n.name},s=await c("search-news-sources",t.key,{method:"GET",query:o},_);if(s.sources&&Array.isArray(s.sources))for(let i of s.sources)try{await t.db.sources.upsertByEntityId(i.url||i.name,{...i,searchedAt:new Date})}catch{}return await Oe(t,"worldnewsapi.news.searchNewsSources",{name:n.name,availableCount:s.available},"completed"),s};import{logEventFromContext as De}from"corsair/core";var B=async(t,n)=>{let o={"source-country":n.sourceCountry,language:n.language,date:n.date,"headlines-only":n.headlinesOnly,"max-news-per-cluster":n.maxNewsPerCluster},s=await c("top-news",t.key,{method:"GET",query:o},W);if(s.top_news&&Array.isArray(s.top_news)){for(let i of s.top_news)if(i.news&&Array.isArray(i.news))for(let a of i.news)try{await t.db.articles.upsertByEntityId(String(a.id),{...a,createdAt:new Date})}catch{}}return await De(t,"worldnewsapi.news.topNews",{sourceCountry:n.sourceCountry,language:n.language,clustersCount:s.top_news?.length??0},"completed"),s};var g={topNews:B,extractNews:G,extractNewsLinks:q,getGeoCoordinates:z,newsWebsiteToRssFeed:U,searchNewsSources:j,searchNews:Y};import{ApiError as H}from"corsair/http";function N(t){if(t instanceof H||t instanceof u)return t.status}function b(t){return t instanceof Error?t.message.toLowerCase():""}function Ie(t){return t instanceof H?t.retryAfter:void 0}var $={RATE_LIMIT_ERROR:{match:(t,n)=>{if(N(t)===429)return!0;let o=b(t);return o.includes("rate_limit")||o.includes("ratelimit")||o.includes("429")||o.includes("too many requests")},handler:async(t,n)=>({maxRetries:5,headersRetryAfterMs:Ie(t)})},QUOTA_ERROR:{match:(t,n)=>{if(N(t)===402)return!0;let o=b(t);return o.includes("quota exceeded")||o.includes("payment required")},handler:async(t,n)=>({maxRetries:0})},AUTH_ERROR:{match:(t,n)=>{if(N(t)===401)return!0;let o=b(t);return o.includes("unauthorized")||o.includes("invalid api key")||o.includes("auth_missing")||o.includes("authentication failed")},handler:async(t,n)=>({maxRetries:0})},PERMISSION_ERROR:{match:(t,n)=>{if(N(t)===403)return!0;let o=b(t);return o.includes("forbidden")||o.includes("access denied")||o.includes("insufficient_permissions")},handler:async(t,n)=>({maxRetries:0})},NOT_FOUND_ERROR:{match:(t,n)=>{if(N(t)===404)return!0;let o=b(t);return o.includes("not found")||o.includes("404")},handler:async(t,n)=>({maxRetries:0})},BAD_REQUEST_ERROR:{match:(t,n)=>{if(N(t)===400)return!0;let o=b(t);return o.includes("bad request")||o.includes("invalid_url")||o.includes("malformed_url")||o.includes("invalid_protocol")||o.includes("ssrf_protected")},handler:async(t,n)=>({maxRetries:0})},DEFAULT:{match:(t,n)=>!0,handler:async(t,n)=>({maxRetries:0})}};import{z as r}from"zod";var K=r.object({id:r.number(),title:r.string(),text:r.string().optional(),summary:r.string().nullable().optional(),url:r.string(),image:r.string().nullable().optional(),video:r.string().nullable().optional(),publish_date:r.string().optional(),author:r.string().nullable().optional(),authors:r.array(r.string().nullable()).optional(),category:r.string().optional(),language:r.string().optional(),source_country:r.string().optional(),sentiment:r.number().optional(),createdAt:r.coerce.date().optional()}),X=r.object({url:r.string(),title:r.string().optional(),text:r.string().optional(),image:r.string().nullable().optional(),video:r.string().nullable().optional(),publish_date:r.string().optional(),author:r.string().nullable().optional(),authors:r.array(r.string().nullable()).optional(),language:r.string().optional(),source_country:r.string().optional(),sentiment:r.number().optional(),extractedAt:r.coerce.date().optional()}),V=r.object({location:r.string(),latitude:r.number(),longitude:r.number(),city:r.string().optional(),resolvedAt:r.coerce.date().optional()}),Q=r.object({name:r.string(),url:r.string(),language:r.string().optional(),country:r.string().optional(),searchedAt:r.coerce.date().optional()});var Z={version:"1.0.0",entities:{articles:K,extractedArticles:X,geoCoordinates:V,sources:Q}};var Le={news:{topNews:g.topNews,extractNews:g.extractNews,extractNewsLinks:g.extractNewsLinks,getGeoCoordinates:g.getGeoCoordinates,newsWebsiteToRssFeed:g.newsWebsiteToRssFeed,searchNewsSources:g.searchNewsSources,searchNews:g.searchNews}},ve={},Fe={"news.topNews":{input:w["news.topNews"],output:m["news.topNews"]},"news.extractNews":{input:w["news.extractNews"],output:m["news.extractNews"]},"news.extractNewsLinks":{input:w["news.extractNewsLinks"],output:m["news.extractNewsLinks"]},"news.getGeoCoordinates":{input:w["news.getGeoCoordinates"],output:m["news.getGeoCoordinates"]},"news.newsWebsiteToRssFeed":{input:w["news.newsWebsiteToRssFeed"],output:m["news.newsWebsiteToRssFeed"]},"news.searchNewsSources":{input:w["news.searchNewsSources"],output:m["news.searchNewsSources"]},"news.searchNews":{input:w["news.searchNews"],output:m["news.searchNews"]}},Me="api_key",Ge={"news.topNews":{riskLevel:"read",description:"Get the top news from a country in a specific language for a given date. The top news are clustered from multiple sources in the specified country."},"news.extractNews":{riskLevel:"read",description:"Extract a news article from a website to a well-structured JSON object, including title, text, images, videos, publish date, authors, language, and sentiment."},"news.extractNewsLinks":{riskLevel:"read",description:"Extract news article links from a website or webpage, with optional filtering by URL prefix and subdomain inclusion."},"news.getGeoCoordinates":{riskLevel:"read",description:"Retrieve latitude and longitude of a location name to fill the location-filter parameter in news search operations."},"news.newsWebsiteToRssFeed":{riskLevel:"read",description:"Convert any news website page into an RSS feed with the latest news from that page."},"news.searchNewsSources":{riskLevel:"read",description:"Search whether a news source is being monitored by the World News API."},"news.searchNews":{riskLevel:"read",description:"Search and filter news by text, date, location, category, language, and more."}},qe={api_key:{}};function Ut(t={}){let n={...t,authType:t.authType??Me};return{id:"worldnewsapi",authConfig:qe,schema:Z,options:n,hooks:n.hooks,endpoints:Le,webhooks:ve,endpointMeta:Ge,endpointSchemas:Fe,webhookSchemas:{},errorHandlers:{...$,...n.errorHandlers},keyBuilder:async(o,s)=>{if(s==="endpoint"&&n.key)return n.key;if(s==="endpoint"&&o.authType==="api_key"){let i=await o.keys.get_api_key();if(i)return i}throw new Pe("worldnewsapi","api_key")}}}export{Ut as worldNewsApi,qe as worldNewsApiAuthConfig,Fe as worldNewsApiEndpointSchemas};
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ /** Indexed article from GET /search-news or GET /top-news. Field names match the official JSON. */
3
+ export declare const WorldNewsArticle: z.ZodObject<{
4
+ id: z.ZodNumber;
5
+ title: z.ZodString;
6
+ text: z.ZodOptional<z.ZodString>;
7
+ summary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ url: z.ZodString;
9
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ publish_date: z.ZodOptional<z.ZodString>;
12
+ author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ authors: z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodString>>>;
14
+ category: z.ZodOptional<z.ZodString>;
15
+ language: z.ZodOptional<z.ZodString>;
16
+ source_country: z.ZodOptional<z.ZodString>;
17
+ sentiment: z.ZodOptional<z.ZodNumber>;
18
+ createdAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
19
+ }, z.core.$strip>;
20
+ /** Extracted article from GET /extract-news. Field names match ExtractNews200Response. */
21
+ export declare const WorldNewsExtractedArticle: z.ZodObject<{
22
+ url: z.ZodString;
23
+ title: z.ZodOptional<z.ZodString>;
24
+ text: z.ZodOptional<z.ZodString>;
25
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ publish_date: z.ZodOptional<z.ZodString>;
28
+ author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ authors: z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodString>>>;
30
+ language: z.ZodOptional<z.ZodString>;
31
+ source_country: z.ZodOptional<z.ZodString>;
32
+ sentiment: z.ZodOptional<z.ZodNumber>;
33
+ extractedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
34
+ }, z.core.$strip>;
35
+ /** Location from GET /geo-coordinates (latitude, longitude, city). */
36
+ export declare const WorldNewsGeoCoordinate: z.ZodObject<{
37
+ location: z.ZodString;
38
+ latitude: z.ZodNumber;
39
+ longitude: z.ZodNumber;
40
+ city: z.ZodOptional<z.ZodString>;
41
+ resolvedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
42
+ }, z.core.$strip>;
43
+ /** Source from GET /search-news-sources (url, name, language). */
44
+ export declare const WorldNewsSource: z.ZodObject<{
45
+ name: z.ZodString;
46
+ url: z.ZodString;
47
+ language: z.ZodOptional<z.ZodString>;
48
+ country: z.ZodOptional<z.ZodString>;
49
+ searchedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
50
+ }, z.core.$strip>;
51
+ export type WorldNewsArticle = z.infer<typeof WorldNewsArticle>;
52
+ export type WorldNewsExtractedArticle = z.infer<typeof WorldNewsExtractedArticle>;
53
+ export type WorldNewsGeoCoordinate = z.infer<typeof WorldNewsGeoCoordinate>;
54
+ export type WorldNewsSource = z.infer<typeof WorldNewsSource>;
55
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../schema/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,mGAAmG;AACnG,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;iBAiB3B,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;iBAapC,CAAC;AAEH,sEAAsE;AACtE,eAAO,MAAM,sBAAsB;;;;;;iBAMjC,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,eAAe;;;;;;iBAM1B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,yBAAyB,CAChC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ export declare const WorldNewsApiSchema: {
2
+ readonly version: "1.0.0";
3
+ readonly entities: {
4
+ readonly articles: import("zod").ZodObject<{
5
+ id: import("zod").ZodNumber;
6
+ title: import("zod").ZodString;
7
+ text: import("zod").ZodOptional<import("zod").ZodString>;
8
+ summary: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
9
+ url: import("zod").ZodString;
10
+ image: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
11
+ video: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
12
+ publish_date: import("zod").ZodOptional<import("zod").ZodString>;
13
+ author: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
14
+ authors: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNullable<import("zod").ZodString>>>;
15
+ category: import("zod").ZodOptional<import("zod").ZodString>;
16
+ language: import("zod").ZodOptional<import("zod").ZodString>;
17
+ source_country: import("zod").ZodOptional<import("zod").ZodString>;
18
+ sentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
19
+ createdAt: import("zod").ZodOptional<import("zod").ZodCoercedDate<unknown>>;
20
+ }, import("zod/v4/core").$strip>;
21
+ readonly extractedArticles: import("zod").ZodObject<{
22
+ url: import("zod").ZodString;
23
+ title: import("zod").ZodOptional<import("zod").ZodString>;
24
+ text: import("zod").ZodOptional<import("zod").ZodString>;
25
+ image: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
26
+ video: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
27
+ publish_date: import("zod").ZodOptional<import("zod").ZodString>;
28
+ author: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
29
+ authors: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodNullable<import("zod").ZodString>>>;
30
+ language: import("zod").ZodOptional<import("zod").ZodString>;
31
+ source_country: import("zod").ZodOptional<import("zod").ZodString>;
32
+ sentiment: import("zod").ZodOptional<import("zod").ZodNumber>;
33
+ extractedAt: import("zod").ZodOptional<import("zod").ZodCoercedDate<unknown>>;
34
+ }, import("zod/v4/core").$strip>;
35
+ readonly geoCoordinates: import("zod").ZodObject<{
36
+ location: import("zod").ZodString;
37
+ latitude: import("zod").ZodNumber;
38
+ longitude: import("zod").ZodNumber;
39
+ city: import("zod").ZodOptional<import("zod").ZodString>;
40
+ resolvedAt: import("zod").ZodOptional<import("zod").ZodCoercedDate<unknown>>;
41
+ }, import("zod/v4/core").$strip>;
42
+ readonly sources: import("zod").ZodObject<{
43
+ name: import("zod").ZodString;
44
+ url: import("zod").ZodString;
45
+ language: import("zod").ZodOptional<import("zod").ZodString>;
46
+ country: import("zod").ZodOptional<import("zod").ZodString>;
47
+ searchedAt: import("zod").ZodOptional<import("zod").ZodCoercedDate<unknown>>;
48
+ }, import("zod/v4/core").$strip>;
49
+ };
50
+ };
51
+ export * from './database';
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schema/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQrB,CAAC;AAEX,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../schema.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
2
+ export default _default;
3
+ //# sourceMappingURL=tsup.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBAYG"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@corsair-dev/worldnewsapi",
3
+ "version": "0.1.0",
4
+ "description": "WorldNewsApi plugin for Corsair",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "dev-source": "./index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "peerDependencies": {
17
+ "corsair": ">=0.1.0",
18
+ "zod": "^4.1.13"
19
+ },
20
+ "devDependencies": {
21
+ "@types/jest": "^29.5.14",
22
+ "jest": "^29.7.0",
23
+ "ts-jest": "^29.4.9",
24
+ "tsup": "^8.0.1",
25
+ "typescript": "^5.9.3",
26
+ "zod": "^4.1.13",
27
+ "corsair": "0.1.125"
28
+ },
29
+ "keywords": [
30
+ "corsair",
31
+ "worldnewsapi",
32
+ "plugin"
33
+ ],
34
+ "author": "",
35
+ "license": "Apache-2.0",
36
+ "files": [
37
+ "dist"
38
+ ],
39
+ "scripts": {
40
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc --build --force && tsup",
41
+ "typecheck": "tsc --noEmit",
42
+ "test": "jest"
43
+ }
44
+ }