Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
44 changes: 44 additions & 0 deletions components/txt_werk/actions/analyze-text/analyze-text.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import app from "../../txt_werk.app.mjs";

export default {
key: "txt_werk-analyze-text",
name: "Analyze Text",
description: "Send a text to be analyzed by TXTWerk. [See the documentation](https://services.txtwerk.de/ws/documentation/showRequest)",
version: "0.0.1",
type: "action",
props: {
app,
text: {
propDefinition: [
app,
"text",
],
},
title: {
propDefinition: [
app,
"title",
],
},
services: {
propDefinition: [
app,
"services",
],
},
},
async run({ $ }) {
const response = await this.app.analyzeText({
$,
params: {
text: this.text,
title: this.title,
services: this.services.join(","),
},
});

$.export("$summary", "Text successfully analyzed");

return response;
},
};
14 changes: 14 additions & 0 deletions components/txt_werk/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
SERVICES: [
"entities",
"tags",
"categories",
"dates",
"measures",
"authors",
"fingerprints",
"lexiconEntities",
"lexiconTags",
"nerEntities",
],
};
7 changes: 5 additions & 2 deletions components/txt_werk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/txt_werk",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream TXT Werk Components",
"main": "txt_werk.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}
51 changes: 47 additions & 4 deletions components/txt_werk/txt_werk.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "txt_werk",
propDefinitions: {},
propDefinitions: {
text: {
type: "string",
label: "Text",
description: "Text to be analyzed",
},
title: {
type: "string",
label: "Title",
description: "Title of the document to be analyzed",
optional: true,
},
services: {
type: "string[]",
label: "Services",
description: "List of services to request",
options: constants.SERVICES,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.txtwerk.de/rest/txt";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"X-Api-Key": `${this.$auth.api_key}`,
},
});
},
async analyzeText(args = {}) {
return this._makeRequest({
method: "post",
path: "/analyzer",
...args,
});
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.