diff --git a/components/upwave/.gitignore b/components/upwave/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/upwave/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/upwave/actions/create-card/create-card.mjs b/components/upwave/actions/create-card/create-card.mjs new file mode 100644 index 0000000000000..62a9026d03699 --- /dev/null +++ b/components/upwave/actions/create-card/create-card.mjs @@ -0,0 +1,52 @@ +import app from "../../upwave.app.mjs"; + +export default { + key: "upwave-create-card", + name: "Create Card", + description: "Create a new card. [See the documentation](https://upwavehq.github.io/api/#creating-a-new-card)", + version: "0.0.1", + type: "action", + props: { + app, + workspaceId: { + propDefinition: [ + app, + "workspaceId", + ], + }, + boardId: { + propDefinition: [ + app, + "boardId", + (c) => ({ + workspaceId: c.workspaceId, + }), + ], + }, + dueDt: { + propDefinition: [ + app, + "dueDt", + ], + }, + description: { + propDefinition: [ + app, + "description", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createCard({ + $, + workspaceId: this.workspaceId, + data: { + board: this.boardId, + due_dt: this.dueDt, + description: this.description, + }, + }); + $.export("$summary", "Successfully created card with ID: " + response.id); + return response; + }, +}; diff --git a/components/upwave/app/upwave.app.ts b/components/upwave/app/upwave.app.ts deleted file mode 100644 index 728e09f8ab155..0000000000000 --- a/components/upwave/app/upwave.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "upwave", - 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/upwave/package.json b/components/upwave/package.json index c62810a7fd52c..b5a63abfda954 100644 --- a/components/upwave/package.json +++ b/components/upwave/package.json @@ -1,13 +1,12 @@ { "name": "@pipedream/upwave", - "version": "0.0.2", + "version": "0.1.0", "description": "Pipedream Upwave Components", - "main": "dist/app/upwave.app.mjs", + "main": "upwave.app.mjs", "keywords": [ "pipedream", "upwave" ], - "files": ["dist"], "homepage": "https://pipedream.com/apps/upwave", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { diff --git a/components/upwave/upwave.app.mjs b/components/upwave/upwave.app.mjs new file mode 100644 index 0000000000000..3268ccaae152c --- /dev/null +++ b/components/upwave/upwave.app.mjs @@ -0,0 +1,124 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "upwave", + propDefinitions: { + workspaceId: { + type: "string", + label: "Workspace ID", + description: "Description for workspaceId", + async options({ + prevContext, page, + }) { + const params = prevContext?.next + ? { + page: page + 1, + } + : {}; + const { + results, next, + } = await this.getWorkspaces({ + params, + }); + return { + options: results.map(({ + title, id, + }) => ({ + label: title, + value: id, + })), + context: { + next, + }, + }; + }, + }, + boardId: { + type: "string", + label: "Board ID", + description: "Description for boardId", + async options({ + workspaceId, prevContext, page, + }) { + const params = prevContext?.next + ? { + page: page + 1, + } + : {}; + const { + results, next, + } = await this.getBoards({ + workspaceId, + params, + }); + return { + options: results.map(({ + title, id, + }) => ({ + label: title, + value: id, + })), + context: { + next, + }, + }; + }, + }, + dueDt: { + type: "string", + label: "Due Date", + description: "The due date of the card, i.e.: `2025-12-31`", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Description of the card", + }, + }, + methods: { + _baseUrl() { + return "https://api.upwave.io"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "Authorization": `Token ${this.$auth.api_key}`, + ...headers, + }, + }); + }, + async createCard({ + workspaceId, ...args + }) { + return this._makeRequest({ + path: `/workspaces/${workspaceId}/cards/`, + method: "post", + ...args, + }); + }, + async getWorkspaces(args = {}) { + return this._makeRequest({ + path: "/workspaces", + ...args, + }); + }, + async getBoards({ + workspaceId, ...args + }) { + return this._makeRequest({ + path: `/workspaces/${workspaceId}/boards`, + ...args, + }); + }, + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca86868b73242..37826898041cc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -962,8 +962,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/arlo: - specifiers: {} + components/arlo: {} components/aroflo: dependencies: @@ -5618,8 +5617,7 @@ importers: specifier: ^0.1.4 version: 0.1.6 - components/goqr_me: - specifiers: {} + components/goqr_me: {} components/gorgias: dependencies: