@credal/actions 0.1.95 → 0.1.97

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.
@@ -5342,6 +5342,10 @@ exports.gongGetGongTranscriptsDefinition = {
5342
5342
  description: "The names of the trackers to fetch transcripts for",
5343
5343
  },
5344
5344
  },
5345
+ company: {
5346
+ type: "string",
5347
+ description: "The company to get calls with",
5348
+ },
5345
5349
  startDate: {
5346
5350
  type: "string",
5347
5351
  description: "The start date of the transcripts to fetch in ISO 8601 format",
@@ -2530,16 +2530,19 @@ export type googleOauthSearchDriveByKeywordsFunction = ActionFunction<googleOaut
2530
2530
  export declare const gongGetGongTranscriptsParamsSchema: z.ZodObject<{
2531
2531
  userRole: z.ZodString;
2532
2532
  trackers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2533
+ company: z.ZodOptional<z.ZodString>;
2533
2534
  startDate: z.ZodOptional<z.ZodString>;
2534
2535
  endDate: z.ZodOptional<z.ZodString>;
2535
2536
  }, "strip", z.ZodTypeAny, {
2536
2537
  userRole: string;
2537
2538
  trackers?: string[] | undefined;
2539
+ company?: string | undefined;
2538
2540
  startDate?: string | undefined;
2539
2541
  endDate?: string | undefined;
2540
2542
  }, {
2541
2543
  userRole: string;
2542
2544
  trackers?: string[] | undefined;
2545
+ company?: string | undefined;
2543
2546
  startDate?: string | undefined;
2544
2547
  endDate?: string | undefined;
2545
2548
  }>;
@@ -2124,6 +2124,7 @@ exports.gongGetGongTranscriptsParamsSchema = zod_1.z.object({
2124
2124
  .array(zod_1.z.string().describe("The names of the trackers to fetch transcripts for"))
2125
2125
  .describe("The trackers to fetch transcripts for")
2126
2126
  .optional(),
2127
+ company: zod_1.z.string().describe("The company to get calls with").optional(),
2127
2128
  startDate: zod_1.z.string().describe("The start date of the transcripts to fetch in ISO 8601 format").optional(),
2128
2129
  endDate: zod_1.z.string().describe("The end date of the transcripts to fetch in ISO 8601 format").optional(),
2129
2130
  });
@@ -125,7 +125,8 @@ const GongResponseSchema = zod_1.z.object({
125
125
  });
126
126
  function getUsers(authToken) {
127
127
  return __awaiter(this, void 0, void 0, function* () {
128
- let results = [];
128
+ var _a;
129
+ const results = [];
129
130
  let cursor = undefined;
130
131
  do {
131
132
  const response = yield axios_1.default.get(`https://api.gong.io/v2/users` + (cursor ? `?cursor=${cursor}` : ""), {
@@ -137,12 +138,11 @@ function getUsers(authToken) {
137
138
  if (!response) {
138
139
  return results;
139
140
  }
140
- const parsedItems = zod_1.z.array(UserSchema).safeParse(response.data.users);
141
- if (parsedItems.success) {
142
- results = [...results, ...parsedItems.data];
143
- }
144
- else {
145
- return results;
141
+ for (const user of (_a = response.data.users) !== null && _a !== void 0 ? _a : []) {
142
+ const parsedUser = UserSchema.safeParse(user);
143
+ if (parsedUser.success) {
144
+ results.push(parsedUser.data);
145
+ }
146
146
  }
147
147
  cursor = response.data.cursor;
148
148
  } while (cursor);
@@ -284,32 +284,56 @@ const getGongTranscripts = (_a) => __awaiter(void 0, [_a], void 0, function* ({
284
284
  // Map speaker IDs to names in the transcripts
285
285
  const userIdToNameMap = {};
286
286
  const userIdToEmailMap = {};
287
+ const callIdToEmails = {};
287
288
  publicCalls.forEach(call => {
289
+ var _a;
288
290
  // Check if call has parties array
289
291
  if (call.parties && Array.isArray(call.parties)) {
290
292
  // Iterate through each party in the call
291
- call.parties.forEach(party => {
292
- // Add the mapping of speakerId to name
293
- if (party.speakerId) {
294
- if (party.name) {
295
- userIdToNameMap[party.speakerId] = party.name;
296
- }
297
- if (party.emailAddress) {
298
- userIdToEmailMap[party.speakerId] = party.emailAddress;
293
+ if ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) {
294
+ callIdToEmails[call.metaData.id] = [];
295
+ call.parties.forEach(party => {
296
+ var _a;
297
+ // Add the mapping of speakerId to name
298
+ if (party.speakerId) {
299
+ if (party.name) {
300
+ userIdToNameMap[party.speakerId] = party.name;
301
+ }
302
+ if (party.emailAddress) {
303
+ userIdToEmailMap[party.speakerId] = party.emailAddress;
304
+ if ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) {
305
+ callIdToEmails[call.metaData.id].push(party.emailAddress);
306
+ }
307
+ }
299
308
  }
300
- }
301
- });
309
+ });
310
+ }
302
311
  }
303
312
  });
304
- const callTranscriptsWithNames = callTranscripts.map(callTranscript => {
305
- var _a, _b, _c, _d, _e, _f, _g;
313
+ const callTranscriptsWithNames = callTranscripts
314
+ .map(callTranscript => {
315
+ var _a, _b, _c, _d, _e, _f, _g, _h;
306
316
  const currTranscript = Object.assign({}, callTranscript);
317
+ const callId = callTranscript.callId;
307
318
  currTranscript.transcript = (_a = callTranscript.transcript) === null || _a === void 0 ? void 0 : _a.map(transcript => {
308
319
  var _a, _b;
309
320
  const { speakerId } = transcript, rest = __rest(transcript, ["speakerId"]);
310
321
  return Object.assign(Object.assign({}, rest), { speakerName: (_a = userIdToNameMap[speakerId !== null && speakerId !== void 0 ? speakerId : ""]) !== null && _a !== void 0 ? _a : "Unknown", speakerEmail: (_b = userIdToEmailMap[speakerId !== null && speakerId !== void 0 ? speakerId : ""]) !== null && _b !== void 0 ? _b : "Unknown" });
311
322
  });
312
- return Object.assign({ callName: (_d = (_c = (_b = publicCalls.find(call => { var _a; return ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) === callTranscript.callId; })) === null || _b === void 0 ? void 0 : _b.metaData) === null || _c === void 0 ? void 0 : _c.title) !== null && _d !== void 0 ? _d : "", startTime: (_g = (_f = (_e = publicCalls.find(call => { var _a; return ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) === callTranscript.callId; })) === null || _e === void 0 ? void 0 : _e.metaData) === null || _f === void 0 ? void 0 : _f.started) !== null && _g !== void 0 ? _g : "" }, currTranscript);
323
+ return Object.assign({ callName: (_d = (_c = (_b = publicCalls.find(call => { var _a; return ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) === callTranscript.callId; })) === null || _b === void 0 ? void 0 : _b.metaData) === null || _c === void 0 ? void 0 : _c.title) !== null && _d !== void 0 ? _d : "", userEmails: (_e = callIdToEmails[callId]) !== null && _e !== void 0 ? _e : [], startTime: (_h = (_g = (_f = publicCalls.find(call => { var _a; return ((_a = call.metaData) === null || _a === void 0 ? void 0 : _a.id) === callTranscript.callId; })) === null || _f === void 0 ? void 0 : _f.metaData) === null || _g === void 0 ? void 0 : _g.started) !== null && _h !== void 0 ? _h : "" }, currTranscript);
324
+ })
325
+ .filter(callTranscript => {
326
+ var _a;
327
+ if (!params.company || params.company === "") {
328
+ return true; // If no company filter is provided, include all transcripts
329
+ }
330
+ for (const email of callIdToEmails[callTranscript.callId]) {
331
+ const companyName = (_a = params.company) === null || _a === void 0 ? void 0 : _a.toLowerCase().replace(/ /g, "");
332
+ if (email.includes(companyName)) {
333
+ return true;
334
+ }
335
+ }
336
+ return false;
313
337
  });
314
338
  return {
315
339
  success: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.95",
3
+ "version": "0.1.97",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",