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
3 changes: 0 additions & 3 deletions components/tettra/.gitignore

This file was deleted.

51 changes: 51 additions & 0 deletions components/tettra/actions/create-page/create-page.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import tettra from "../../tettra.app.mjs";

export default {
key: "tettra-create-page",
name: "Create Page",
description: "Creates a new page in Tettra. [See the documentation](https://support.tettra.co/api-overview/api-endpoint-create-page)",
version: "0.0.1",
type: "action",
props: {
tettra,
title: {
type: "string",
label: "Title",
description: "The title of the page",
},
body: {
type: "string",
label: "Body",
description: "The body of the page formatted as HTML",
},
categoryId: {
propDefinition: [
tettra,
"categoryId",
],
},
subcategoryId: {
propDefinition: [
tettra,
"subcategoryId",
({ categoryId }) => ({
categoryId,
}),
],
},
},
async run({ $ }) {
const response = await this.tettra.createPage({
$,
data: {
title: this.title,
body: this.body,
category_id: this.categoryId,
subcategory_id: this.subcategoryId,
},
});

$.export("$summary", `Successfully created page "${this.title}"`);
return response;
},
};
51 changes: 51 additions & 0 deletions components/tettra/actions/suggest-page/suggest-page.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import tettra from "../../tettra.app.mjs";

export default {
key: "tettra-suggest-page",
name: "Suggest Page",
description: "Creates a new page suggestion in Tettra. [See the documentation](https://support.tettra.co/api-overview/api-endpoint-suggest-a-new-page)",
version: "0.0.1",
type: "action",
props: {
tettra,
title: {
type: "string",
label: "Title",
description: "Title of the page suggestion",
},
description: {
type: "string",
label: "Description",
description: "More context about the suggested page",
optional: true,
},
category: {
propDefinition: [
tettra,
"categoryId",
],
},
assignableId: {
propDefinition: [
tettra,
"userId",
],
label: "Assignable ID",
description: "Select a user to assign the suggestion, or provide a user ID",
},
},
async run({ $ }) {
const response = await this.tettra.suggestPage({
$,
data: {
title: this.title,
description: this.description,
category: this.category,
assignable_id: this.assignableId,
},
});

$.export("$summary", `Successfully created page suggestion "${this.title}"`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/tettra/app/tettra.app.ts

This file was deleted.

8 changes: 5 additions & 3 deletions components/tettra/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@pipedream/tettra",
"version": "0.0.2",
"version": "0.1.0",
"description": "Pipedream Tettra Components",
"main": "dist/app/tettra.app.mjs",
"main": "tettra.app.mjs",
"keywords": [
"pipedream",
"tettra"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/tettra",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
96 changes: 96 additions & 0 deletions components/tettra/tettra.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "tettra",
propDefinitions: {
categoryId: {
type: "string",
label: "Category ID",
description: "Select a category or provide a category ID",
optional: true,
async options() {
const { categories } = await this.getCategories();
return categories.map((category) => ({
label: category.name,
value: category.id,
}));
},
},
subcategoryId: {
type: "string",
label: "Subcategory ID",
description: "Select a subcategory or provide a subcategory ID",
optional: true,
async options({ categoryId }) {
const { categoryItems } = await this.getCategory(categoryId);
return categoryItems.filter((item) => item.type === "Subcategory").map((item) => ({
label: item.title,
value: item.id,
}));
},
},
userId: {
type: "string",
label: "User ID",
description: "Select a user or provide a user ID",
optional: true,
async options() {
const { users } = await this.getUsers();
return users.map((user) => ({
label: user.display_name ?? user.email,
value: user.id,
}));
},
},
},
methods: {
async _makeRequest({
$ = this,
data,
...args
}) {
const response = await axios($, {
baseURL: `https://app.tettra.co/api/teams/${this.$auth.team_id}`,
headers: {
"Content-Type": "application/json",
},
data: {
...data,
api_key: this.$auth.api_key,
},
...args,
});
return response;
},
async createPage(args) {
return this._makeRequest({
url: "/pages",
method: "POST",
...args,
});
},
async suggestPage(args) {
return this._makeRequest({
url: "/suggestions",
method: "POST",
...args,
});
},
async getCategories() {
return this._makeRequest({
url: "/categories",
});
},
async getCategory(categoryId) {
return this._makeRequest({
url: `/categories/${categoryId}`,
});
},
async getUsers() {
return this._makeRequest({
url: "/users",
});
},
},
};
17 changes: 6 additions & 11 deletions pnpm-lock.yaml

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

Loading