diff --git a/components/tettra/.gitignore b/components/tettra/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/tettra/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/tettra/actions/create-page/create-page.mjs b/components/tettra/actions/create-page/create-page.mjs new file mode 100644 index 0000000000000..b0407a5b75aeb --- /dev/null +++ b/components/tettra/actions/create-page/create-page.mjs @@ -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; + }, +}; diff --git a/components/tettra/actions/suggest-page/suggest-page.mjs b/components/tettra/actions/suggest-page/suggest-page.mjs new file mode 100644 index 0000000000000..7232795825cd8 --- /dev/null +++ b/components/tettra/actions/suggest-page/suggest-page.mjs @@ -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; + }, +}; diff --git a/components/tettra/app/tettra.app.ts b/components/tettra/app/tettra.app.ts deleted file mode 100644 index 26e7cd1768867..0000000000000 --- a/components/tettra/app/tettra.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "tettra", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); \ No newline at end of file diff --git a/components/tettra/package.json b/components/tettra/package.json index 6f794d1412d43..faf812145a0de 100644 --- a/components/tettra/package.json +++ b/components/tettra/package.json @@ -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 (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/tettra/tettra.app.mjs b/components/tettra/tettra.app.mjs new file mode 100644 index 0000000000000..8fd702b8b8ff7 --- /dev/null +++ b/components/tettra/tettra.app.mjs @@ -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", + }); + }, + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f66157982da6d..d62ea60acdf70 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12565,8 +12565,7 @@ importers: components/smartymeet: {} - components/smashsend: - specifiers: {} + components/smashsend: {} components/smiirl: dependencies: @@ -13490,7 +13489,11 @@ importers: specifier: ^2.29.4 version: 2.30.1 - components/tettra: {} + components/tettra: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/textcortex: dependencies: @@ -15754,14 +15757,6 @@ importers: specifier: ^6.0.0 version: 6.2.0 - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/cjs: {} - - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/esm: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/cjs: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/esm: {} - packages/ai: dependencies: '@pipedream/sdk':