@sentry/junior-google 0.300.0 → 0.301.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 +46 -18
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1143,23 +1143,35 @@ function viewerIsOnEvent(event, viewer) {
|
|
|
1143
1143
|
...(event.attendees ?? []).map((attendee) => attendee.email)
|
|
1144
1144
|
].some((email3) => email3?.toLowerCase() === viewer);
|
|
1145
1145
|
}
|
|
1146
|
-
|
|
1146
|
+
var EVENT_READ_TTL_MS = 1e4;
|
|
1147
|
+
async function readLinkedEvent(ctx, url) {
|
|
1147
1148
|
const config = readGoogleConfig();
|
|
1148
1149
|
const eventId = config && parseEventLink(url, config.accountEmail);
|
|
1149
|
-
if (!eventId) return
|
|
1150
|
+
if (!eventId) return null;
|
|
1151
|
+
return await ctx.cache.getOrLoad(`calendar-event:${eventId}`, async () => ({
|
|
1152
|
+
value: await fetchLinkedEvent(ctx, eventId),
|
|
1153
|
+
ttlMs: EVENT_READ_TTL_MS
|
|
1154
|
+
}));
|
|
1155
|
+
}
|
|
1156
|
+
async function fetchLinkedEvent(ctx, eventId) {
|
|
1150
1157
|
const response = await googleApiRequest(ctx, {
|
|
1151
1158
|
operation: "google.calendar.event.get",
|
|
1152
1159
|
path: `/calendar/v3/calendars/primary/events/${eventId}`
|
|
1153
1160
|
});
|
|
1154
|
-
if ([403, 404, 410].includes(response.status)) return
|
|
1161
|
+
if ([403, 404, 410].includes(response.status)) return null;
|
|
1155
1162
|
if (response.status !== 200) {
|
|
1156
1163
|
throw googleApiError("google.calendar.event.get", response);
|
|
1157
1164
|
}
|
|
1158
1165
|
const parsed = linkedEventSchema.safeParse(response.body);
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1166
|
+
return parsed.success && parsed.data.status !== "cancelled" ? parsed.data : null;
|
|
1167
|
+
}
|
|
1168
|
+
async function canViewGoogleCalendarLink(ctx, url) {
|
|
1169
|
+
const event = await readLinkedEvent(ctx, url);
|
|
1170
|
+
return !!event && viewerIsOnEvent(event, ctx.viewer.email.toLowerCase());
|
|
1171
|
+
}
|
|
1172
|
+
async function resolveGoogleCalendarLink(ctx, url) {
|
|
1173
|
+
const event = await readLinkedEvent(ctx, url);
|
|
1174
|
+
if (!event) return void 0;
|
|
1163
1175
|
const title = event.summary?.trim() || "Untitled event";
|
|
1164
1176
|
return {
|
|
1165
1177
|
kind: "object",
|
|
@@ -1183,6 +1195,7 @@ var googleCalendarLinks = {
|
|
|
1183
1195
|
{ host: "calendar.google.com", pathPattern: "/calendar/r/eventedit/*" },
|
|
1184
1196
|
{ host: "calendar.google.com", pathPattern: "/calendar/u/*/r/eventedit/*" }
|
|
1185
1197
|
],
|
|
1198
|
+
canView: canViewGoogleCalendarLink,
|
|
1186
1199
|
objectType: "calendar_event",
|
|
1187
1200
|
resolve: resolveGoogleCalendarLink
|
|
1188
1201
|
};
|
|
@@ -1425,10 +1438,18 @@ async function viewerCanOpen(ctx, file, allowedDomains) {
|
|
|
1425
1438
|
]);
|
|
1426
1439
|
return checks.some(Boolean);
|
|
1427
1440
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1441
|
+
var FILE_READ_TTL_MS = 1e4;
|
|
1442
|
+
async function readLinkedFile(ctx, link) {
|
|
1443
|
+
const { fileId, resourceKey } = link.file;
|
|
1444
|
+
return await ctx.cache.getOrLoad(
|
|
1445
|
+
`drive-file:${link.type}:${fileId}:${resourceKey ?? ""}`,
|
|
1446
|
+
async () => ({
|
|
1447
|
+
value: await fetchLinkedFile(ctx, link),
|
|
1448
|
+
ttlMs: FILE_READ_TTL_MS
|
|
1449
|
+
})
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
async function fetchLinkedFile(ctx, link) {
|
|
1432
1453
|
const response = await googleApiRequest(ctx, {
|
|
1433
1454
|
headers: resourceKeyHeaders(link.file),
|
|
1434
1455
|
operation: "google.drive.file.get",
|
|
@@ -1438,17 +1459,23 @@ async function resolveGoogleFileLink(ctx, url) {
|
|
|
1438
1459
|
supportsAllDrives: "true"
|
|
1439
1460
|
}
|
|
1440
1461
|
});
|
|
1441
|
-
if (response.status === 403 || response.status === 404) return
|
|
1462
|
+
if (response.status === 403 || response.status === 404) return null;
|
|
1442
1463
|
if (response.status !== 200) {
|
|
1443
1464
|
throw googleApiError("google.drive.file.get", response);
|
|
1444
1465
|
}
|
|
1445
1466
|
const file = linkedFileSchema.parse(response.body);
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1467
|
+
return file.trashed || googleFileType(file.mimeType) !== link.type ? null : file;
|
|
1468
|
+
}
|
|
1469
|
+
async function canViewGoogleFileLink(ctx, url) {
|
|
1470
|
+
const config = readGoogleConfig();
|
|
1471
|
+
const link = parseFileLink(url);
|
|
1472
|
+
const file = config && link && await readLinkedFile(ctx, link);
|
|
1473
|
+
return !!file && await viewerCanOpen(ctx, file, config.allowedDomains);
|
|
1474
|
+
}
|
|
1475
|
+
async function resolveGoogleFileLink(ctx, url) {
|
|
1476
|
+
const link = parseFileLink(url);
|
|
1477
|
+
const file = link && await readLinkedFile(ctx, link);
|
|
1478
|
+
if (!file) return void 0;
|
|
1452
1479
|
const summary = link.type === "document" ? await docSummary(ctx, link.file) : void 0;
|
|
1453
1480
|
const owner = file.owners?.[0];
|
|
1454
1481
|
const ownerName = (owner?.displayName || owner?.emailAddress)?.trim();
|
|
@@ -1477,6 +1504,7 @@ var googleFileLinks = {
|
|
|
1477
1504
|
pathPrefix
|
|
1478
1505
|
}))
|
|
1479
1506
|
),
|
|
1507
|
+
canView: canViewGoogleFileLink,
|
|
1480
1508
|
objectType: "document",
|
|
1481
1509
|
// One tool reads every file type; it takes the type from the link.
|
|
1482
1510
|
readTool: "readGoogleFile",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-google",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.301.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,13 +26,15 @@
|
|
|
26
26
|
"drizzle-orm": "^0.45.4",
|
|
27
27
|
"parse5": "^7.3.0",
|
|
28
28
|
"zod": "^4.6.7",
|
|
29
|
-
"@sentry/junior-plugin-api": "0.
|
|
29
|
+
"@sentry/junior-plugin-api": "0.301.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@oxlint/plugins": "1.79.0",
|
|
33
33
|
"@types/node": "^25.9.1",
|
|
34
|
+
"@types/pg": "^8.15.6",
|
|
34
35
|
"drizzle-kit": "^0.31.8",
|
|
35
36
|
"oxlint": "^1.79.0",
|
|
37
|
+
"pg": "^8.16.3",
|
|
36
38
|
"tsup": "^8.5.1",
|
|
37
39
|
"typescript": "^7.0.2",
|
|
38
40
|
"vitest": "^4.1.12",
|