@sentry/junior-google 0.306.0 → 0.307.1

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.
Files changed (2) hide show
  1. package/dist/index.js +54 -32
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ import * as z from "zod";
7
7
  import { and, eq } from "drizzle-orm";
8
8
  import { bigint, pgTable, text } from "drizzle-orm/pg-core";
9
9
  import { parseFragment } from "parse5";
10
+ import pLimit from "p-limit";
10
11
  // src/config.ts
11
12
  /**
12
13
  * Deployment configuration for the Google plugin.
@@ -1089,7 +1090,7 @@ function htmlSummary(html) {
1089
1090
  const visit = (node) => {
1090
1091
  if (node.nodeName === "#text" && "value" in node) parts.push(node.value);
1091
1092
  if (HIDDEN.has(node.nodeName)) return;
1092
- if ("childNodes" in node) node.childNodes.forEach(visit);
1093
+ if ("childNodes" in node) for (const child of node.childNodes) visit(child);
1093
1094
  if (BREAKS.has(node.nodeName)) parts.push(" ");
1094
1095
  };
1095
1096
  visit(parseFragment(html));
@@ -2875,7 +2876,7 @@ const findMeetingTimesTool = definePluginTool({
2875
2876
  const checked = [];
2876
2877
  const unavailable = [];
2877
2878
  const slotAttendees = [];
2878
- everyone.forEach((email, index) => {
2879
+ for (const [index, email] of everyone.entries()) {
2879
2880
  const calendar = calendars[email];
2880
2881
  const error = calendar?.errors?.[0]?.reason;
2881
2882
  if (!calendar || error) {
@@ -2883,7 +2884,7 @@ const findMeetingTimesTool = definePluginTool({
2883
2884
  email,
2884
2885
  reason: error ?? "notFound"
2885
2886
  });
2886
- return;
2887
+ continue;
2887
2888
  }
2888
2889
  const calendarZone = timeZones[index];
2889
2890
  checked.push({
@@ -2899,7 +2900,7 @@ const findMeetingTimesTool = definePluginTool({
2899
2900
  required: required.has(email),
2900
2901
  timeZone: calendarZone ?? timeZone
2901
2902
  });
2902
- });
2903
+ }
2903
2904
  const slots = !slotAttendees.some((attendee) => attendee.required) ? [] : findFreeSlots({
2904
2905
  attendees: slotAttendees,
2905
2906
  durationMinutes: input.duration_minutes,
@@ -3437,6 +3438,7 @@ function meetingRecordKind(title) {
3437
3438
  return kind === "Transcript" ? "transcript" : kind ? "notes" : void 0;
3438
3439
  }
3439
3440
  const EARLY_START_MS = 18e5;
3441
+ const DRIVE_READ_CONCURRENCY = 5;
3440
3442
  const inputSchema$3 = z.object({ event_id: z.string().trim().min(5).max(2048).describe("Event id from listCalendarEvents on your own calendar, or a Google Calendar event link. You and the requester must both be invited. For a repeating meeting, use the id of the occurrence, not its series_event_id.") }).strict();
3441
3443
  const recordOutputSchema = z.object({
3442
3444
  content: z.string(),
@@ -3503,6 +3505,36 @@ async function readRecordFile(ctx, input) {
3503
3505
  if (response.status !== 200) throw googleApiError(input.operation, response);
3504
3506
  return response;
3505
3507
  }
3508
+ /**
3509
+ * Read one attached Doc as a Meet record of this occurrence. Return
3510
+ * `"unreadable"` when the account cannot open it, and nothing when it is not
3511
+ * a record of this meeting.
3512
+ */
3513
+ async function readRecord(ctx, fileId, organizer, startMs) {
3514
+ const metadata = await readRecordFile(ctx, {
3515
+ operation: "google.drive.file.get",
3516
+ path: `/drive/v3/files/${fileId}`,
3517
+ query: {
3518
+ fields: "createdTime,id,mimeType,name,owners(emailAddress),webViewLink",
3519
+ supportsAllDrives: "true"
3520
+ }
3521
+ });
3522
+ if (!metadata) return "unreadable";
3523
+ const file = recordFileSchema.parse(metadata.body);
3524
+ if (file.mimeType !== googleFileMimeType("document") || file.owners[0]?.emailAddress.toLowerCase() !== organizer || Date.parse(file.createdTime) < startMs - EARLY_START_MS) return;
3525
+ const exported = await readRecordFile(ctx, {
3526
+ headers: { Accept: "text/markdown" },
3527
+ operation: "google.drive.file.export",
3528
+ path: `/drive/v3/files/${fileId}/export`,
3529
+ query: { mimeType: "text/markdown" }
3530
+ });
3531
+ if (!exported) return "unreadable";
3532
+ return {
3533
+ file,
3534
+ fileId,
3535
+ text: typeof exported.body === "string" ? exported.body : ""
3536
+ };
3537
+ }
3506
3538
  /** Save the full text of a long record in the sandbox and return its path. */
