forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Actions & Sources] World news api (PipedreamHQ#5938)
* Remove TS setup * Search News * Extract News * Get Geo Coordinates * Source * Pipelines * Bad keys * CR * CR * Fix manual dedupe * Update action to use undefined if string is null * CR * Fix publish date and add new param to source * fix pagination loop * Fetch 20 news in the first execution * Update Max Value * Removing source because api is not ordering correctly * Remake source
- Loading branch information
Showing
13 changed files
with
1,782 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
components/world_news_api/actions/extract-news/extract-news.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import app from "../../world_news_api.app.mjs"; | ||
|
||
export default { | ||
name: "Extract News", | ||
description: "Extract a news article from a website to a well structure JSON object. [See the docs here](https://worldnewsapi.com/docs/#Extract-News). **Calling this endpoint requires 1 point, plus 2 points if analyze is true.**", | ||
key: "world_news_api-extract-news", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
url: { | ||
type: "string", | ||
label: "URL", | ||
description: "The URL of the news article to extract.", | ||
}, | ||
analyze: { | ||
type: "boolean", | ||
label: "Analyze", | ||
description: "Whether to analyze the news.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const params = { | ||
url: this.url, | ||
analyze: this.analyze, | ||
}; | ||
const res = await this.app.extractNews(params, $); | ||
$.export("$summary", res.title); | ||
return res; | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
components/world_news_api/actions/get-geo-coordinates/get-geo-coordinates.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import app from "../../world_news_api.app.mjs"; | ||
|
||
export default { | ||
name: "Get Geo Coordinates", | ||
description: "Retrieve the latitude and longitude of a location name. [See the docs here](https://worldnewsapi.com/docs/#Get-Geo-Coordinates). **Calling this endpoint requires 1 point.**", | ||
key: "world_news_api-get-geo-coordinates", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
location: { | ||
type: "string", | ||
label: "Location", | ||
description: "The address or name of the location.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const params = { | ||
location: this.location, | ||
}; | ||
const res = await this.app.getGeoCoordinates(params, $); | ||
$.export("$summary", `Geo coordinates for ${this.location} successfully retrieved`); | ||
return res; | ||
}, | ||
}; |
125 changes: 125 additions & 0 deletions
125
components/world_news_api/actions/search-news/search-news.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import app from "../../world_news_api.app.mjs"; | ||
import { getCommaSeparatedListFromArray } from "../../common/helpers.mjs"; | ||
|
||
export default { | ||
name: "Search News", | ||
description: "Search and filter news. [See the docs here](https://worldnewsapi.com/docs/#Search-News). **Calling this endpoint requires 1 point**", | ||
key: "world_news_api-search-news", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
text: { | ||
propDefinition: [ | ||
app, | ||
"text", | ||
], | ||
}, | ||
sourceCountries: { | ||
propDefinition: [ | ||
app, | ||
"sourceCountries", | ||
], | ||
}, | ||
language: { | ||
propDefinition: [ | ||
app, | ||
"language", | ||
], | ||
}, | ||
minSentiment: { | ||
propDefinition: [ | ||
app, | ||
"minSentiment", | ||
], | ||
}, | ||
maxSentiment: { | ||
propDefinition: [ | ||
app, | ||
"maxSentiment", | ||
], | ||
}, | ||
earliestPublishedDate: { | ||
propDefinition: [ | ||
app, | ||
"earliestPublishedDate", | ||
], | ||
}, | ||
latestPublishedDate: { | ||
propDefinition: [ | ||
app, | ||
"latestPublishedDate", | ||
], | ||
}, | ||
newsSources: { | ||
propDefinition: [ | ||
app, | ||
"newsSources", | ||
], | ||
}, | ||
authors: { | ||
propDefinition: [ | ||
app, | ||
"authors", | ||
], | ||
}, | ||
entities: { | ||
propDefinition: [ | ||
app, | ||
"entities", | ||
], | ||
}, | ||
locationFilter: { | ||
propDefinition: [ | ||
app, | ||
"locationFilter", | ||
], | ||
}, | ||
sort: { | ||
propDefinition: [ | ||
app, | ||
"sort", | ||
], | ||
}, | ||
sortDirection: { | ||
propDefinition: [ | ||
app, | ||
"sortDirection", | ||
], | ||
}, | ||
offset: { | ||
propDefinition: [ | ||
app, | ||
"offset", | ||
], | ||
}, | ||
number: { | ||
propDefinition: [ | ||
app, | ||
"number", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const params = { | ||
"text": this.text || undefined, | ||
"source-countries": getCommaSeparatedListFromArray(this.sourceCountries), | ||
"language": this.language || undefined, | ||
"min-sentiment": this.minSentiment || undefined, | ||
"max-sentiment": this.maxSentiment || undefined, | ||
"earliest-publish-date": this.earliestPublishedDate || undefined, | ||
"latest-publish-date": this.latestPublishedDate || undefined, | ||
"news-sources": getCommaSeparatedListFromArray(this.newsSources), | ||
"authors": getCommaSeparatedListFromArray(this.authors), | ||
"entities": getCommaSeparatedListFromArray(this.entities), | ||
"location-filter": this.locationFilter || undefined, | ||
"sort": this.sort || undefined, | ||
"sort-direction": this.sortDirection || undefined, | ||
"offset": this.offset || undefined, | ||
"number": this.number || undefined, | ||
}; | ||
const res = await this.app.searchNews(params, $); | ||
$.export("$summary", `Found ${res.available} news`); | ||
return res; | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.