@credal/actions 0.1.71 → 0.1.72
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/dist/actions/providers/gong/getGongTranscripts.js +72 -37
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +3 -0
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +43 -0
- package/package.json +1 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +0 -3
- package/dist/actions/providers/confluence/updatePage.js +0 -47
@@ -41,52 +41,76 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
41
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
42
42
|
});
|
43
43
|
};
|
44
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
45
|
+
var t = {};
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
47
|
+
t[p] = s[p];
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
51
|
+
t[p[i]] = s[p[i]];
|
52
|
+
}
|
53
|
+
return t;
|
54
|
+
};
|
44
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
45
56
|
const axios_1 = __importStar(require("axios"));
|
46
57
|
const zod_1 = require("zod");
|
47
|
-
const UserSchema = zod_1.z
|
58
|
+
const UserSchema = zod_1.z
|
59
|
+
.object({
|
48
60
|
id: zod_1.z.string(),
|
49
|
-
|
61
|
+
firstName: zod_1.z.string(),
|
62
|
+
lastName: zod_1.z.string(),
|
50
63
|
title: zod_1.z.string(),
|
51
|
-
})
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
})
|
65
|
+
.partial()
|
66
|
+
.passthrough();
|
67
|
+
const TrackerSchema = zod_1.z
|
68
|
+
.object({
|
69
|
+
trackerId: zod_1.z.string(),
|
70
|
+
trackerName: zod_1.z.string(),
|
71
|
+
})
|
72
|
+
.partial()
|
73
|
+
.passthrough();
|
74
|
+
const CallSchema = zod_1.z
|
75
|
+
.object({
|
76
|
+
metaData: zod_1.z.object({
|
77
|
+
id: zod_1.z.string(),
|
78
|
+
primaryUserId: zod_1.z.string(),
|
79
|
+
started: zod_1.z.string(),
|
80
|
+
}),
|
81
|
+
})
|
82
|
+
.partial()
|
83
|
+
.passthrough();
|
61
84
|
const SentenceSchema = zod_1.z.object({
|
62
85
|
start: zod_1.z.number(),
|
63
86
|
end: zod_1.z.number(),
|
64
87
|
text: zod_1.z.string(),
|
65
88
|
});
|
66
|
-
const TranscriptSchema = zod_1.z
|
89
|
+
const TranscriptSchema = zod_1.z
|
90
|
+
.object({
|
67
91
|
callId: zod_1.z.string(),
|
68
92
|
transcript: zod_1.z.array(zod_1.z.object({
|
69
|
-
speakerId: zod_1.z.string(),
|
93
|
+
speakerId: zod_1.z.string().optional(),
|
70
94
|
topic: zod_1.z.string(),
|
71
95
|
sentences: zod_1.z.array(SentenceSchema),
|
72
96
|
})),
|
73
|
-
})
|
97
|
+
})
|
98
|
+
.partial()
|
99
|
+
.passthrough();
|
74
100
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
75
101
|
const GongResponseSchema = zod_1.z.object({
|
76
102
|
users: zod_1.z.array(UserSchema).optional(),
|
77
|
-
|
103
|
+
keywordTrackers: zod_1.z.array(TrackerSchema).optional(),
|
78
104
|
calls: zod_1.z.array(CallSchema).optional(),
|
79
105
|
callTranscripts: zod_1.z.array(TranscriptSchema).optional(),
|
80
106
|
cursor: zod_1.z.string().optional(),
|
81
107
|
});
|
82
|
-
function getUsers(
|
83
|
-
return __awaiter(this,
|
108
|
+
function getUsers(authToken) {
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
84
110
|
let results = [];
|
85
111
|
let cursor = undefined;
|
86
112
|
do {
|
87
|
-
const response = yield axios_1.default.
|
88
|
-
filter: Object.assign({}, params),
|
89
|
-
}, {
|
113
|
+
const response = yield axios_1.default.get(`https://api.gong.io/v2/users` + (cursor ? `?cursor=${cursor}` : ""), {
|
90
114
|
headers: {
|
91
115
|
Authorization: `Bearer ${authToken}`,
|
92
116
|
"Content-Type": "application/json",
|
@@ -107,8 +131,8 @@ function getUsers(authToken_1) {
|
|
107
131
|
return results;
|
108
132
|
});
|
109
133
|
}
|
110
|
-
function getTrackers(
|
111
|
-
return __awaiter(this,
|
134
|
+
function getTrackers(authToken) {
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
112
136
|
let results = [];
|
113
137
|
let cursor = undefined;
|
114
138
|
do {
|
@@ -117,14 +141,12 @@ function getTrackers(authToken_1) {
|
|
117
141
|
Authorization: `Bearer ${authToken}`,
|
118
142
|
"Content-Type": "application/json",
|
119
143
|
},
|
120
|
-
params: {
|
121
|
-
filter: Object.assign({}, params),
|
122
|
-
},
|
144
|
+
params: {},
|
123
145
|
});
|
124
146
|
if (!response) {
|
125
147
|
return results;
|
126
148
|
}
|
127
|
-
const parsedItems = zod_1.z.array(TrackerSchema).safeParse(response.data.
|
149
|
+
const parsedItems = zod_1.z.array(TrackerSchema).safeParse(response.data.keywordTrackers);
|
128
150
|
if (parsedItems.success) {
|
129
151
|
results = [...results, ...parsedItems.data];
|
130
152
|
}
|
@@ -169,7 +191,7 @@ function getTranscripts(authToken_1) {
|
|
169
191
|
let results = [];
|
170
192
|
let cursor = undefined;
|
171
193
|
do {
|
172
|
-
const response = yield axios_1.default.post(`https://api.gong.io/v2/
|
194
|
+
const response = yield axios_1.default.post(`https://api.gong.io/v2/calls/transcript` + (cursor ? `?cursor=${cursor}` : ""), {
|
173
195
|
filter: Object.assign({}, params),
|
174
196
|
}, {
|
175
197
|
headers: {
|
@@ -202,26 +224,39 @@ const getGongTranscripts = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
202
224
|
};
|
203
225
|
}
|
204
226
|
try {
|
205
|
-
const gongUsers = yield getUsers(authParams.authToken
|
227
|
+
const gongUsers = yield getUsers(authParams.authToken);
|
206
228
|
const filteredGongUsers = gongUsers.filter(user => user.title === params.userRole);
|
207
|
-
const trackers = yield getTrackers(authParams.authToken
|
208
|
-
const filteredTrackers = trackers.filter(tracker => { var _a; return (
|
209
|
-
// Get calls owned by the users and filtered by the trackers
|
229
|
+
const trackers = yield getTrackers(authParams.authToken);
|
230
|
+
const filteredTrackers = trackers.filter(tracker => { var _a, _b; return (_a = params.trackers) === null || _a === void 0 ? void 0 : _a.includes((_b = tracker.trackerName) !== null && _b !== void 0 ? _b : ""); });
|
210
231
|
const calls = yield getCalls(authParams.authToken, {
|
211
232
|
fromDateTime: (_b = params.startDate) !== null && _b !== void 0 ? _b : "",
|
212
233
|
toDateTime: (_c = params.endDate) !== null && _c !== void 0 ? _c : "",
|
213
|
-
primaryUserIds: filteredGongUsers.length > 0
|
214
|
-
|
234
|
+
primaryUserIds: filteredGongUsers.length > 0
|
235
|
+
? filteredGongUsers.map(user => user.id).filter((id) => id !== undefined)
|
236
|
+
: undefined,
|
237
|
+
trackerIds: filteredTrackers.length > 0
|
238
|
+
? filteredTrackers.map(tracker => tracker.trackerId).filter((id) => id !== undefined)
|
239
|
+
: undefined,
|
215
240
|
});
|
216
241
|
// Get transcripts for the calls we found
|
217
242
|
const callTranscripts = yield getTranscripts(authParams.authToken, {
|
218
243
|
fromDateTime: (_d = params.startDate) !== null && _d !== void 0 ? _d : "",
|
219
244
|
toDateTime: (_e = params.endDate) !== null && _e !== void 0 ? _e : "",
|
220
|
-
callIds: calls.map(call => call.id),
|
245
|
+
callIds: calls.map(call => { var _a; return (_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id; }).filter((id) => id !== undefined),
|
221
246
|
});
|
222
247
|
// Map speaker IDs to names in the transcripts
|
223
|
-
const userIdToNameMap = Object.fromEntries(
|
224
|
-
const callTranscriptsWithNames = callTranscripts.map(callTranscript =>
|
248
|
+
const userIdToNameMap = Object.fromEntries(gongUsers.map(user => [user.id, user.firstName + " " + user.lastName]));
|
249
|
+
const callTranscriptsWithNames = callTranscripts.map(callTranscript => {
|
250
|
+
var _a;
|
251
|
+
const currTranscript = Object.assign({}, callTranscript);
|
252
|
+
currTranscript.transcript = (_a = callTranscript.transcript) === null || _a === void 0 ? void 0 : _a.map(transcript => {
|
253
|
+
var _a;
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
255
|
+
const { speakerId } = transcript, rest = __rest(transcript, ["speakerId"]);
|
256
|
+
return Object.assign(Object.assign({}, rest), { speakerName: userIdToNameMap[(_a = transcript.speakerId) !== null && _a !== void 0 ? _a : ""] });
|
257
|
+
});
|
258
|
+
return currTranscript;
|
259
|
+
});
|
225
260
|
return {
|
226
261
|
success: true,
|
227
262
|
callTranscripts: callTranscriptsWithNames,
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
+
const getSalesforceRecordByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
|
+
const { authToken, baseUrl } = authParams;
|
15
|
+
const { query, limit } = params;
|
16
|
+
if (!authToken || !baseUrl) {
|
17
|
+
return {
|
18
|
+
success: false,
|
19
|
+
error: "authToken and baseUrl are required for Salesforce API",
|
20
|
+
};
|
21
|
+
}
|
22
|
+
// The API limits the maximum number of records returned to 2000, the limit lets the user set a smaller custom limit
|
23
|
+
const url = `${baseUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query + " LIMIT " + (limit != undefined && limit <= 2000 ? limit : 2000))}`;
|
24
|
+
try {
|
25
|
+
const response = yield axiosClient_1.axiosClient.get(url, {
|
26
|
+
headers: {
|
27
|
+
Authorization: `Bearer ${authToken}`,
|
28
|
+
},
|
29
|
+
});
|
30
|
+
return {
|
31
|
+
success: true,
|
32
|
+
records: response.data,
|
33
|
+
};
|
34
|
+
}
|
35
|
+
catch (error) {
|
36
|
+
console.error("Error retrieving Salesforce record:", error);
|
37
|
+
return {
|
38
|
+
success: false,
|
39
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
40
|
+
};
|
41
|
+
}
|
42
|
+
});
|
43
|
+
exports.default = getSalesforceRecordByQuery;
|
package/package.json
CHANGED
@@ -1,47 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
16
|
-
function getConfluenceApi(baseUrl, username, apiToken) {
|
17
|
-
const api = axios_1.default.create({
|
18
|
-
baseURL: baseUrl,
|
19
|
-
headers: {
|
20
|
-
Accept: "application/json",
|
21
|
-
// Tokens are associated with a specific user.
|
22
|
-
Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
|
23
|
-
},
|
24
|
-
});
|
25
|
-
return api;
|
26
|
-
}
|
27
|
-
const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
28
|
-
const { pageId, username, content, title } = params;
|
29
|
-
const { baseUrl, authToken } = authParams;
|
30
|
-
const api = getConfluenceApi(baseUrl, username, authToken);
|
31
|
-
// Get current version number
|
32
|
-
const response = yield api.get(`/api/v2/pages/${pageId}`);
|
33
|
-
const currVersion = response.data.version.number;
|
34
|
-
yield api.put(`/api/v2/pages/${pageId}`, {
|
35
|
-
id: pageId,
|
36
|
-
status: "current",
|
37
|
-
title,
|
38
|
-
body: {
|
39
|
-
representation: "storage",
|
40
|
-
value: content,
|
41
|
-
},
|
42
|
-
version: {
|
43
|
-
number: currVersion + 1,
|
44
|
-
},
|
45
|
-
});
|
46
|
-
});
|
47
|
-
exports.default = confluenceUpdatePage;
|