Skip to content
Closed

accident #16448

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-assign-ticket-to-agent",
name: "Assign Ticket to Agent",
description: "Assign a Freshdesk ticket to a specific agent",
version: "0.0.1",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
responder_id: {
type: "integer",
label: "Agent ID",
description: "ID of the agent to assign this ticket to",
},
},
async run({ $ }) {
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;
},
};

Check failure on line 35 in components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Newline required at end of file but not found
Comment on lines +1 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Good implementation, but missing newline at end of file

The implementation of this action looks good and follows the same pattern as the other Freshdesk actions. It correctly assigns a ticket to an agent by updating the responder_id field.

Fix the linting error by adding a newline at the end of the file:

  },
};
+
📝 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.

Suggested change
import freshdesk from "../../freshdesk.app.mjs";
export default {
key: "freshdesk-assign-ticket-to-agent",
name: "Assign Ticket to Agent",
description: "Assign a Freshdesk ticket to a specific agent",
version: "0.0.1",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
responder_id: {
type: "integer",
label: "Agent ID",
description: "ID of the agent to assign this ticket to",
},
},
async run({ $ }) {
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;
},
};
},
};
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 35-35:
Newline required at end of file but not found

🪛 GitHub Actions: Pull Request Checks

[error] 35-35: ESLint: Newline required at end of file but not found (eol-last)

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-assign-ticket-to-group",
name: "Assign Ticket to Group",
description: "Assign a Freshdesk ticket to a specific group",
version: "0.0.1",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
group_id: {
type: "integer",
label: "Group ID",
description: "ID of the group to assign this ticket to",
},
},
async run({ $ }) {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
group_id: this.group_id,
},
});
$.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
return response;
},
Comment on lines +23 to +34
Copy link
Contributor

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 with informative messages

The current implementation lacks specific error handling which could provide more context to users when things go wrong.

   async run({ $ }) {
+    try {
       const response = await this.freshdesk._makeRequest({
         $,
         method: "PUT",
         url: `/tickets/${this.ticketId}`,
         data: {
           group_id: this.group_id,
         },
       });
       $.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
       return response;
+    } catch (error) {
+      $.export("$summary", `Failed to assign ticket ${this.ticketId} to group ${this.group_id}`);
+      throw error;
+    }
   },
📝 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.

Suggested change
async run({ $ }) {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
group_id: this.group_id,
},
});
$.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
return response;
},
async run({ $ }) {
try {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
group_id: this.group_id,
},
});
$.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
return response;
} catch (error) {
$.export("$summary", `Failed to assign ticket ${this.ticketId} to group ${this.group_id}`);
throw error;
}
},

};

Check failure on line 35 in components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Newline required at end of file but not found
33 changes: 33 additions & 0 deletions components/freshdesk/actions/close-ticket/close-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-close-ticket",
name: "Close Ticket",
description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
version: "0.0.1",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
},
async run({ $ }) {
const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed'

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;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));

Check failure on line 1 in components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Strings must use doublequote

Check failure on line 1 in components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

A space is required after '{'

Check failure on line 1 in components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

A space is required before '}'

// 🔧 Replace these with your real values
const API_KEY = "YfaK2hd0KP3og3KbqV";
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
Comment on lines +3 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
// 🔧 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);
};
Comment on lines +7 to +25
Copy link
Contributor

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.

Suggested change
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);
}
};


createGroup();

Check failure on line 27 in components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Newline required at end of file but not found
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import fetch from "node-fetch"; // if you're using Node 18+, native fetch is available

// 🔧 Replace these with your real values
const API_KEY = "YfaK2hd0KP3og3KbqV";
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
Comment on lines +3 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
// 🔧 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


// 🎟️ 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"],

Check failure on line 14 in components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

A linebreak is required after '['

Check failure on line 14 in components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

There should be a linebreak after this element

Check failure on line 14 in components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

There should be a linebreak after this element

Check failure on line 14 in components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

A linebreak is required before ']'
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"
},
};
Comment on lines +8 to +22
Copy link
Contributor

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.

Suggested change
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 ']'


const createTicket = async () => {
const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});

if (!response.ok) {
console.error("❌ Failed to create ticket", response.status, await response.text());
return;
}

const data = await response.json();
console.log("✅ Ticket created:", data);
};
Comment on lines +24 to +41
Copy link
Contributor

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 createTicket = async () => {
+  try {
     const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, {
       method: "POST",
       headers: {
         "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
         "Content-Type": "application/json",
       },
       body: JSON.stringify(payload),
     });

     if (!response.ok) {
       console.error("❌ Failed to create ticket", response.status, await response.text());
       return;
     }

     const data = await response.json();
     console.log("✅ Ticket 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.

Suggested change
const createTicket = async () => {
const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
console.error("❌ Failed to create ticket", response.status, await response.text());
return;
}
const data = await response.json();
console.log("✅ Ticket created:", data);
};
const createTicket = async () => {
try {
const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
console.error("❌ Failed to create ticket", response.status, await response.text());
return;
}
const data = await response.json();
console.log("✅ Ticket created:", data);
} catch (error) {
console.error("❌ Network error:", error.message);
}
};


createTicket();
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
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,
},
Comment on lines +44 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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)

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,
Comment on lines +114 to +115
Copy link
Contributor

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.

Suggested change
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,
},

} = 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;
},
};
Comment on lines +1 to +147
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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)



Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));

// 🔧 Replace with your values
const API_KEY = "your_api_key";
const DOMAIN = "yourdomain.freshdesk.com";

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}`);
});
};
Comment on lines +7 to +26
Copy link
Contributor

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.

Suggested change
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);
}
};


getGroups();
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-set-ticket-priority",
name: "Set Ticket Priority",
description: "Update the priority of a ticket in Freshdesk",
version: "0.0.1",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
ticketPriority: {
propDefinition: [
freshdesk,
"ticketPriority",
],
},
},
async run({ $ }) {
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;
},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Check for missing newline at end of file

Since there was a linting error in the assign-ticket-to-agent file about a missing newline, check if this file also needs one at the end.


🏁 Script executed:

#!/bin/bash
# Check if file ends with a newline
if [ "$(tail -c1 components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs | wc -l)" -eq 0 ]; then
  echo "File is missing a newline at the end"
else
  echo "File has a newline at the end"
fi

Length of output: 194


Add missing newline at end of file

The file components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs is missing a trailing newline. Please update the file to include one.

• File needing update:
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs

• Suggested change (add an empty line at EOF):

 };  // existing last line of code
+    ← add a single newline here
📝 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.

Suggested change
};
};

Loading
Loading