-
Notifications
You must be signed in to change notification settings - Fork 5.5k
accident #16448
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
accident #16448
Conversation
|
@SokolovskyiK is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
WalkthroughThis update introduces several new action modules and utility scripts for integrating with the Freshdesk API. The changes add actions to assign tickets to agents or groups, close tickets, set ticket priority or status, and update ticket attributes. Additionally, scripts are included for creating groups, creating tickets, and fetching group IDs from Freshdesk. Each action defines its own properties, leverages Freshdesk’s API endpoints, and returns a summary message along with the API response. The modules collectively enhance the ability to programmatically manage Freshdesk tickets and related entities. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ActionModule
participant FreshdeskAPI
User->>ActionModule: Provide ticket and update details
ActionModule->>FreshdeskAPI: Send PUT/POST request with update data
FreshdeskAPI-->>ActionModule: Return API response
ActionModule-->>User: Return summary and response
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/freshdesk/actions/close-ticket/close-ticket.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
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.
Actionable comments posted: 15
🧹 Nitpick comments (13)
components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs (2)
1-1: Update formatting for dynamic importThe dynamic import pattern has formatting issues that should be fixed to maintain consistent code style.
-const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); +const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));🧰 Tools
🪛 GitHub Check: Lint Code Base
[failure] 1-1:
Strings must use doublequote
[failure] 1-1:
A space is required after '{'
[failure] 1-1:
A space is required before '}'
27-27: Add newline at end of fileAdd a newline at the end of the file to comply with common coding standards.
createGroup(); +🧰 Tools
🪛 GitHub Check: Lint Code Base
[failure] 27-27:
Newline required at end of file but not foundcomponents/freshdesk/actions/freshdesk-update-ticket/get-group-id.mjs (2)
1-1: Update formatting for dynamic importThe dynamic import pattern has formatting issues that should be fixed to maintain consistent code style.
-const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); +const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));
28-28: Add newline at end of fileAdd a newline at the end of the file to comply with common coding standards.
getGroups(); +components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs (1)
43-43: Add newline at end of fileAdd a newline at the end of the file to comply with common coding standards.
createTicket(); +components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs (1)
35-35: Add newline at end of fileAdd a newline at the end of the file to comply with common coding standards.
}; +🧰 Tools
🪛 GitHub Check: Lint Code Base
[failure] 35-35:
Newline required at end of file but not foundcomponents/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs (2)
6-7: Add documentation link for consistencyFor consistency with other actions (like close-ticket), consider adding a link to the Freshdesk API documentation.
- description: "Assign a Freshdesk ticket to a specific agent", + description: "Assign a Freshdesk ticket to a specific agent. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
23-34: Consider adding error handlingThe action doesn't include any explicit error handling. While errors might be handled by the
_makeRequesthelper, it would be good to add specific error handling for clarity.Consider adding try/catch for better error handling:
async run({ $ }) { + try { const response = await this.freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${this.ticketId}`, data: { responder_id: this.responder_id, }, }); $.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`); return response; + } catch (error) { + $.export("$summary", `Failed to assign ticket ${this.ticketId} to agent ${this.responder_id}: ${error.message}`); + throw error; + } },components/freshdesk/actions/close-ticket/close-ticket.mjs (1)
18-32: Consider adding error handlingThe action doesn't include any explicit error handling. While errors might be handled by the
_makeRequesthelper, it would be good to add specific error handling for clarity.Consider adding try/catch for better error handling:
async run({ $ }) { const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed' + try { const response = await this.freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${this.ticketId}`, data: { status: CLOSED_STATUS, }, }); $.export("$summary", `Ticket ${this.ticketId} closed successfully`); return response; + } catch (error) { + $.export("$summary", `Failed to close ticket ${this.ticketId}: ${error.message}`); + throw error; + } },components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (2)
6-7: Add documentation link for consistencyFor consistency with the close-ticket action, consider adding a link to the Freshdesk API documentation.
- description: "Update the priority of a ticket in Freshdesk", + description: "Update the priority of a ticket in Freshdesk. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
24-35: Consider adding error handlingThe action doesn't include any explicit error handling. While errors might be handled by the
_makeRequesthelper, it would be good to add specific error handling for clarity.Consider adding try/catch for better error handling:
async run({ $ }) { + try { const response = await this.freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${this.ticketId}`, data: { priority: this.ticketPriority, }, }); $.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`); return response; + } catch (error) { + $.export("$summary", `Failed to update priority for ticket ${this.ticketId}: ${error.message}`); + throw error; + } },components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs (2)
6-7: Add documentation link for consistencyFor consistency with the close-ticket action, consider adding a link to the Freshdesk API documentation.
- description: "Update the status of a ticket in Freshdesk", + description: "Update the status of a ticket in Freshdesk. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
24-35: Consider adding error handlingThe action doesn't include any explicit error handling. While errors might be handled by the
_makeRequesthelper, it would be good to add specific error handling for clarity.Consider adding try/catch for better error handling:
async run({ $ }) { + try { const response = await this.freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${this.ticketId}`, data: { status: this.ticketStatus, }, }); $.export("$summary", `Ticket ${this.ticketId} status updated to ${this.ticketStatus}`); return response; + } catch (error) { + $.export("$summary", `Failed to update status for ticket ${this.ticketId}: ${error.message}`); + throw error; + } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs(1 hunks)components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs(1 hunks)components/freshdesk/actions/close-ticket/close-ticket.mjs(1 hunks)components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs(1 hunks)components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs(1 hunks)components/freshdesk/actions/freshdesk-update-ticket/freshdesk-update-ticket.mjs(1 hunks)components/freshdesk/actions/freshdesk-update-ticket/get-group-id.mjs(1 hunks)components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs(1 hunks)components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs(1 hunks)components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs(1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs
[failure] 1-1:
Strings must use doublequote
[failure] 1-1:
A space is required after '{'
[failure] 1-1:
A space is required before '}'
[failure] 27-27:
Newline required at end of file but not found
components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs
[failure] 14-14:
A linebreak is required after '['
[failure] 14-14:
There should be a linebreak after this element
[failure] 14-14:
There should be a linebreak after this element
[failure] 14-14:
A linebreak is required before ']'
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs
[failure] 35-35:
Newline required at end of file but not found
components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs
[failure] 35-35:
Newline required at end of file but not found
🪛 GitHub Actions: Pull Request Checks
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs
[error] 35-35: ESLint: Newline required at end of file but not found (eol-last)
🪛 Biome (1.9.4)
components/freshdesk/actions/freshdesk-update-ticket/freshdesk-update-ticket.mjs
[error] 44-49: This property value named type is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type
(lint/suspicious/noDuplicateObjectKeys)
components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs
[error] 44-49: This property value named type is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type
(lint/suspicious/noDuplicateObjectKeys)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (7)
components/freshdesk/actions/close-ticket/close-ticket.mjs (2)
6-7: Good documentation with API linkThe description includes a link to the Freshdesk API documentation, which is great for users who need more information.
19-19: Good use of constant with explanatory commentUsing a named constant with a comment for the status code is a good practice that makes the code more maintainable and easier to understand.
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (1)
1-36: Overall implementation looks goodThe implementation follows the same pattern as the other Freshdesk actions and correctly updates the ticket priority.
components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs (1)
1-36: Overall implementation looks goodThe implementation follows the same pattern as the other Freshdesk actions and correctly updates the ticket status. This provides a more general version of the close-ticket action, allowing any status to be set.
components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs (3)
5-6: LGTM: Clear action name and keyThe action key and name clearly communicate the purpose of this component, which is important for discoverability.
100-146: LGTM: Well-structured run method with proper validationThe run method efficiently extracts properties, removes null entries, validates input requirements, and handles the API request appropriately.
1-147:✅ Verification successful
Consider consistent naming convention for property names
Some properties use camelCase (ticketStatus, ticketPriority), while others use snake_case (group_id, responder_id). Although this likely mirrors Freshdesk's API naming, it might be confusing for users.
Consider whether this mixed naming is aligned with how Freshdesk returns these properties in responses, and with other components in your codebase.
🏁 Script executed:
#!/bin/bash # Check how other Freshdesk components handle property naming fd -e mjs -e js --exec grep -l "group_id\|responder_id" {} \; --exec echo "File: {}" \; --exec grep -A 5 -B 5 "group_id\|responder_id" {} \; components/freshdesk/Length of output: 561
🏁 Script executed:
#!/bin/bash # Search for snake_case and camelCase prop names across Freshdesk components echo "Searching for group_id and responder_id..." rg -n -e "group_id" -e "responder_id" components/freshdesk echo "" echo "Searching for ticketStatus and ticketPriority..." rg -n -e "ticketStatus" -e "ticketPriority" components/freshdeskLength of output: 5411
Naming Convention Aligns with API and Is Consistently Applied
We intentionally use camelCase for local props (
ticketStatus,ticketPriority) that map to the API’s genericstatusandpriorityfields, and snake_case for props that directly mirror Freshdesk’s snake_case API fields (group_id,responder_id,custom_fields). This pattern is already applied uniformly across all Freshdesk action components:
ticketStatus/ticketPrioritydefined infreshdesk.app.mjsand used in all actions, mapping to API’sstatus/priority.group_id/responder_idused inupdate-ticket,assign-ticket-to-group,assign-ticket-to-agent, andcreate-ticket, matching the API’s field names.No changes needed.
🧰 Tools
🪛 Biome (1.9.4)
[error] 44-49: This property value named type is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type(lint/suspicious/noDuplicateObjectKeys)
| // 🔧 Replace these with your real values | ||
| const API_KEY = "YfaK2hd0KP3og3KbqV"; | ||
| const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com |
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.
Remove hardcoded API credentials
The script contains what appears to be a real API key and domain. Hardcoding credentials in source code is a security risk even in test scripts.
-// 🔧 Replace these with your real values
-const API_KEY = "YfaK2hd0KP3og3KbqV";
-const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
+// 🔧 Replace these with your real values
+const API_KEY = "your_api_key";
+const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // 🔧 Replace these with your real values | |
| const API_KEY = "YfaK2hd0KP3og3KbqV"; | |
| const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com | |
| // 🔧 Replace these with your real values | |
| const API_KEY = "your_api_key"; | |
| const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com |
| const createGroup = async () => { | ||
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | ||
| method: "POST", | ||
| headers: { | ||
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | ||
| "Content-Type": "application/json", | ||
| }, | ||
| body: JSON.stringify({ | ||
| name: "My Team", | ||
| }), | ||
| }); | ||
|
|
||
| const data = await res.json(); | ||
| if (!res.ok) { | ||
| console.error("❌ Group create error:", data); | ||
| return; | ||
| } | ||
| console.log("✅ Group created:", data); | ||
| }; |
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.
🛠️ Refactor suggestion
Add error handling for network failures
The function handles API error responses but not network errors. Add try/catch to handle potential network failures.
const createGroup = async () => {
+ try {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My Team",
}),
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Group create error:", data);
return;
}
console.log("✅ Group created:", data);
+ } catch (error) {
+ console.error("❌ Network error:", error.message);
+ }
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const createGroup = async () => { | |
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | |
| method: "POST", | |
| headers: { | |
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | |
| "Content-Type": "application/json", | |
| }, | |
| body: JSON.stringify({ | |
| name: "My Team", | |
| }), | |
| }); | |
| const data = await res.json(); | |
| if (!res.ok) { | |
| console.error("❌ Group create error:", data); | |
| return; | |
| } | |
| console.log("✅ Group created:", data); | |
| }; | |
| const createGroup = async () => { | |
| try { | |
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | |
| method: "POST", | |
| headers: { | |
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | |
| "Content-Type": "application/json", | |
| }, | |
| body: JSON.stringify({ | |
| name: "My Team", | |
| }), | |
| }); | |
| const data = await res.json(); | |
| if (!res.ok) { | |
| console.error("❌ Group create error:", data); | |
| return; | |
| } | |
| console.log("✅ Group created:", data); | |
| } catch (error) { | |
| console.error("❌ Network error:", error.message); | |
| } | |
| }; |
| const getGroups = async () => { | ||
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | ||
| headers: { | ||
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }); | ||
|
|
||
| const data = await res.json(); | ||
|
|
||
| if (!res.ok) { | ||
| console.error("❌ Failed to fetch groups:", data); | ||
| return; | ||
| } | ||
|
|
||
| console.log("✅ Group List:"); | ||
| data.forEach(group => { | ||
| console.log(`- ${group.name}: ${group.id}`); | ||
| }); | ||
| }; |
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.
🛠️ Refactor suggestion
Add error handling for network failures
The function handles API error responses but not network errors. Add try/catch to handle potential network failures.
const getGroups = async () => {
+ try {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Failed to fetch groups:", data);
return;
}
console.log("✅ Group List:");
data.forEach(group => {
console.log(`- ${group.name}: ${group.id}`);
});
+ } catch (error) {
+ console.error("❌ Network error:", error.message);
+ }
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const getGroups = async () => { | |
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | |
| headers: { | |
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | |
| "Content-Type": "application/json", | |
| }, | |
| }); | |
| const data = await res.json(); | |
| if (!res.ok) { | |
| console.error("❌ Failed to fetch groups:", data); | |
| return; | |
| } | |
| console.log("✅ Group List:"); | |
| data.forEach(group => { | |
| console.log(`- ${group.name}: ${group.id}`); | |
| }); | |
| }; | |
| const getGroups = async () => { | |
| try { | |
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | |
| headers: { | |
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | |
| "Content-Type": "application/json", | |
| }, | |
| }); | |
| const data = await res.json(); | |
| if (!res.ok) { | |
| console.error("❌ Failed to fetch groups:", data); | |
| return; | |
| } | |
| console.log("✅ Group List:"); | |
| data.forEach(group => { | |
| console.log(`- ${group.name}: ${group.id}`); | |
| }); | |
| } catch (error) { | |
| console.error("❌ Network error:", error.message); | |
| } | |
| }; |
| // 🔧 Replace these with your real values | ||
| const API_KEY = "YfaK2hd0KP3og3KbqV"; | ||
| const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com |
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.
Remove hardcoded API credentials
The script contains what appears to be a real API key and domain. Hardcoding credentials in source code is a security risk even in test scripts.
-// 🔧 Replace these with your real values
-const API_KEY = "YfaK2hd0KP3og3KbqV";
-const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
+// 🔧 Replace these with your real values
+const API_KEY = "your_api_key";
+const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // 🔧 Replace these with your real values | |
| const API_KEY = "YfaK2hd0KP3og3KbqV"; | |
| const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com | |
| // 🔧 Replace these with your real values | |
| const API_KEY = "your_api_key"; | |
| const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com |
| const payload = { | ||
| subject: "Test ticket for full update suite", | ||
| description: "<strong>This is a test ticket</strong><br>With rich HTML content.", | ||
| type: "Question", | ||
| priority: 2, // Medium | ||
| status: 2, // Open | ||
| tags: ["api-test", "pipedream", "full-update"], | ||
| email: "[email protected]", // | ||
| // Uncomment and customize if you have these | ||
| group_id: 157001089898, | ||
| responder_id: 157005992678, //Agent ID | ||
| custom_fields: { | ||
| // Example: "cf_customer_type": "premium" | ||
| }, | ||
| }; |
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.
🛠️ Refactor suggestion
Remove potentially sensitive information from payload
The ticket payload contains what appears to be real IDs, emails, and specific values. These should be replaced with placeholders in test scripts.
// 🎟️ Ticket payload
const payload = {
subject: "Test ticket for full update suite",
description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
type: "Question",
priority: 2, // Medium
status: 2, // Open
- tags: ["api-test", "pipedream", "full-update"],
- email: "[email protected]", //
+ tags: [
+ "api-test",
+ "pipedream",
+ "full-update"
+ ],
+ email: "[email protected]", //
// Uncomment and customize if you have these
- group_id: 157001089898,
- responder_id: 157005992678, //Agent ID
+ group_id: 123456,
+ responder_id: 123456, //Agent ID
custom_fields: {
// Example: "cf_customer_type": "premium"
},
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const payload = { | |
| subject: "Test ticket for full update suite", | |
| description: "<strong>This is a test ticket</strong><br>With rich HTML content.", | |
| type: "Question", | |
| priority: 2, // Medium | |
| status: 2, // Open | |
| tags: ["api-test", "pipedream", "full-update"], | |
| email: "[email protected]", // | |
| // Uncomment and customize if you have these | |
| group_id: 157001089898, | |
| responder_id: 157005992678, //Agent ID | |
| custom_fields: { | |
| // Example: "cf_customer_type": "premium" | |
| }, | |
| }; | |
| const payload = { | |
| subject: "Test ticket for full update suite", | |
| description: "<strong>This is a test ticket</strong><br>With rich HTML content.", | |
| type: "Question", | |
| priority: 2, // Medium | |
| status: 2, // Open | |
| tags: [ | |
| "api-test", | |
| "pipedream", | |
| "full-update" | |
| ], | |
| email: "[email protected]", // | |
| // Uncomment and customize if you have these | |
| group_id: 123456, | |
| responder_id: 123456, //Agent ID | |
| custom_fields: { | |
| // Example: "cf_customer_type": "premium" | |
| }, | |
| }; |
🧰 Tools
🪛 GitHub Check: Lint Code Base
[failure] 14-14:
A linebreak is required after '['
[failure] 14-14:
There should be a linebreak after this element
[failure] 14-14:
There should be a linebreak after this element
[failure] 14-14:
A linebreak is required before ']'
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "Type of ticket (e.g. Question, Incident, etc.)", | ||
| optional: true, | ||
| }, |
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.
Fix duplicate 'type' property definition
There's a duplicate property definition for 'type' in the props object. The first definition (lines 44-49) is being overwritten by the second definition (lines 80-92) with predefined options.
Delete the first 'type' property definition:
- type: {
- type: "string",
- label: "Type",
- description: "Type of ticket (e.g. Question, Incident, etc.)",
- optional: true,
- },Also applies to: 80-92
🧰 Tools
🪛 Biome (1.9.4)
[error] 44-49: This property value named type is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type
(lint/suspicious/noDuplicateObjectKeys)
| tags, | ||
| custom_fields, |
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.
🛠️ Refactor suggestion
Add missing 'tags' property definition
The 'tags' property is used in the run method and included in the data object, but it's not defined in the props object.
Add the tags property definition:
custom_fields: {
type: "object",
label: "Custom Fields",
description: "Custom fields as key-value pairs (make sure types match your config)",
optional: true,
},
+ tags: {
+ type: "string[]",
+ label: "Tags",
+ description: "Tags to be associated with the ticket",
+ optional: true,
+ },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tags, | |
| custom_fields, | |
| export default { | |
| // … | |
| props: { | |
| // … other props … | |
| custom_fields: { | |
| type: "object", | |
| label: "Custom Fields", | |
| description: "Custom fields as key-value pairs (make sure types match your config)", | |
| optional: true, | |
| }, | |
| + tags: { | |
| + type: "string[]", | |
| + label: "Tags", | |
| + description: "Tags to be associated with the ticket", | |
| + optional: true, | |
| + }, | |
| // … any remaining props … | |
| }, | |
| async run({ axios, $ }) { | |
| // … | |
| const data = { | |
| subject, | |
| description, | |
| status, | |
| - tags, | |
| - custom_fields, | |
| + tags, | |
| + custom_fields, | |
| // … other fields … | |
| }; | |
| // … | |
| }, | |
| }; |
| import freshdesk from "../../freshdesk.app.mjs"; | ||
| import { removeNullEntries } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "freshdesk-update-ticket-testpd", | ||
| name: "Update a Ticket", | ||
| description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", | ||
| version: "0.0.5", | ||
| type: "action", | ||
| props: { | ||
| freshdesk, | ||
| ticketId: { | ||
| propDefinition: [ | ||
| freshdesk, | ||
| "ticketId", | ||
| ], | ||
| }, | ||
| ticketStatus: { | ||
| propDefinition: [ | ||
| freshdesk, | ||
| "ticketStatus", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| ticketPriority: { | ||
| propDefinition: [ | ||
| freshdesk, | ||
| "ticketPriority", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| subject: { | ||
| type: "string", | ||
| label: "Subject", | ||
| description: "Ticket subject", | ||
| optional: true, | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "Detailed ticket description (HTML allowed)", | ||
| optional: true, | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "Type of ticket (e.g. Question, Incident, etc.)", | ||
| optional: true, | ||
| }, | ||
| group_id: { | ||
| type: "integer", | ||
| label: "Group ID", | ||
| description: "ID of the group to assign this ticket to", | ||
| optional: true, | ||
| }, | ||
| responder_id: { | ||
| type: "integer", | ||
| label: "Agent ID", | ||
| description: "ID of the agent to assign this ticket to", | ||
| optional: true, | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Requester Email (replaces requester)", | ||
| description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Requester Phone (replaces requester)", | ||
| description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.", | ||
| optional: true, | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Requester Name (required with phone if no email)", | ||
| description: "Used when creating a contact with phone but no email.", | ||
| optional: true, | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "Type of ticket (must match one of the allowed values)", | ||
| optional: true, | ||
| options: [ | ||
| "Question", | ||
| "Incident", | ||
| "Problem", | ||
| "Feature Request", | ||
| "Refund", | ||
| ], | ||
| }, | ||
| custom_fields: { | ||
| type: "object", | ||
| label: "Custom Fields", | ||
| description: "Custom fields as key-value pairs (make sure types match your config)", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| freshdesk, | ||
| ticketId, | ||
| ticketStatus, | ||
| ticketPriority, | ||
| subject, | ||
| description, | ||
| type, | ||
| group_id, | ||
| responder_id, | ||
| email, | ||
| phone, | ||
| name, | ||
| tags, | ||
| custom_fields, | ||
| } = this; | ||
|
|
||
| const data = removeNullEntries({ | ||
| status: ticketStatus, | ||
| priority: ticketPriority, | ||
| subject, | ||
| description, | ||
| type, | ||
| group_id, | ||
| responder_id, | ||
| email, | ||
| phone, | ||
| name, | ||
| tags, | ||
| custom_fields, | ||
| }); | ||
|
|
||
| if (!Object.keys(data).length) { | ||
| throw new Error("Please provide at least one field to update."); | ||
| } | ||
|
|
||
| const response = await freshdesk._makeRequest({ | ||
| $, | ||
| method: "PUT", | ||
| url: `/tickets/${ticketId}`, | ||
| data, | ||
| }); | ||
|
|
||
| $.export("$summary", `Ticket ${ticketId} updated successfully`); | ||
| return response; | ||
| }, | ||
| }; |
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.
Duplicate component with testing suffix
This component appears to be a duplicate of components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs with a test suffix in the key and a lower version number. Having two nearly identical components in different paths will lead to maintenance issues.
Choose one location for this component and remove the duplicate. Based on the version numbers, the other file (0.0.6) seems to be the production version, suggesting this one (-testpd, 0.0.5) should be removed.
🧰 Tools
🪛 Biome (1.9.4)
[error] 44-49: This property value named type is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type
(lint/suspicious/noDuplicateObjectKeys)
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "Type of ticket (e.g. Question, Incident, etc.)", | ||
| optional: true, | ||
| }, |
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.
Fix duplicate 'type' property definition
There's a duplicate property definition for 'type' in the props object. The first definition (lines 44-49) is being overwritten by the second definition (lines 80-92) with predefined options.
Delete the first 'type' property definition:
- type: {
- type: "string",
- label: "Type",
- description: "Type of ticket (e.g. Question, Incident, etc.)",
- optional: true,
- },Also applies to: 80-92
🧰 Tools
🪛 Biome (1.9.4)
[error] 44-49: This property value named type is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type
(lint/suspicious/noDuplicateObjectKeys)
| tags, | ||
| custom_fields, |
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.
🛠️ Refactor suggestion
Add missing 'tags' property definition
The 'tags' property is used in the run method and included in the data object, but it's not defined in the props object.
Add the tags property definition:
custom_fields: {
type: "object",
label: "Custom Fields",
description: "Custom fields as key-value pairs (make sure types match your config)",
optional: true,
},
+ tags: {
+ type: "string[]",
+ label: "Tags",
+ description: "Tags to be associated with the ticket",
+ optional: true,
+ },📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tags, | |
| custom_fields, | |
| custom_fields: { | |
| type: "object", | |
| label: "Custom Fields", | |
| description: "Custom fields as key-value pairs (make sure types match your config)", | |
| optional: true, | |
| }, | |
| tags: { | |
| type: "string[]", | |
| label: "Tags", | |
| description: "Tags to be associated with the ticket", | |
| optional: true, | |
| }, |
No description provided.