Skip to content

Commit ef77de5

Browse files
committed
fix: comments
1 parent 066dae1 commit ef77de5

File tree

2 files changed

+61
-32
lines changed

2 files changed

+61
-32
lines changed

components/gong/actions/get-extensive-data/get-extensive-data.mjs

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import app from "../../gong.app.mjs";
22
import constants from "../../common/constants.mjs";
33
import { ConfigurationError } from "@pipedream/platform";
4+
import utils from "../../common/utils.mjs";
45

56
export default {
67
key: "gong-get-extensive-data",
@@ -57,7 +58,7 @@ export default {
5758
context: {
5859
type: "string",
5960
label: "Context",
60-
description: "Allowed: None, Basic, Extended. If 'Basic', add links to external systems (context objects) such as CRM, Telephony System, Case Management. If 'Extended' include also data (context fields) for these links. Default value 'None'",
61+
description: "If 'Basic', add links to external systems (context objects) such as CRM, Telephony System, Case Management. If 'Extended' include also data (context fields) for these links.",
6162
options: [
6263
"None",
6364
"Basic",
@@ -70,7 +71,6 @@ export default {
7071
type: "string[]",
7172
label: "Context Timing",
7273
description: "Allowed: Now, TimeOfCall. Timing for the context data. The field is optional and can contain either 'Now' or 'TimeOfCall' or both. The default value is ['Now']. Can be provided only when the context field is set to 'Extended'",
73-
default: [],
7474
optional: true,
7575
},
7676
includeParties: {
@@ -85,16 +85,16 @@ export default {
8585
label: "Exposed Fields Content",
8686
description: "Specify which fields to include in the response for the content",
8787
default: {
88-
"structure": false,
89-
"topics": false,
90-
"trackers": false,
91-
"trackerOccurrences": false,
92-
"pointsOfInterest": false,
93-
"brief": false,
94-
"outline": false,
95-
"highlights": false,
96-
"callOutcome": false,
97-
"keyPoints": false,
88+
"structure": "false",
89+
"topics": "false",
90+
"trackers": "false",
91+
"trackerOccurrences": "false",
92+
"pointsOfInterest": "false",
93+
"brief": "false",
94+
"outline": "false",
95+
"highlights": "false",
96+
"callOutcome": "false",
97+
"keyPoints": "false",
9898
},
9999
optional: true,
100100
},
@@ -103,10 +103,10 @@ export default {
103103
label: "Exposed Fields Interaction",
104104
description: "Specify which fields to include in the response for the interaction",
105105
default: {
106-
"speakers": false,
107-
"video": false,
108-
"personInteractionStats": false,
109-
"questions": false,
106+
"speakers": "false",
107+
"video": "false",
108+
"personInteractionStats": "false",
109+
"questions": "false",
110110
},
111111
optional: true,
112112
},
@@ -152,6 +152,9 @@ export default {
152152
throw new ConfigurationError("Must not provide both `callIds` and `workspaceId`");
153153
}
154154

155+
const exposedFieldsContentObj = utils.parseObject(exposedFieldsContent);
156+
const exposedFieldsInteractionObj = utils.parseObject(exposedFieldsInteraction);
157+
155158
const contentSelector = {
156159
"context": context || "None",
157160
...(contextTiming.length > 0 && {
@@ -160,22 +163,22 @@ export default {
160163
"exposedFields": {
161164
"parties": includeParties || false,
162165
"content": {
163-
"structure": exposedFieldsContent.structure || false,
164-
"topics": exposedFieldsContent.topics || false,
165-
"trackers": exposedFieldsContent.trackers || false,
166-
"trackerOccurrences": exposedFieldsContent.trackerOccurrences || false,
167-
"pointsOfInterest": exposedFieldsContent.pointsOfInterest || false,
168-
"brief": exposedFieldsContent.brief || false,
169-
"outline": exposedFieldsContent.outline || false,
170-
"highlights": exposedFieldsContent.highlights || false,
171-
"callOutcome": exposedFieldsContent.callOutcome || false,
172-
"keyPoints": exposedFieldsContent.keyPoints || false,
166+
"structure": exposedFieldsContentObj?.structure || false,
167+
"topics": exposedFieldsContentObj?.topics || false,
168+
"trackers": exposedFieldsContentObj?.trackers || false,
169+
"trackerOccurrences": exposedFieldsContentObj?.trackerOccurrences || false,
170+
"pointsOfInterest": exposedFieldsContentObj?.pointsOfInterest || false,
171+
"brief": exposedFieldsContentObj?.brief || false,
172+
"outline": exposedFieldsContentObj?.outline || false,
173+
"highlights": exposedFieldsContentObj?.highlights || false,
174+
"callOutcome": exposedFieldsContentObj?.callOutcome || false,
175+
"keyPoints": exposedFieldsContentObj?.keyPoints || false,
173176
},
174177
"interaction": {
175-
"speakers": exposedFieldsInteraction.speakers || false,
176-
"video": exposedFieldsInteraction.video || false,
177-
"personInteractionStats": exposedFieldsInteraction.personInteractionStats || false,
178-
"questions": exposedFieldsInteraction.questions || false,
178+
"speakers": exposedFieldsInteractionObj?.speakers || false,
179+
"video": exposedFieldsInteractionObj?.video || false,
180+
"personInteractionStats": exposedFieldsInteractionObj?.personInteractionStats || false,
181+
"questions": exposedFieldsInteractionObj?.questions || false,
179182
},
180183
"collaboration": {
181184
"publicComments": includePublicComments || false,

components/gong/common/utils.mjs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { ConfigurationError } from "@pipedream/platform";
22

33
function emptyStrToUndefined(value) {
4-
const trimmed = typeof(value) === "string" && value.trim();
4+
const trimmed = typeof (value) === "string" && value.trim();
55
return trimmed === ""
66
? undefined
77
: value;
88
}
99

1010
function parse(value) {
1111
const valueToParse = emptyStrToUndefined(value);
12-
if (typeof(valueToParse) === "object" || valueToParse === undefined) {
12+
if (typeof (valueToParse) === "object" || valueToParse === undefined) {
1313
return valueToParse;
1414
}
1515
try {
@@ -42,6 +42,31 @@ function parseArray(value) {
4242
}
4343
}
4444

45+
function parseObject(obj) {
46+
if (!obj) return undefined;
47+
48+
if (Array.isArray(obj)) {
49+
return obj.map((item) => {
50+
if (typeof item === "string") {
51+
try {
52+
return JSON.parse(item);
53+
} catch (e) {
54+
return item;
55+
}
56+
}
57+
return item;
58+
});
59+
}
60+
if (typeof obj === "string") {
61+
try {
62+
return JSON.parse(obj);
63+
} catch (e) {
64+
return obj;
65+
}
66+
}
67+
return obj;
68+
};
69+
4570
async function streamIterator(stream) {
4671
const resources = [];
4772
for await (const resource of stream) {
@@ -52,6 +77,7 @@ async function streamIterator(stream) {
5277

5378
export default {
5479
parseArray,
80+
parseObject,
5581
parse,
5682
streamIterator,
5783
};

0 commit comments

Comments
 (0)