3507
3539
  async function saveFullRecord(ctx, eventId, fileId, text) {
3508
3540
  const directory = `${ctx.sandbox.root}/meetings/${eventId.replace(/[^A-Za-z0-9_-]/g, "_")}`;
@@ -3584,48 +3616,38 @@ const readMeetingTranscriptTool = definePluginTool({
3584
3616
  message: NO_RECORD_MESSAGE,
3585
3617
  status: "no_record"
3586
3618
  };
3619
+ const limit = pLimit(DRIVE_READ_CONCURRENCY);
3620
+ const reads = await Promise.all(fileIds.map((fileId) => limit(() => readRecord(ctx, fileId, organizer, startMs))));
3587
3621
  const records = [];
3622
+ const fullRecords = [];
3588
3623
  let chars = 0;
3589
- let truncated = false;
3590
3624
  let unreadable = 0;
3591
- for (const fileId of fileIds) {
3592
- const metadata = await readRecordFile(ctx, {
3593
- operation: "google.drive.file.get",
3594
- path: `/drive/v3/files/${fileId}`,
3595
- query: {
3596
- fields: "createdTime,id,mimeType,name,owners(emailAddress),webViewLink",
3597
- supportsAllDrives: "true"
3598
- }
3599
- });
3600
- if (!metadata) {
3601
- unreadable += 1;
3602
- continue;
3603
- }
3604
- const file = recordFileSchema.parse(metadata.body);
3605
- if (file.mimeType !== googleFileMimeType("document") || file.owners[0]?.emailAddress.toLowerCase() !== organizer || Date.parse(file.createdTime) < startMs - EARLY_START_MS) continue;
3606
- const exported = await readRecordFile(ctx, {
3607
- headers: { Accept: "text/markdown" },
3608
- operation: "google.drive.file.export",
3609
- path: `/drive/v3/files/${fileId}/export`,
3610
- query: { mimeType: "text/markdown" }
3611
- });
3612
- if (!exported) {
3625
+ for (const read of reads) {
3626
+ if (read === "unreadable") {
3613
3627
  unreadable += 1;
3614
3628
  continue;
3615
3629
  }
3616
- const text = typeof exported.body === "string" ? exported.body : "";
3630
+ if (!read) continue;
3631
+ const { file, fileId, text } = read;
3617
3632
  const content = text.slice(0, Math.max(MAX_CONTENT_CHARS - chars, 0));
3618
3633
  chars += content.length;
3619
- const path = content.length < text.length ? await saveFullRecord(ctx, eventId, fileId, text) : void 0;
3620
- truncated ||= path !== void 0;
3621
- records.push({
3634
+ const record = {
3622
3635
  content,
3623
3636
  kind: meetingRecordKind(file.name) ?? "document",
3624
- ...path ? { path } : void 0,
3625
3637
  title: file.name,
3626
3638
  ...file.webViewLink ? { url: file.webViewLink } : void 0
3639
+ };
3640
+ records.push(record);
3641
+ if (content.length < text.length) fullRecords.push({
3642
+ fileId,
3643
+ record,
3644
+ text
3627
3645
  });
3628
3646
  }
3647
+ await Promise.all(fullRecords.map(({ fileId, record, text }) => limit(async () => {
3648
+ record.path = await saveFullRecord(ctx, eventId, fileId, text);
3649
+ })));
3650
+ const truncated = fullRecords.length > 0;
3629
3651
  const unreadableNote = unreadable > 0 ? `${unreadable} attached Meet record(s) cannot be opened by your Google account (${ctx.accountEmail}). The Doc may be deleted, or not shared with invitees. Ask the organizer to share it with that account.` : void 0;
3630
3652
  if (records.length === 0) return {
3631
3653
  ...base,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-google",
3
- "version": "0.306.0",
3
+ "version": "0.307.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,9 +22,10 @@
22
22
  "migrations"
23
23
  ],
24
24
  "dependencies": {
25
- "@sentry/junior-plugin-api": "0.306.0",
25
+ "@sentry/junior-plugin-api": "0.307.1",
26
26
  "commander": "^14.0.3",
27
27
  "drizzle-orm": "^0.45.4",
28
+ "p-limit": "^7.3.3",
28
29
  "parse5": "^7.3.0",
29
30
  "zod": "^4.6.7"
30
31
  },