Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions components/trawlingweb/actions/search-news/search-news.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import trawlingweb from "../../trawlingweb.app.mjs";

export default {
key: "trawlingweb-search-news",
name: "Search News",
description: "Search for news based on the specified search parameters. [See the documentation](https://dashboard.trawlingweb.com/documentation)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
trawlingweb,
query: {
type: "string",
label: "Query",
description: "The search query",
},
dateStart: {
type: "string",
label: "Date Start",
description: "The start date of the search in ISO 8601 format (YYYY-MM-DD)",
optional: true,
},
dateEnd: {
type: "string",
label: "Date End",
description: "The end date of the search in ISO 8601 format (YYYY-MM-DD)",
optional: true,
},
sort: {
type: "string",
label: "Sort",
description: "Sort by publishing date or crawled date. Default: `crawled`",
options: [
"published",
"crawled",
],
optional: true,
},
order: {
type: "string",
label: "Order",
description: "Set up the order in ascending (from older news to newer) or descending (from newer news to older)",
options: [
"asc",
"desc",
],
optional: true,
},
maxResults: {
type: "integer",
label: "Max Results",
description: "The maximum number of results to return",
optional: true,
max: 100,
},
},
async run({ $ }) {
const { response: { data } } = await this.trawlingweb.searchNews({
$,
params: {
q: this.query,
ts: this.dateStart
? Date.parse(this.dateStart)
: undefined,
tsi: this.dateEnd
? Date.parse(this.dateEnd)
: undefined,
sort: this.sort === "published"
? "published"
: undefined,
order: this.order,
size: this.maxResults,
},
});

$.export("$summary", `Found ${data?.length} news resources`);

return data;
},
};
5 changes: 4 additions & 1 deletion components/trawlingweb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/trawlingweb",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Trawlingweb Components",
"main": "trawlingweb.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
24 changes: 21 additions & 3 deletions components/trawlingweb/trawlingweb.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "trawlingweb",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.trawlingweb.com";
},
_makeRequest({
$ = this, params = {}, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}`,
params: {
...params,
token: `${this.$auth.api_token}`,
},
...opts,
});
},
searchNews(opts = {}) {
return this._makeRequest({
...opts,
});
},
},
};
20 changes: 11 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading