Skip to content

Commit 62446a1

Browse files
committed
docparser init
1 parent ab004e9 commit 62446a1

File tree

119 files changed

+19460
-4
lines changed

Some content is hidden

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

119 files changed

+19460
-4
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import docparser from "../../docparser.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "docparser-fetch-document-url",
6+
name: "Fetch Document by URL",
7+
description: "Fetches a document from a provided URL and imports it to Docparser for parsing. [See the documentation](https://docparser.com/api/)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
docparser,
12+
url: {
13+
propDefinition: [
14+
docparser,
15+
"url",
16+
],
17+
},
18+
parserId: {
19+
propDefinition: [
20+
docparser,
21+
"parserId",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.docparser.fetchDocumentFromURL({
27+
parserId: this.parserId,
28+
url: this.url,
29+
});
30+
31+
$.export("$summary", `Document is scheduled to be fetched and processed. Document ID: ${response.document_id}`);
32+
return response;
33+
},
34+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import docparser from "../../docparser.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "docparser-upload-document",
6+
name: "Upload Document",
7+
description: "Uploads a document to docparser that initiates parsing immediately after reception. [See the documentation](https://docparser.com/api/)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
docparser,
12+
parserId: {
13+
propDefinition: [
14+
docparser,
15+
"parserId",
16+
],
17+
},
18+
file: {
19+
propDefinition: [
20+
docparser,
21+
"file",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.docparser.uploadDocument({
27+
parserId: this.parserId,
28+
file: this.file,
29+
});
30+
31+
$.export("$summary", `Successfully uploaded document. Document ID: ${response.id}`);
32+
return response;
33+
},
34+
};
Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,83 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "docparser",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
url: {
8+
type: "string",
9+
label: "Document URL",
10+
description: "The URL of the document to be fetched and imported into Docparser.",
11+
},
12+
file: {
13+
type: "string",
14+
label: "File Content",
15+
description: "The content of the file to be uploaded, encoded in base64.",
16+
},
17+
parserId: {
18+
type: "string",
19+
label: "Parser ID",
20+
description: "The ID of the parser to be used.",
21+
async options() {
22+
const parsers = await this.listParsers();
23+
return parsers.map((parser) => ({
24+
label: parser.name,
25+
value: parser.id,
26+
}));
27+
},
28+
},
29+
},
530
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
31+
_baseUrl() {
32+
return "https://api.docparser.com";
33+
},
34+
async _makeRequest(opts = {}) {
35+
const {
36+
$ = this, method = "GET", path, headers, ...otherOpts
37+
} = opts;
38+
return axios($, {
39+
...otherOpts,
40+
method,
41+
url: this._baseUrl() + path,
42+
headers: {
43+
...headers,
44+
Authorization: `Bearer ${this.$auth.api_key}`,
45+
},
46+
});
47+
},
48+
async listParsers() {
49+
return this._makeRequest({
50+
path: "/v2/parsers",
51+
});
52+
},
53+
async fetchDocumentFromURL({
54+
parserId, url,
55+
}) {
56+
return this._makeRequest({
57+
method: "POST",
58+
path: `/v2/document/fetch/${parserId}`,
59+
data: {
60+
url,
61+
},
62+
});
63+
},
64+
async uploadDocument({
65+
parserId, file,
66+
}) {
67+
return this._makeRequest({
68+
method: "POST",
69+
path: `/v1/document/upload/${parserId}`,
70+
data: {
71+
file_content: file,
72+
},
73+
});
74+
},
75+
async pollParsedData() {
76+
// Implement logic to emit new events when parsed data is available
77+
},
78+
async pollParsedTableRows() {
79+
// Implement logic to emit new events when parsed table rows are available
980
},
1081
},
82+
version: "0.0.{{{ts}}}", // Ensure the version is set as per requirements
1183
};

components/docparser/node_modules/@pipedream/platform/.eslintignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/docparser/node_modules/@pipedream/platform/LICENSE

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/docparser/node_modules/@pipedream/platform/README.md

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)