@sentry/junior-google 0.279.0 → 0.281.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/dist/index.js CHANGED
@@ -27,12 +27,12 @@ function readEnv(name) {
27
27
  function readList(name) {
28
28
  return (readEnv(name) ?? "").split(",").map((value) => value.trim().toLowerCase()).filter(Boolean);
29
29
  }
30
- function emailDomain(email) {
31
- const at = email.lastIndexOf("@");
32
- if (at <= 0 || at === email.length - 1) {
30
+ function emailDomain(email3) {
31
+ const at = email3.lastIndexOf("@");
32
+ if (at <= 0 || at === email3.length - 1) {
33
33
  return void 0;
34
34
  }
35
- return email.slice(at + 1).toLowerCase();
35
+ return email3.slice(at + 1).toLowerCase();
36
36
  }
37
37
  function readGoogleConfig() {
38
38
  const clientId = readEnv(GOOGLE_CLIENT_ID_ENV);
@@ -56,7 +56,7 @@ function readGoogleConfig() {
56
56
 
57
57
  // src/oauth.ts
58
58
  import { createHash, randomBytes } from "crypto";
59
- import { z } from "zod";
59
+ import * as z from "zod";
60
60
 
61
61
  // src/store.ts
62
62
  import { and, eq } from "drizzle-orm";
@@ -76,31 +76,31 @@ async function getGoogleAccount(db, accountEmail) {
76
76
  const [row] = await db.select().from(juniorGoogleAccounts).where(eq(juniorGoogleAccounts.accountEmail, accountEmail)).limit(1);
77
77
  return row;
78
78
  }
79
- async function saveGoogleAccount(db, record) {
80
- await db.insert(juniorGoogleAccounts).values(record).onConflictDoUpdate({
79
+ async function saveGoogleAccount(db, record2) {
80
+ await db.insert(juniorGoogleAccounts).values(record2).onConflictDoUpdate({
81
81
  target: juniorGoogleAccounts.accountEmail,
82
82
  set: {
83
- refreshToken: record.refreshToken,
84
- scope: record.scope,
85
- connectedBy: record.connectedBy,
86
- connectedAtMs: record.connectedAtMs
83
+ refreshToken: record2.refreshToken,
84
+ scope: record2.scope,
85
+ connectedBy: record2.connectedBy,
86
+ connectedAtMs: record2.connectedAtMs
87
87
  }
88
88
  });
89
89
  }
90
- async function deleteRejectedGoogleAccount(db, record) {
90
+ async function deleteRejectedGoogleAccount(db, record2) {
91
91
  await db.delete(juniorGoogleAccounts).where(
92
92
  and(
93
- eq(juniorGoogleAccounts.accountEmail, record.accountEmail),
94
- eq(juniorGoogleAccounts.refreshToken, record.refreshToken)
93
+ eq(juniorGoogleAccounts.accountEmail, record2.accountEmail),
94
+ eq(juniorGoogleAccounts.refreshToken, record2.refreshToken)
95
95
  )
96
96
  );
97
97
  }
98
- function googleAccountStatus(record) {
98
+ function googleAccountStatus(record2) {
99
99
  return {
100
- accountEmail: record.accountEmail,
101
- connectedAt: new Date(record.connectedAtMs).toISOString(),
102
- connectedBy: record.connectedBy,
103
- scope: record.scope
100
+ accountEmail: record2.accountEmail,
101
+ connectedAt: new Date(record2.connectedAtMs).toISOString(),
102
+ connectedBy: record2.connectedBy,
103
+ scope: record2.scope
104
104
  };
105
105
  }
106
106
 
@@ -187,10 +187,10 @@ function verifyGrant(tokens, config) {
187
187
  if (!claims || !GOOGLE_ISSUERS.has(claims.iss) || claims.aud !== config.clientId || claims.email_verified !== true) {
188
188
  return { reason: "Google did not return a valid account identity." };
189
189
  }
190
- const email = claims.email.toLowerCase();
191
- if (email !== config.accountEmail) {
190
+ const email3 = claims.email.toLowerCase();
191
+ if (email3 !== config.accountEmail) {
192
192
  return {
193
- reason: `You signed in as ${email}. Sign in as ${config.accountEmail} instead.`
193
+ reason: `You signed in as ${email3}. Sign in as ${config.accountEmail} instead.`
194
194
  };
195
195
  }
196
196
  const granted = new Set(grantedScopes(tokens));
@@ -382,11 +382,11 @@ async function runConnect(ctx, options) {
382
382
  async function runStatus(ctx) {
383
383
  const config = await requireConfig(ctx);
384
384
  if (!config) return 1;
385
- const record = await getGoogleAccount(
385
+ const record2 = await getGoogleAccount(
386
386
  ctx.db,
387
387
  config.accountEmail
388
388
  );
389
- if (!record) {
389
+ if (!record2) {
390
390
  await ctx.io.writeOutput(
391
391
  `account=${config.accountEmail}
392
392
  status=not_connected
@@ -394,7 +394,7 @@ status=not_connected
394
394
  );
395
395
  return 0;
396
396
  }
397
- const status = googleAccountStatus(record);
397
+ const status = googleAccountStatus(record2);
398
398
  await ctx.io.writeOutput(
399
399
  [
400
400
  `account=${status.accountEmail}`,
@@ -560,16 +560,16 @@ async function issueGoogleCredential(ctx) {
560
560
  );
561
561
  }
562
562
  const db = ctx.db;
563
- const record = await getGoogleAccount(db, config.accountEmail);
564
- if (!record) {
563
+ const record2 = await getGoogleAccount(db, config.accountEmail);
564
+ if (!record2) {
565
565
  return unavailable(NOT_CONNECTED_MESSAGE);
566
566
  }
567
567
  const token = await refreshGoogleAccessToken({
568
568
  config,
569
- refreshToken: record.refreshToken
569
+ refreshToken: record2.refreshToken
570
570
  });
571
571
  if (!token) {
572
- await deleteRejectedGoogleAccount(db, record);
572
+ await deleteRejectedGoogleAccount(db, record2);
573
573
  ctx.log.warn("google.account.token_rejected", {
574
574
  "app.google.account": config.accountEmail
575
575
  });
@@ -622,11 +622,11 @@ function googleCallbackUrl(request) {
622
622
  }
623
623
  function adminEmail(context) {
624
624
  const user = context?.auth.user;
625
- const email = user?.email?.trim().toLowerCase();
626
- if (!email || user?.emailVerified !== true || user.isAdmin !== true) {
625
+ const email3 = user?.email?.trim().toLowerCase();
626
+ if (!email3 || user?.emailVerified !== true || user.isAdmin !== true) {
627
627
  return void 0;
628
628
  }
629
- return email;
629
+ return email3;
630
630
  }
631
631
  function forbidden() {
632
632
  return htmlPage(
@@ -750,11 +750,11 @@ function createGoogleSetupPage() {
750
750
  ]
751
751
  };
752
752
  }
753
- const record = await getGoogleAccount(
753
+ const record2 = await getGoogleAccount(
754
754
  ctx.db,
755
755
  config.accountEmail
756
756
  );
757
- const status = record ? googleAccountStatus(record) : void 0;
757
+ const status = record2 ? googleAccountStatus(record2) : void 0;
758
758
  return {
759
759
  type: "list",
760
760
  records: [
@@ -788,13 +788,13 @@ import {
788
788
  definePluginTool,
789
789
  pluginToolOutputSchema
790
790
  } from "@sentry/junior-plugin-api";
791
- import { z as z3 } from "zod";
791
+ import * as z3 from "zod";
792
792
 
793
793
  // src/tools/shared.ts
794
794
  import {
795
795
  PluginToolInputError
796
796
  } from "@sentry/junior-plugin-api";
797
- import { z as z2 } from "zod";
797
+ import * as z2 from "zod";
798
798
  var emailListSchema = (max) => z2.array(z2.string().trim().toLowerCase().pipe(z2.email())).max(max).describe("Attendee email addresses.");
799
799
  var timeZoneSchema = z2.string().min(1).refine(isTimeZone, "time_zone must be an IANA time zone").optional().describe(
800
800
  "IANA time zone used to read and show times, such as America/Los_Angeles. Omit to use the requester's time zone."
@@ -808,8 +808,8 @@ function isTimeZone(value) {
808
808
  }
809
809
  }
810
810
  function requireAllowedEmails(emails, allowedDomains) {
811
- const outside = emails.filter((email) => {
812
- const domain = emailDomain(email);
811
+ const outside = emails.filter((email3) => {
812
+ const domain = emailDomain(email3);
813
813
  return !domain || !allowedDomains.includes(domain);
814
814
  });
815
815
  if (outside.length > 0) {
@@ -1136,7 +1136,7 @@ import {
1136
1136
  PluginToolInputError as PluginToolInputError2,
1137
1137
  pluginToolOutputSchema as pluginToolOutputSchema2
1138
1138
  } from "@sentry/junior-plugin-api";
1139
- import { z as z4 } from "zod";
1139
+ import * as z4 from "zod";
1140
1140
  var repeatSchema = z4.object({
1141
1141
  frequency: z4.enum(["weekdays", "weekly", "monthly"]).describe(
1142
1142
  "`weekdays` repeats Monday to Friday. `weekly` repeats on the start's weekday. `monthly` repeats on the start's day of the month."
@@ -1208,7 +1208,7 @@ function createCreateCalendarEventTool(ctx) {
1208
1208
  const attendees = await withRequester(ctx, input.attendees);
1209
1209
  const required = new Set(attendees);
1210
1210
  const optionalAttendees = [...new Set(input.optional_attendees)].filter(
1211
- (email) => !required.has(email)
1211
+ (email3) => !required.has(email3)
1212
1212
  );
1213
1213
  if (attendees.length + optionalAttendees.length === 0) {
1214
1214
  throw new PluginToolInputError2("Invite at least one attendee.");
@@ -1221,8 +1221,8 @@ function createCreateCalendarEventTool(ctx) {
1221
1221
  const response = await googleApiRequest(ctx, {
1222
1222
  body: {
1223
1223
  attendees: [
1224
- ...attendees.map((email) => ({ email })),
1225
- ...optionalAttendees.map((email) => ({ email, optional: true }))
1224
+ ...attendees.map((email3) => ({ email: email3 })),
1225
+ ...optionalAttendees.map((email3) => ({ email: email3, optional: true }))
1226
1226
  ],
1227
1227
  conferenceData: {
1228
1228
  createRequest: {
@@ -1279,7 +1279,7 @@ import {
1279
1279
  PluginToolInputError as PluginToolInputError3,
1280
1280
  pluginToolOutputSchema as pluginToolOutputSchema3
1281
1281
  } from "@sentry/junior-plugin-api";
1282
- import { z as z5 } from "zod";
1282
+ import * as z5 from "zod";
1283
1283
  var DAY_MS = 24 * 60 * 60 * 1e3;
1284
1284
  var MAX_WINDOW_MS = 14 * DAY_MS;
1285
1285
  var DEFAULT_WINDOW_MS = 7 * DAY_MS;
@@ -1583,10 +1583,10 @@ function findFreeSlots(input) {
1583
1583
  startMs
1584
1584
  }));
1585
1585
  }
1586
- async function calendarTimeZone(ctx, email) {
1586
+ async function calendarTimeZone(ctx, email3) {
1587
1587
  const response = await googleApiRequest(ctx, {
1588
1588
  operation: "google.calendar.events.list",
1589
- path: `/calendar/v3/calendars/${encodeURIComponent(email)}/events`,
1589
+ path: `/calendar/v3/calendars/${encodeURIComponent(email3)}/events`,
1590
1590
  // No `timeZone` parameter: Google then answers with the calendar's own.
1591
1591
  query: { fields: "timeZone", maxResults: "1" }
1592
1592
  });
@@ -1637,11 +1637,11 @@ function createFindMeetingTimesTool(ctx) {
1637
1637
  }
1638
1638
  const optionalEmails = new Set(input.optional_attendees);
1639
1639
  const attendees = (await withRequester(ctx, input.attendees)).filter(
1640
- (email) => input.attendees.includes(email) || !optionalEmails.has(email)
1640
+ (email3) => input.attendees.includes(email3) || !optionalEmails.has(email3)
1641
1641
  );
1642
1642
  const required = new Set(attendees);
1643
1643
  const optionalAttendees = [...optionalEmails].filter(
1644
- (email) => !required.has(email)
1644
+ (email3) => !required.has(email3)
1645
1645
  );
1646
1646
  const everyone = [...attendees, ...optionalAttendees];
1647
1647
  requireAllowedEmails(everyone, ctx.allowedDomains);
@@ -1655,7 +1655,7 @@ function createFindMeetingTimesTool(ctx) {
1655
1655
  operation: "google.calendar.freebusy.query",
1656
1656
  path: "/calendar/v3/freeBusy"
1657
1657
  }),
1658
- ...everyone.map((email) => calendarTimeZone(ctx, email))
1658
+ ...everyone.map((email3) => calendarTimeZone(ctx, email3))
1659
1659
  ]);
1660
1660
  if (response.status !== 200) {
1661
1661
  throw googleApiError("google.calendar.freebusy.query", response);
@@ -1664,16 +1664,16 @@ function createFindMeetingTimesTool(ctx) {
1664
1664
  const checked = [];
1665
1665
  const unavailable2 = [];
1666
1666
  const slotAttendees = [];
1667
- everyone.forEach((email, index) => {
1668
- const calendar = calendars[email];
1667
+ everyone.forEach((email3, index) => {
1668
+ const calendar = calendars[email3];
1669
1669
  const error = calendar?.errors?.[0]?.reason;
1670
1670
  if (!calendar || error) {
1671
- unavailable2.push({ email, reason: error ?? "notFound" });
1671
+ unavailable2.push({ email: email3, reason: error ?? "notFound" });
1672
1672
  return;
1673
1673
  }
1674
1674
  const calendarZone = timeZones[index];
1675
1675
  checked.push({
1676
- email,
1676
+ email: email3,
1677
1677
  ...calendarZone ? { time_zone: calendarZone } : void 0
1678
1678
  });
1679
1679
  slotAttendees.push({
@@ -1681,8 +1681,8 @@ function createFindMeetingTimesTool(ctx) {
1681
1681
  endMs: Date.parse(interval.end),
1682
1682
  startMs: Date.parse(interval.start)
1683
1683
  })),
1684
- email,
1685
- required: required.has(email),
1684
+ email: email3,
1685
+ required: required.has(email3),
1686
1686
  timeZone: calendarZone ?? timeZone
1687
1687
  });
1688
1688
  });
@@ -1730,11 +1730,11 @@ import {
1730
1730
  definePluginTool as definePluginTool4,
1731
1731
  pluginToolOutputSchema as pluginToolOutputSchema4
1732
1732
  } from "@sentry/junior-plugin-api";
1733
- import { z as z7 } from "zod";
1733
+ import * as z7 from "zod";
1734
1734
 
1735
1735
  // src/tools/files.ts
1736
1736
  import { PluginToolInputError as PluginToolInputError4 } from "@sentry/junior-plugin-api";
1737
- import { z as z6 } from "zod";
1737
+ import * as z6 from "zod";
1738
1738
  var FILE_TYPES = {
1739
1739
  document: {
1740
1740
  label: "Google Doc",
@@ -1938,7 +1938,7 @@ import {
1938
1938
  PluginToolInputError as PluginToolInputError5,
1939
1939
  pluginToolOutputSchema as pluginToolOutputSchema5
1940
1940
  } from "@sentry/junior-plugin-api";
1941
- import { z as z8 } from "zod";
1941
+ import * as z8 from "zod";
1942
1942
  var MAX_WINDOW_MS2 = 31 * 24 * 60 * 60 * 1e3;
1943
1943
  var inputSchema5 = z8.object({
1944
1944
  calendar: z8.string().trim().toLowerCase().pipe(z8.email()).optional().describe(
@@ -2092,7 +2092,7 @@ import {
2092
2092
  definePluginTool as definePluginTool6,
2093
2093
  pluginToolOutputSchema as pluginToolOutputSchema6
2094
2094
  } from "@sentry/junior-plugin-api";
2095
- import { z as z9 } from "zod";
2095
+ import * as z9 from "zod";
2096
2096
  var inputSchema6 = z9.object({
2097
2097
  document: fileReferenceSchema("Google Docs")
2098
2098
  }).strict();
@@ -2146,7 +2146,7 @@ import {
2146
2146
  PluginToolInputError as PluginToolInputError6,
2147
2147
  pluginToolOutputSchema as pluginToolOutputSchema7
2148
2148
  } from "@sentry/junior-plugin-api";
2149
- import { z as z10 } from "zod";
2149
+ import * as z10 from "zod";
2150
2150
  var MEETING_RECORD_TITLE = / - \d{4}\/\d{2}\/\d{2} \d{2}:\d{2} \S+ - (Transcript|Notes by Gemini)$/;
2151
2151
  function meetingRecordKind(title) {
2152
2152
  const kind = MEETING_RECORD_TITLE.exec(title)?.[1];
@@ -2230,9 +2230,9 @@ async function saveFullRecord(ctx, eventId, fileId, text2) {
2230
2230
  await ctx.sandbox.writeFile({ content: text2, path });
2231
2231
  return path;
2232
2232
  }
2233
- function isInvited(event, email) {
2234
- return event.organizer?.email?.toLowerCase() === email || (event.attendees ?? []).some(
2235
- (attendee) => attendee.email.toLowerCase() === email
2233
+ function isInvited(event, email3) {
2234
+ return event.organizer?.email?.toLowerCase() === email3 || (event.attendees ?? []).some(
2235
+ (attendee) => attendee.email.toLowerCase() === email3
2236
2236
  );
2237
2237
  }
2238
2238
  async function readInvitedEvent(ctx, eventIdOrLink) {
@@ -2372,7 +2372,7 @@ import {
2372
2372
  definePluginTool as definePluginTool8,
2373
2373
  pluginToolOutputSchema as pluginToolOutputSchema8
2374
2374
  } from "@sentry/junior-plugin-api";
2375
- import { z as z11 } from "zod";
2375
+ import * as z11 from "zod";
2376
2376
  var inputSchema8 = z11.object({
2377
2377
  spreadsheet: fileReferenceSchema("Google Sheets"),
2378
2378
  range: z11.string().trim().min(1).max(500).optional().describe(
@@ -2485,7 +2485,7 @@ import {
2485
2485
  definePluginTool as definePluginTool9,
2486
2486
  pluginToolOutputSchema as pluginToolOutputSchema9
2487
2487
  } from "@sentry/junior-plugin-api";
2488
- import { z as z12 } from "zod";
2488
+ import * as z12 from "zod";
2489
2489
  var inputSchema9 = z12.object({
2490
2490
  presentation: fileReferenceSchema("Google Slides")
2491
2491
  }).strict();
@@ -2614,7 +2614,7 @@ import {
2614
2614
  definePluginTool as definePluginTool10,
2615
2615
  pluginToolOutputSchema as pluginToolOutputSchema10
2616
2616
  } from "@sentry/junior-plugin-api";
2617
- import { z as z13 } from "zod";
2617
+ import * as z13 from "zod";
2618
2618
  var inputSchema10 = z13.object({
2619
2619
  query: z13.string().trim().min(1).max(500).describe("Words to find in the file title or text."),
2620
2620
  types: z13.array(z13.enum(GOOGLE_FILE_TYPES)).min(1).optional().describe(
@@ -2709,7 +2709,7 @@ import {
2709
2709
  PluginToolInputError as PluginToolInputError7,
2710
2710
  pluginToolOutputSchema as pluginToolOutputSchema11
2711
2711
  } from "@sentry/junior-plugin-api";
2712
- import { z as z14 } from "zod";
2712
+ import * as z14 from "zod";
2713
2713
  var inputSchema11 = z14.object({
2714
2714
  event_id: ownEventIdSchema,
2715
2715
  title: z14.string().trim().min(1).max(200).optional(),
@@ -2790,7 +2790,7 @@ function createUpdateCalendarEventTool(ctx) {
2790
2790
  }
2791
2791
  const { event, path } = read;
2792
2792
  const attendees = event.attendees ?? [];
2793
- const emailKey = (email) => email.toLowerCase();
2793
+ const emailKey = (email3) => email3.toLowerCase();
2794
2794
  const removed = new Set(input.remove_attendees);
2795
2795
  const kept = attendees.filter(
2796
2796
  (attendee) => !removed.has(emailKey(attendee.email))
@@ -2799,9 +2799,9 @@ function createUpdateCalendarEventTool(ctx) {
2799
2799
  kept.map((attendee) => emailKey(attendee.email))
2800
2800
  );
2801
2801
  const added = [
2802
- ...input.add_attendees.map((email) => ({ email })),
2803
- ...input.add_optional_attendees.map((email) => ({
2804
- email,
2802
+ ...input.add_attendees.map((email3) => ({ email: email3 })),
2803
+ ...input.add_optional_attendees.map((email3) => ({
2804
+ email: email3,
2805
2805
  optional: true
2806
2806
  }))
2807
2807
  ].filter((attendee) => {
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import { type GoogleToolContext } from "./shared";
3
3
  declare const repeatSchema: z.ZodObject<{
4
4
  frequency: z.ZodEnum<{
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod";
2
2
  import type { GoogleOperation } from "../credentials";
3
3
  import { type GoogleToolContext } from "./shared";
4
4
  /** Google file types that the tools read, with their Drive MIME types. */
@@ -1,5 +1,5 @@
1
1
  import { type PluginEgress, type PluginSandbox, type User } from "@sentry/junior-plugin-api";
2
- import { z } from "zod";
2
+ import * as z from "zod";
3
3
  import { type GoogleOperation } from "../credentials";
4
4
  /** Runtime capabilities the Google tools use. */
5
5
  export interface GoogleToolContext {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-google",
3
- "version": "0.279.0",
3
+ "version": "0.281.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,7 +25,7 @@
25
25
  "commander": "^14.0.3",
26
26
  "drizzle-orm": "^0.45.2",
27
27
  "zod": "^4.5.4",
28
- "@sentry/junior-plugin-api": "0.279.0"
28
+ "@sentry/junior-plugin-api": "0.281.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@oxlint/plugins": "1.79.0",