Skip to content

Commit 3d98934

Browse files
authored
Merging pull request #18887
* search-news action * pnpm-lock.yaml
1 parent 7c496c8 commit 3d98934

File tree

4 files changed

+114
-5
lines changed

4 files changed

+114
-5
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import trawlingweb from "../../trawlingweb.app.mjs";
2+
3+
export default {
4+
key: "trawlingweb-search-news",
5+
name: "Search News",
6+
description: "Search for news based on the specified search parameters. [See the documentation](https://dashboard.trawlingweb.com/documentation)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
trawlingweb,
16+
query: {
17+
type: "string",
18+
label: "Query",
19+
description: "The search query",
20+
},
21+
dateStart: {
22+
type: "string",
23+
label: "Date Start",
24+
description: "The start date of the search in ISO 8601 format (YYYY-MM-DD)",
25+
optional: true,
26+
},
27+
dateEnd: {
28+
type: "string",
29+
label: "Date End",
30+
description: "The end date of the search in ISO 8601 format (YYYY-MM-DD)",
31+
optional: true,
32+
},
33+
sort: {
34+
type: "string",
35+
label: "Sort",
36+
description: "Sort by publishing date or crawled date. Default: `crawled`",
37+
options: [
38+
"published",
39+
"crawled",
40+
],
41+
optional: true,
42+
},
43+
order: {
44+
type: "string",
45+
label: "Order",
46+
description: "Set up the order in ascending (from older news to newer) or descending (from newer news to older)",
47+
options: [
48+
"asc",
49+
"desc",
50+
],
51+
optional: true,
52+
},
53+
maxResults: {
54+
type: "integer",
55+
label: "Max Results",
56+
description: "The maximum number of results to return",
57+
optional: true,
58+
max: 100,
59+
},
60+
},
61+
async run({ $ }) {
62+
const { response: { data } } = await this.trawlingweb.searchNews({
63+
$,
64+
params: {
65+
q: this.query,
66+
ts: this.dateStart
67+
? Date.parse(this.dateStart)
68+
: undefined,
69+
tsi: this.dateEnd
70+
? Date.parse(this.dateEnd)
71+
: undefined,
72+
sort: this.sort === "published"
73+
? "published"
74+
: undefined,
75+
order: this.order,
76+
size: this.maxResults,
77+
},
78+
});
79+
80+
$.export("$summary", `Found ${data?.length} news resources`);
81+
82+
return data;
83+
},
84+
};

components/trawlingweb/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/trawlingweb",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Trawlingweb Components",
55
"main": "trawlingweb.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
1518
}
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "trawlingweb",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://api.trawlingweb.com";
10+
},
11+
_makeRequest({
12+
$ = this, params = {}, ...opts
13+
}) {
14+
return axios($, {
15+
url: `${this._baseUrl()}`,
16+
params: {
17+
...params,
18+
token: `${this.$auth.api_token}`,
19+
},
20+
...opts,
21+
});
22+
},
23+
searchNews(opts = {}) {
24+
return this._makeRequest({
25+
...opts,
26+
});
927
},
1028
},
1129
};

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)