-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - checkvist #14481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Components - checkvist #14481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import checkvist from "../../checkvist.app.mjs"; | ||
| import { STATUS_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "checkvist-create-list-item", | ||
| name: "Create List Item", | ||
| description: "Creates a new list item within a specified list. [See the documentation](https://checkvist.com/auth/api)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| checkvist, | ||
| listId: { | ||
| propDefinition: [ | ||
| checkvist, | ||
| "listId", | ||
| ], | ||
| }, | ||
| content: { | ||
| type: "string", | ||
| label: "Content", | ||
| description: "Block of text containing items to add. Indentations indicate nested list items.", | ||
| }, | ||
| parentId: { | ||
| propDefinition: [ | ||
| checkvist, | ||
| "parentId", | ||
| ({ listId }) => ({ | ||
| listId, | ||
| }), | ||
| ], | ||
| optional: true, | ||
| }, | ||
| tags: { | ||
| type: "string[]", | ||
| label: "Tags", | ||
| description: "An array of tags.", | ||
| optional: true, | ||
| }, | ||
| dueDate: { | ||
| type: "string", | ||
| label: "Due Date", | ||
| description: "Due for the task, in Checkvist's smart syntax format.", | ||
| optional: true, | ||
| }, | ||
| position: { | ||
| type: "integer", | ||
| label: "Position", | ||
| description: "1-based position of the task (omit to add to the end of the list).", | ||
| optional: true, | ||
| }, | ||
| status: { | ||
| type: "string", | ||
| label: "Status", | ||
| description: "Task status", | ||
| options: STATUS_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.checkvist.createListItem({ | ||
| $, | ||
| listId: this.listId, | ||
| data: { | ||
| task: { | ||
| content: this.content, | ||
| parent_id: this.parentId || 0, | ||
| tags: parseObject(this.tags)?.join(","), | ||
| due_date: this.dueDate, | ||
| position: this.position, | ||
| status: this.status, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created a new list item in list with ID ${this.listId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import checkvist from "../../checkvist.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SEPARATE_LINE_OPTIONS, STATUS_OPTIONS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "../../common/constants.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: "checkvist-create-multiple-list-items", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Create Multiple List Items", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Enables creation of several list items at once from a block of text. Indentations in the text indicate nested list items. [See the documentation](https://checkvist.com/auth/api)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkvist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| listId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkvist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "listId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| itemsContent: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Content Items", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "list items in the same format, as supported by [Checkvist's import function](https://checkvist.com/help#import).", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parentId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkvist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "parentId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ({ listId }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| listId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| position: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Position", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "1-based position of the task (omit to add to the end of the list).", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parseTasks: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Parse Tasks", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "If true, recognize **^due** and **#tags** syntax in imported list items", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| separateWithEmptyLine: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Separate With Empty Line", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Select value for List items separator.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options: SEPARATE_LINE_OPTIONS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Status", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Task status", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options: STATUS_OPTIONS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.checkvist.createMultipleListItems({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| listId: this.listId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import_content: this.itemsContent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parent_id: this.parentId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| position: this.position, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parse_tasks: this.parseTasks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| separate_with_empty_line: this.separateWithEmptyLine, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: this.status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", "Successfully created multiple list items"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+60
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance error handling and response details. The run method implementation could benefit from:
Consider applying these improvements: async run({ $ }) {
+ if (!this.itemsContent.trim()) {
+ throw new Error("Content Items cannot be empty");
+ }
+
+ try {
const response = await this.checkvist.createMultipleListItems({
$,
listId: this.listId,
data: {
import_content: this.itemsContent,
parent_id: this.parentId,
position: this.position,
parse_tasks: this.parseTasks,
separate_with_empty_line: this.separateWithEmptyLine,
status: this.status,
},
});
- $.export("$summary", "Successfully created multiple list items");
+ const itemCount = response.length;
+ $.export("$summary", `Successfully created ${itemCount} list item${itemCount === 1 ? "" : "s"}`);
return response;
+ } catch (error) {
+ throw new Error(`Failed to create list items: ${error.message}`);
+ }
},📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import checkvist from "../../checkvist.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: "checkvist-create-new-list", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Create New List", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Creates a new list in Checkvist. [See the documentation](https://checkvist.com/auth/api)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkvist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "List Name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Name of the new list to be created", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "boolean", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Public", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "true for checklist which can be accessed in read-only mode by anyone. Access to such checklists doesn't require authentication.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.checkvist.createList({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: this.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public: this.public, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", `Successfully created a new list: ${this.name}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling and input sanitization. The current implementation should handle potential API errors and sanitize inputs before sending to the API. Consider implementing these improvements: async run({ $ }) {
+ // Sanitize inputs
+ const name = this.name.trim();
+
+ // Validate required fields
+ if (!name) {
+ throw new Error("List name cannot be empty");
+ }
+
+ try {
const response = await this.checkvist.createList({
$,
data: {
- name: this.name,
+ name,
public: this.public,
},
});
$.export("$summary", `Successfully created a new list: ${this.name}`);
return response;
+ } catch (error) {
+ throw new Error(`Failed to create list: ${error.message}`);
+ }
},📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,101 @@ | ||||||||||||||||||||
| import { axios } from "@pipedream/platform"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export default { | ||||||||||||||||||||
| type: "app", | ||||||||||||||||||||
| app: "checkvist", | ||||||||||||||||||||
| propDefinitions: {}, | ||||||||||||||||||||
| propDefinitions: { | ||||||||||||||||||||
| listId: { | ||||||||||||||||||||
| type: "string", | ||||||||||||||||||||
| label: "List ID", | ||||||||||||||||||||
| description: "Select a list to monitor for new items", | ||||||||||||||||||||
| async options() { | ||||||||||||||||||||
| const lists = await this.getLists({ | ||||||||||||||||||||
| params: { | ||||||||||||||||||||
| skip_stats: true, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| return lists.map(({ | ||||||||||||||||||||
| id: value, name: label, | ||||||||||||||||||||
| }) => ({ | ||||||||||||||||||||
| label, | ||||||||||||||||||||
| value, | ||||||||||||||||||||
| })); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| parentId: { | ||||||||||||||||||||
| type: "string", | ||||||||||||||||||||
| label: "Parent task ID", | ||||||||||||||||||||
| description: "Empty for root-level tasks", | ||||||||||||||||||||
| async options({ listId }) { | ||||||||||||||||||||
| const items = await this.getListItems({ | ||||||||||||||||||||
| listId, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
Comment on lines
+30
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle empty In the Here's how you might adjust the code: async options({ listId }) {
+ if (!listId) {
+ return [];
+ }
const items = await this.getListItems({
listId,
});📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
| return items.map(({ | ||||||||||||||||||||
| id: value, content: label, | ||||||||||||||||||||
| }) => ({ | ||||||||||||||||||||
| label, | ||||||||||||||||||||
| value, | ||||||||||||||||||||
| })); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| methods: { | ||||||||||||||||||||
| // this.$auth contains connected account data | ||||||||||||||||||||
| authKeys() { | ||||||||||||||||||||
| console.log(Object.keys(this.$auth)); | ||||||||||||||||||||
| _baseUrl() { | ||||||||||||||||||||
| return "https://checkvist.com"; | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| _auth() { | ||||||||||||||||||||
| return { | ||||||||||||||||||||
| username: `${this.$auth.username}`, | ||||||||||||||||||||
| password: `${this.$auth.api_key}`, | ||||||||||||||||||||
|
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Simplify property assignments in the In the Here's the suggested change: return {
- username: `${this.$auth.username}`,
- password: `${this.$auth.api_key}`,
+ username: this.$auth.username,
+ password: this.$auth.api_key,
};📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
| }; | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| _makeRequest({ | ||||||||||||||||||||
| $ = this, path, ...opts | ||||||||||||||||||||
| }) { | ||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| return axios($, { | ||||||||||||||||||||
| url: this._baseUrl() + path, | ||||||||||||||||||||
| auth: this._auth(), | ||||||||||||||||||||
| ...opts, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| getLists(opts = {}) { | ||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||
| path: "/checklists.json", | ||||||||||||||||||||
| ...opts, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| getListItems({ | ||||||||||||||||||||
| listId, ...opts | ||||||||||||||||||||
| }) { | ||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||
| path: `/checklists/${listId}/tasks.json`, | ||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| ...opts, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| createList(opts = {}) { | ||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||
| path: "/checklists.json", | ||||||||||||||||||||
| ...opts, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| createListItem({ | ||||||||||||||||||||
| listId, ...opts | ||||||||||||||||||||
| }) { | ||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||
| path: `/checklists/${listId}/tasks.json`, | ||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| ...opts, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| createMultipleListItems({ | ||||||||||||||||||||
| listId, ...opts | ||||||||||||||||||||
| }) { | ||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||
| path: `/checklists/${listId}/import.json`, | ||||||||||||||||||||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
| ...opts, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| export const STATUS_OPTIONS = [ | ||
| { | ||
| label: "Open", | ||
| value: "0", | ||
| }, | ||
| { | ||
| label: "Closed", | ||
| value: "1", | ||
| }, | ||
| { | ||
| label: "Invalidated", | ||
| value: "2", | ||
| }, | ||
| ]; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const SEPARATE_LINE_OPTIONS = [ | ||
| { | ||
| label: "Separate with empty line", | ||
| value: "singleItem", | ||
| }, | ||
| { | ||
| label: "One item per line", | ||
| value: "multipleItems", | ||
| }, | ||
| ]; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return obj; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "@pipedream/checkvist", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Checkvist Components", | ||
| "main": "checkvist.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "checkvist" | ||
| ], | ||
| "homepage": "https://pipedream.com/apps/checkvist", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling and input validation.
The current implementation could benefit from better error handling and input validation:
Consider applying these improvements:
async run({ $ }) { + if (!this.content?.trim()) { + throw new Error("Content cannot be empty"); + } + + const tags = this.tags ? parseObject(this.tags) : undefined; + if (this.tags && !tags) { + throw new Error("Invalid tags format"); + } + const response = await this.checkvist.createListItem({ $, listId: this.listId, data: { task: { content: this.content, parent_id: this.parentId || 0, - tags: parseObject(this.tags)?.join(","), + tags: tags?.join(","), due_date: this.dueDate, position: this.position, status: this.status, }, }, }); $.export("$summary", `Successfully created a new list item in list with ID ${this.listId}`); return response; },📝 Committable suggestion