Skip to content

Commit f88b9f6

Browse files
committed
Merge branch 'master' into google-drive-patch-2
2 parents 4c7467a + e51b8b1 commit f88b9f6

File tree

380 files changed

+14767
-1306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

380 files changed

+14767
-1306
lines changed
Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,76 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "_2markdown",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
filePath: {
8+
type: "string",
9+
label: "File Path",
10+
description: "The path to an HTML file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
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://api.2markdown.com/v1";
16+
},
17+
_makeRequest({
18+
$ = this,
19+
path,
20+
headers,
21+
...opts
22+
}) {
23+
return axios($, {
24+
url: `${this._baseUrl()}${path}`,
25+
headers: {
26+
...headers,
27+
"X-Api-Key": this.$auth.api_key,
28+
},
29+
...opts,
30+
});
31+
},
32+
getJobStatus({
33+
jobId, ...opts
34+
}) {
35+
return this._makeRequest({
36+
path: `/pdf2md/${jobId}`,
37+
...opts,
38+
});
39+
},
40+
pdfToMarkdown(opts = {}) {
41+
return this._makeRequest({
42+
method: "POST",
43+
path: "/pdf2md",
44+
...opts,
45+
});
46+
},
47+
urlToMarkdown(opts = {}) {
48+
return this._makeRequest({
49+
method: "POST",
50+
path: "/url2md",
51+
...opts,
52+
});
53+
},
54+
urlToMarkdownWithJs(opts = {}) {
55+
return this._makeRequest({
56+
method: "POST",
57+
path: "/url2mdjs",
58+
...opts,
59+
});
60+
},
61+
htmlFileToMarkdown(opts = {}) {
62+
return this._makeRequest({
63+
method: "POST",
64+
path: "/file2md",
65+
...opts,
66+
});
67+
},
68+
htmlToMarkdown(opts = {}) {
69+
return this._makeRequest({
70+
method: "POST",
71+
path: "/html2md",
72+
...opts,
73+
});
974
},
1075
},
1176
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import _2markdown from "../../_2markdown.app.mjs";
2+
import fs from "fs";
3+
import FormData from "form-data";
4+
5+
export default {
6+
key: "_2markdown-html-file-to-markdown",
7+
name: "HTML File to Markdown",
8+
description: "Convert an HTML file to Markdown format. [See the documentation](https://2markdown.com/docs#file2md)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
_2markdown,
13+
filePath: {
14+
propDefinition: [
15+
_2markdown,
16+
"filePath",
17+
],
18+
},
19+
},
20+
async run({ $ }) {
21+
const form = new FormData();
22+
23+
form.append("document", fs.createReadStream(this.filePath.includes("tmp/")
24+
? this.filePath
25+
: `/tmp/${this.filePath}`));
26+
27+
const response = await this._2markdown.htmlFileToMarkdown({
28+
$,
29+
headers: form.getHeaders(),
30+
data: form,
31+
});
32+
33+
$.export("$summary", "Successfully converted HTML file to markdown.");
34+
35+
return response;
36+
},
37+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import _2markdown from "../../_2markdown.app.mjs";
2+
3+
export default {
4+
key: "_2markdown-html-to-markdown",
5+
name: "HTML to Markdown",
6+
description: "Convert raw HTML content to Markdown format. [See the documentation](https://2markdown.com/docs#html2md)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
_2markdown,
11+
html: {
12+
type: "string",
13+
label: "HTML",
14+
description: "The HTML content to be converted to Markdown",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this._2markdown.htmlToMarkdown({
19+
$,
20+
data: {
21+
html: this.html,
22+
},
23+
});
24+
25+
$.export("$summary", "Successfully converted HTML to markdown.");
26+
27+
return response;
28+
},
29+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import _2markdown from "../../_2markdown.app.mjs";
2+
import fs from "fs";
3+
import FormData from "form-data";
4+
5+
export default {
6+
key: "_2markdown-pdf-to-markdown",
7+
name: "PDF to Markdown",
8+
description: "Convert a PDF document to Markdown format. [See the documentation](https://2markdown.com/docs#pdf2md)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
_2markdown,
13+
filePath: {
14+
propDefinition: [
15+
_2markdown,
16+
"filePath",
17+
],
18+
description: "The path to a PDF file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
19+
},
20+
waitForCompletion: {
21+
type: "boolean",
22+
label: "Wait for Completion",
23+
description: "Set to `true` to poll the API in 3-second intervals until the job is complete",
24+
optional: true,
25+
},
26+
},
27+
async run({ $ }) {
28+
const form = new FormData();
29+
30+
form.append("document", fs.createReadStream(this.filePath.includes("tmp/")
31+
? this.filePath
32+
: `/tmp/${this.filePath}`));
33+
34+
let response = await this._2markdown.pdfToMarkdown({
35+
$,
36+
headers: form.getHeaders(),
37+
data: form,
38+
});
39+
40+
if (this.waitForCompletion) {
41+
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
42+
const jobId = response.jobId;
43+
while (response.status === "processing" || response.status === "pending") {
44+
response = await this._2markdown.getJobStatus({
45+
$,
46+
jobId,
47+
});
48+
await timer(3000);
49+
}
50+
}
51+
52+
$.export("$summary", `${this.waitForCompletion
53+
? "Finished"
54+
: "Started"} converting PDF file to markdown.`);
55+
56+
return response;
57+
},
58+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import _2markdown from "../../_2markdown.app.mjs";
2+
3+
export default {
4+
key: "_2markdown-url-to-markdown",
5+
name: "URL to Markdown",
6+
description: "Extract the essential content of a website as plaintext. [See the documentation](https://2markdown.com/docs#url2md)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
_2markdown,
11+
url: {
12+
type: "string",
13+
label: "URL",
14+
description: "The URL to be processed. Costs 1 credit per request.",
15+
},
16+
js: {
17+
type: "boolean",
18+
label: "Include Javascript Support",
19+
description: "Set to `true` to extract content as plaintext including any javascript-rendered resources. Costs an additional credit per request.",
20+
optional: true,
21+
},
22+
},
23+
async run({ $ }) {
24+
const fn = this.js
25+
? this._2markdown.urlToMarkdownWithJs
26+
: this._2markdown.urlToMarkdown;
27+
28+
const response = await fn({
29+
$,
30+
data: {
31+
url: this.url,
32+
},
33+
});
34+
35+
$.export("$summary", "Successfully extracted website content.");
36+
37+
return response;
38+
},
39+
};

