File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed
actions/set-custom-ticket-fields Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change 11import app from "../../zendesk.app.mjs" ;
2+ import { parseObject } from "../../common/utils.mjs" ;
23
34export 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 ) => {
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change 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" : [
You can’t perform that action at this time.
0 commit comments