Skip to content

Commit adb0b51

Browse files
committed
Added actions
1 parent 7e004ef commit adb0b51

File tree

5 files changed

+112
-6
lines changed

5 files changed

+112
-6
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../txt_werk.app.mjs";
2+
3+
export default {
4+
key: "txt_werk-analyze-text",
5+
name: "Analyze Text",
6+
description: "Send a text to be analyzed by TXTWerk. [See the documentation](https://services.txtwerk.de/ws/documentation/showRequest)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
text: {
12+
propDefinition: [
13+
app,
14+
"text",
15+
],
16+
},
17+
title: {
18+
propDefinition: [
19+
app,
20+
"title",
21+
],
22+
},
23+
services: {
24+
propDefinition: [
25+
app,
26+
"services",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.app.analyzeText({
32+
$,
33+
params: {
34+
text: this.text,
35+
title: this.title,
36+
services: this.services.join(","),
37+
},
38+
});
39+
40+
$.export("$summary", "Text successfully analyzed");
41+
42+
return response;
43+
},
44+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
SERVICES: [
3+
"entities",
4+
"tags",
5+
"categories",
6+
"dates",
7+
"measures",
8+
"authors",
9+
"fingerprints",
10+
"lexiconEntities",
11+
"lexiconTags",
12+
"nerEntities",
13+
],
14+
};

components/txt_werk/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.0"
1417
}
15-
}
18+
}
Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "txt_werk",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
text: {
9+
type: "string",
10+
label: "Text",
11+
description: "Text to be analyzed",
12+
},
13+
title: {
14+
type: "string",
15+
label: "Title",
16+
description: "Title of the document to be analyzed",
17+
},
18+
services: {
19+
type: "string[]",
20+
label: "Services",
21+
description: "List of services to request",
22+
options: constants.SERVICES,
23+
},
24+
},
525
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
26+
_baseUrl() {
27+
return "https://api.txtwerk.de/rest/txt";
28+
},
29+
async _makeRequest(opts = {}) {
30+
const {
31+
$ = this,
32+
path,
33+
headers,
34+
...otherOpts
35+
} = opts;
36+
return axios($, {
37+
...otherOpts,
38+
url: this._baseUrl() + path,
39+
headers: {
40+
...headers,
41+
"X-Api-Key": `${this.$auth.api_key}`,
42+
},
43+
});
44+
},
45+
async analyzeText(args = {}) {
46+
return this._makeRequest({
47+
method: "post",
48+
path: "/analyzer",
49+
...args,
50+
});
951
},
1052
},
1153
};

pnpm-lock.yaml

Lines changed: 4 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)