Skip to content

Commit 37750bc

Browse files
committed
updates
1 parent c2c2b7a commit 37750bc

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

components/zendesk/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import app from "../../zendesk.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
23

34
export default {
45
key: "zendesk-set-custom-ticket-fields",
@@ -44,15 +45,7 @@ export default {
4445
} = this;
4546

4647
// Parse custom fields from string array to objects
47-
const parsedCustomFields = customFields.map((field) => {
48-
try {
49-
return typeof field === "string"
50-
? JSON.parse(field)
51-
: field;
52-
} catch (error) {
53-
throw new Error(`Failed to parse custom field: ${field}. Each field must be valid JSON with "id" and "value" properties.`);
54-
}
55-
});
48+
const parsedCustomFields = parseObject(customFields);
5649

5750
// Validate custom fields structure
5851
parsedCustomFields.forEach((field, index) => {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) {
3+
return {};
4+
}
5+
if (typeof obj === "string") {
6+
try {
7+
return JSON.parse(obj);
8+
} catch {
9+
return obj;
10+
}
11+
}
12+
if (Array.isArray(obj)) {
13+
return obj.map(parseObject);
14+
}
15+
if (typeof obj === "object") {
16+
return Object.fromEntries(Object.entries(obj).map(([
17+
key,
18+
value,
19+
]) => [
20+
key,
21+
parseObject(value),
22+
]));
23+
}
24+
return obj;
25+
};

components/zendesk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/zendesk",
3-
"version": "0.9.1",
3+
"version": "0.10.0",
44
"description": "Pipedream Zendesk Components",
55
"main": "zendesk.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)