Skip to content

Commit f004dcb

Browse files
authored
New Components - rapid_url_indexer (#14424)
* new components * pnpm-lock.yaml * updates
1 parent c3173cb commit f004dcb

File tree

6 files changed

+164
-8
lines changed

6 files changed

+164
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import rapidUrlIndexer from "../../rapid_url_indexer.app.mjs";
2+
import fs from "fs";
3+
4+
export default {
5+
key: "rapid_url_indexer-download-project-report",
6+
name: "Download Project Report",
7+
description: "Download the report for a specific project. [See the documentation](https://rapidurlindexer.com/indexing-api/).",
8+
type: "action",
9+
version: "0.0.1",
10+
props: {
11+
rapidUrlIndexer,
12+
projectId: {
13+
propDefinition: [
14+
rapidUrlIndexer,
15+
"projectId",
16+
],
17+
},
18+
filename: {
19+
type: "string",
20+
label: "Filename",
21+
description: "A filename to save the report as in the `/tmp` directory. Include the `.csv` extension",
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.rapidUrlIndexer.downloadProjectReport({
26+
$,
27+
projectId: this.projectId,
28+
});
29+
30+
const filepath = this.filename.includes("/tmp")
31+
? this.filename
32+
: `/tmp/${this.filename}`;
33+
34+
fs.writeFileSync(filepath, response);
35+
36+
$.export("$summary", `Successfully downloaded report for Project with ID ${this.projectId}`);
37+
return filepath;
38+
},
39+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import rapidUrlIndexer from "../../rapid_url_indexer.app.mjs";
2+
3+
export default {
4+
key: "rapid_url_indexer-get-project-status",
5+
name: "Get Project Status",
6+
description: "Get the status of a specific project. [See the documentation](https://rapidurlindexer.com/indexing-api/).",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
rapidUrlIndexer,
11+
projectId: {
12+
propDefinition: [
13+
rapidUrlIndexer,
14+
"projectId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.rapidUrlIndexer.getProjectStatus({
20+
$,
21+
projectId: this.projectId,
22+
});
23+
if (response.id) {
24+
$.export("$summary", `Successfully retrieved status for Project with ID ${response.id}`);
25+
}
26+
return response;
27+
},
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import rapidUrlIndexer from "../../rapid_url_indexer.app.mjs";
2+
3+
export default {
4+
key: "rapid_url_indexer-submit-project",
5+
name: "Submit Project",
6+
description: "Submit a new project for indexing. [See the documentation](https://rapidurlindexer.com/indexing-api/).",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
rapidUrlIndexer,
11+
name: {
12+
type: "string",
13+
label: "Project Name",
14+
description: "The name of the project",
15+
},
16+
urls: {
17+
type: "string[]",
18+
label: "URLs",
19+
description: "An array of URLs to index. URLs must start with either “http://” or “https://”.",
20+
},
21+
notifyOnStatusChange: {
22+
type: "boolean",
23+
label: "Notify on Status Change",
24+
description: "If set to `true`, you will receive email notifications when the project status changes",
25+
optional: true,
26+
},
27+
},
28+
async run({ $ }) {
29+
const response = await this.rapidUrlIndexer.submitProject({
30+
$,
31+
data: {
32+
project_name: this.name,
33+
urls: this.urls,
34+
notify_on_status_change: this.notifyOnStatusChange,
35+
},
36+
});
37+
$.export("$summary", `${response.message}`);
38+
return response;
39+
},
40+
};

components/rapid_url_indexer/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/rapid_url_indexer",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Rapid URL Indexer Components",
55
"main": "rapid_url_indexer.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.0.3"
1417
}
15-
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "rapid_url_indexer",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
projectId: {
8+
type: "string",
9+
label: "Project ID",
10+
description: "The identifier of a project",
11+
},
12+
},
513
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
14+
_baseUrl() {
15+
return "https://rapidurlindexer.com/wp-json/api/v1";
16+
},
17+
_makeRequest({
18+
$ = this,
19+
path,
20+
...opts
21+
}) {
22+
return axios($, {
23+
url: `${this._baseUrl()}${path}`,
24+
headers: {
25+
"X-API-Key": `${this.$auth.api_key}`,
26+
},
27+
...opts,
28+
});
29+
},
30+
getProjectStatus({
31+
projectId, ...opts
32+
}) {
33+
return this._makeRequest({
34+
path: `/projects/${projectId}`,
35+
...opts,
36+
});
37+
},
38+
downloadProjectReport({
39+
projectId, ...opts
40+
}) {
41+
return this._makeRequest({
42+
path: `/projects/${projectId}/report`,
43+
...opts,
44+
});
45+
},
46+
submitProject(opts = {}) {
47+
return this._makeRequest({
48+
method: "POST",
49+
path: "/projects",
50+
...opts,
51+
});
952
},
1053
},
11-
};
54+
};

pnpm-lock.yaml

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)