Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
78 changes: 78 additions & 0 deletions components/arxiv/actions/search-articles/search-articles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import arxiv from "../../arxiv.app.mjs";
import fs from "fs";

export default {
key: "arxiv-search-articles",
name: "Search Articles",
description: "Search for articles on arXiv. [See the documentation](https://info.arxiv.org/help/api/user-manual.html#2-api-quickstart)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
arxiv,
searchQuery: {
type: "string",
label: "Search Query",
description: "The search query to use. Example: `all:electron`. [See the documentation](https://info.arxiv.org/help/api/user-manual.html#51-details-of-query-construction) for information on constructing a search query.",
optional: true,
},
idList: {
type: "string[]",
label: "ID List",
description: "A list of arXiv article IDs to search for",
optional: true,
},
start: {
type: "integer",
label: "Start",
description: "The index of the first result to return. Defaults to 0.",
optional: true,
},
maxResults: {
type: "integer",
label: "Max Results",
description: "The maximum number of results to return. Defaults to 10.",
optional: true,
},
filename: {
type: "string",
label: "Filename",
description: "A filename to save the result as an xml file to the /tmp directory. Example: `arxiv-search-results.xml`",
optional: true,
},
syncDir: {
type: "dir",
accessMode: "write",
sync: true,
},
},
async run({ $ }) {
const response = await this.arxiv.search({
$,
params: {
search_query: this.searchQuery,
id_list: this.idList,
start: this.start,
max_results: this.maxResults,
},
});

if (!this.filename) {
$.export("$summary", "Successfully searched for articles");
return response;
}

const filePath = `/tmp/${this.filename}`;
fs.writeFileSync(filePath, response, "utf8");

$.export("$summary", `Successfully saved search results to ${filePath}`);
return {
filePath,
fileContent: response,
};
},
};
21 changes: 18 additions & 3 deletions components/arxiv/arxiv.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "arxiv",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://export.arxiv.org/api";
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
...opts,
});
},
search(opts = {}) {
return this._makeRequest({
path: "/query",
...opts,
});
},
},
};
5 changes: 4 additions & 1 deletion components/arxiv/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/arxiv",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream arXiv Components",
"main": "arxiv.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
Loading
Loading