@pipedream/zendesk 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
key: "zendesk-new-ticket-comment-added",
|
|
8
8
|
type: "source",
|
|
9
9
|
description: "Emit new event when a ticket comment has been added",
|
|
10
|
-
version: "0.0
|
|
10
|
+
version: "0.1.0",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
props: {
|
|
13
13
|
app,
|
|
@@ -59,9 +59,14 @@ export default {
|
|
|
59
59
|
},
|
|
60
60
|
convertCommentsToJson(raw) {
|
|
61
61
|
return [
|
|
62
|
-
...raw.matchAll(/#<Comment (.*?)>/g),
|
|
62
|
+
...raw.matchAll(/#<Comment (.*?)(value: "[^"]*")(.*?)>/g),
|
|
63
63
|
].map((match) => {
|
|
64
|
-
const
|
|
64
|
+
const valueField = match[0].match(/(?<=, )value: "([^"]|\\")*[^\\]",/)?.[0];
|
|
65
|
+
const baseMatch = match[0].replace(/^#<Comment /, "");
|
|
66
|
+
const baseMatchWithoutValue = valueField
|
|
67
|
+
? baseMatch.split(valueField).join("")
|
|
68
|
+
: baseMatch;
|
|
69
|
+
const fields = baseMatchWithoutValue
|
|
65
70
|
.split(",")
|
|
66
71
|
.map((part) => part.trim())
|
|
67
72
|
.map((pair) => {
|
|
@@ -81,7 +86,15 @@ export default {
|
|
|
81
86
|
cleaned,
|
|
82
87
|
];
|
|
83
88
|
});
|
|
84
|
-
return Object.fromEntries(
|
|
89
|
+
return Object.fromEntries(valueField
|
|
90
|
+
? [
|
|
91
|
+
...fields,
|
|
92
|
+
[
|
|
93
|
+
"value",
|
|
94
|
+
valueField?.replace(/^value: ?/, ""),
|
|
95
|
+
],
|
|
96
|
+
]
|
|
97
|
+
: fields);
|
|
85
98
|
});
|
|
86
99
|
},
|
|
87
100
|
isRelevant(payload) {
|
|
@@ -97,10 +110,16 @@ export default {
|
|
|
97
110
|
},
|
|
98
111
|
emitEvent(payload) {
|
|
99
112
|
payload.ticketComments = this.convertCommentsToJson(payload.ticketComments);
|
|
100
|
-
|
|
113
|
+
const {
|
|
114
|
+
ticketComments, ...ticketData
|
|
115
|
+
} = payload;
|
|
116
|
+
for (const comment of ticketComments) {
|
|
101
117
|
const ts = Date.parse(comment.created_at);
|
|
102
118
|
const id = `${payload.ticketId}-${ts}`;
|
|
103
|
-
this.$emit(
|
|
119
|
+
this.$emit({
|
|
120
|
+
...comment,
|
|
121
|
+
ticketData,
|
|
122
|
+
}, {
|
|
104
123
|
id,
|
|
105
124
|
summary: comment.value,
|
|
106
125
|
ts,
|