components/_2markdown/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/_2markdown",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream 2markdown Components",
55
"main": "_2markdown.app.mjs",
66
"keywords": [
@@ -11,5 +11,9 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3",
17+
"form-data": "^4.0.1"
1418
}
15-
}
19+
}

components/adobe_document_generation_api/adobe_document_generation_api.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import autodesk from "../../autodesk.app.mjs";
2+
3+
export default {
4+
key: "autodesk-create-folder",
5+
name: "Create Folder",
6+
description: "Creates a new folder in a project in Autodesk. [See the documentation](https://aps.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-folders-POST/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
autodesk,
11+
hubId: {
12+
propDefinition: [
13+
autodesk,
14+
"hubId",
15+
],
16+
},
17+
projectId: {
18+
propDefinition: [
19+
autodesk,
20+
"projectId",
21+
(c) => ({
22+
hubId: c.hubId,
23+
}),
24+
],
25+
},
26+
name: {
27+
type: "string",
28+
label: "Name",
29+
description: "The name of the new folder",
30+
},
31+
parent: {
32+
propDefinition: [
33+
autodesk,
34+
"folderId",
35+
(c) => ({
36+
hubId: c.hubId,
37+
projectId: c.projectId,
38+
}),
39+
],
40+
label: "Parent Folder ID",
41+
description: "The identifier of the parent folder",
42+
},
43+
type: {
44+
type: "string",
45+
label: "Extension Type",
46+
description: "The type of folder extension. For BIM 360 Docs folders, use `folders:autodesk.bim360:Folder`. For all other services, use `folders:autodesk.core:Folder`.",
47+
options: [
48+
{
49+
label: "BIM 360 Docs folders",
50+
value: "folders:autodesk.core:Folder",
51+
},
52+
{
53+
label: "Other folders",
54+
value: "folders:autodesk.bim360:Folder",
55+
},
56+
],
57+
default: "folders:autodesk.core:Folder",
58+
optional: true,
59+
},
60+
},
61+
async run({ $ }) {
62+
const response = await this.autodesk.createFolder({
63+
$,
64+
projectId: this.projectId,
65+
data: {
66+
jsonapi: {
67+
version: "1.0",
68+
},
69+
data: {
70+
type: "folders",
71+
attributes: {
72+
name: this.name,
73+
extension: {
74+
type: this.type,
75+
version: "1.0",
76+
},
77+
},
78+
relationships: {
79+
parent: {
80+
data: {
81+
type: "folders",
82+
id: this.parent,
83+
},
84+
},
85+
},
86+
},
87+
},
88+
});
89+
$.export("$summary", `Successfully created new folder: ${this.name}`);
90+
return response;
91+
},
92+
};

0 commit comments

Comments
 (0)