@sentry/junior-plugin-api 0.306.0 → 0.307.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
@@ -152,6 +152,15 @@ const objectFactsSchema = z.discriminatedUnion("type", [
152
152
  lastCheckedAt: z.iso.datetime({ offset: true }).optional(),
153
153
  trend: trend.optional()
154
154
  }),
155
+ z.strictObject({
156
+ type: z.literal("alert"),
157
+ summary: summary.optional(),
158
+ enabled: z.boolean(),
159
+ projects: z.array(text).max(5),
160
+ trigger: text.optional(),
161
+ notifies: z.array(text).max(5),
162
+ lastTriggeredAt: z.iso.datetime({ offset: true }).optional()
163
+ }),
155
164
  z.strictObject({
156
165
  type: z.literal("trace"),
157
166
  summary: summary.optional(),
@@ -242,106 +251,297 @@ const MONITOR_DETAILS = {
242
251
  cron: "Schedule",
243
252
  uptime: "Checks"
244
253
  };
254
+ function list(values) {
255
+ return values?.length ? `${values.join(", ")}${values.length === 5 ? " (up to 5 shown)" : ""}` : void 0;
256
+ }
257
+ function dateTime(value) {
258
+ return value && new Date(value).toLocaleString(void 0, {
259
+ dateStyle: "medium",
260
+ timeStyle: "short"
261
+ });
262
+ }
263
+ const FACT_FIELDS = {
264
+ code_change: (facts) => [[
265
+ "sourceBranch",
266
+ "Branch",
267
+ facts.sourceBranch
268
+ ]],
269
+ task: (facts) => [
270
+ [
271
+ "assignees",
272
+ "Assignees",
273
+ facts.assignees?.length === 0 ? "Unassigned" : list(facts.assignees)
274
+ ],
275
+ [
276
+ "priority",
277
+ "Priority",
278
+ facts.priority
279
+ ],
280
+ [
281
+ "project",
282
+ "Project",
283
+ facts.project
284
+ ],
285
+ [
286
+ "cycle",
287
+ "Cycle",
288
+ facts.cycle
289
+ ],
290
+ [
291
+ "dueDate",
292
+ "Due",
293
+ facts.dueDate
294
+ ],
295
+ [
296
+ "labels",
297
+ "Labels",
298
+ list(facts.labels)
299
+ ]
300
+ ],
301
+ deployment: (facts) => [
302
+ [
303
+ "environment",
304
+ "Environment",
305
+ facts.environment
306
+ ],
307
+ [
308
+ "project",
309
+ "Project",
310
+ facts.project
311
+ ],
312
+ [
313
+ "revision",
314
+ "Revision",
315
+ facts.revision
316
+ ],
317
+ [
318
+ "branch",
319
+ "Branch",
320
+ facts.branch
321
+ ]
322
+ ],
323
+ calendar_event: (facts) => [[
324
+ "when",
325
+ "When",
326
+ facts.when
327
+ ], [
328
+ "attendees",
329
+ "Attendees",
330
+ list(facts.attendees)
331
+ ]],
332
+ conversation: (facts) => [[
333
+ "participants",
334
+ "Participants",
335
+ list(facts.participants)
336
+ ], [
337
+ "lastActivityAt",
338
+ "Last activity",
339
+ dateTime(facts.lastActivityAt)
340
+ ]],
341
+ document: (facts) => [[
342
+ "owner",
343
+ "Owner",
344
+ facts.owner
345
+ ], [
346
+ "modifiedAt",
347
+ "Modified",
348
+ dateTime(facts.modifiedAt)
349
+ ]],
350
+ message: (facts) => [
351
+ [
352
+ "channel",
353
+ "Channel",
354
+ facts.channel
355
+ ],
356
+ [
357
+ "author",
358
+ "Author",
359
+ facts.author
360
+ ],
361
+ [
362
+ "sentAt",
363
+ "Sent",
364
+ dateTime(facts.sentAt)
365
+ ]
366
+ ],
367
+ web_page: (facts) => [[
368
+ "siteName",
369
+ "Site",
370
+ facts.siteName
371
+ ], [
372
+ "author",
373
+ "Author",
374
+ facts.author
375
+ ]],
376
+ chart: (facts) => [[
377
+ "range",
378
+ "Range",
379
+ facts.range
380
+ ]],
381
+ event: (facts) => [
382
+ [
383
+ "level",
384
+ "Level",
385
+ facts.level
386
+ ],
387
+ [
388
+ "project",
389
+ "Project",
390
+ facts.project
391
+ ],
392
+ [
393
+ "release",
394
+ "Release",
395
+ facts.release
396
+ ],
397
+ [
398
+ "environment",
399
+ "Environment",
400
+ facts.environment
401
+ ]
402
+ ],
403
+ release: (facts) => [
404
+ [
405
+ "projects",
406
+ "Projects",
407
+ list(facts.projects)
408
+ ],
409
+ [
410
+ "newIssues",
411
+ "New issues",
412
+ facts.newIssues?.toLocaleString("en-US")
413
+ ],
414
+ [
415
+ "crashFreeSessions",
416
+ "Crash-free sessions",
417
+ facts.crashFreeSessions === void 0 ? void 0 : `${Number(facts.crashFreeSessions.toFixed(2))}%`
418
+ ],
419
+ [
420
+ "deploys",
421
+ "Deploys",
422
+ facts.deployCount === void 0 ? void 0 : facts.lastDeploy ? `${facts.deployCount.toLocaleString("en-US")}, last to ${facts.lastDeploy.environment}` : facts.deployCount.toLocaleString("en-US")
423
+ ]
424
+ ],
425
+ monitor: (facts) => [
426
+ [
427
+ "kind",
428
+ "Kind",
429
+ MONITOR_KINDS[facts.kind]
430
+ ],
431
+ [
432
+ "project",
433
+ "Project",
434
+ facts.project
435
+ ],
436
+ [
437
+ "environment",
438
+ "Environment",
439
+ facts.environment
440
+ ],
441
+ [
442
+ "detail",
443
+ MONITOR_DETAILS[facts.kind],
444
+ facts.detail
445
+ ]
446
+ ],
447
+ alert: (facts) => [
448
+ [
449
+ "projects",
450
+ facts.projects.length === 1 ? "Project" : "Projects",
451
+ list(facts.projects)
452
+ ],
453
+ [
454
+ "trigger",
455
+ "When",
456
+ facts.trigger
457
+ ],
458
+ [
459
+ "notifies",
460
+ "Notifies",
461
+ list(facts.notifies)
462
+ ],
463
+ [
464
+ "lastTriggeredAt",
465
+ "Last triggered",
466
+ dateTime(facts.lastTriggeredAt)
467
+ ]
468
+ ],
469
+ trace: (facts) => [
470
+ [
471
+ "duration",
472
+ "Duration",
473
+ formatDuration(facts.durationMs)
474
+ ],
475
+ [
476
+ "spans",
477
+ "Spans",
478
+ facts.spanCount.toLocaleString("en-US")
479
+ ],
480
+ [
481
+ "issues",
482
+ "Issues",
483
+ `${plural(facts.errorCount, "error")}, ${plural(facts.performanceIssueCount, "performance issue")}`
484
+ ],
485
+ [
486
+ "projects",
487
+ "Projects",
488
+ list(facts.projects)
489
+ ]
490
+ ],
491
+ dashboard: (facts) => [
492
+ [
493
+ "widgets",
494
+ "Widgets",
495
+ facts.widgetCount.toLocaleString("en-US")
496
+ ],
497
+ [
498
+ "projects",
499
+ "Projects",
500
+ list(facts.projects)
501
+ ],
502
+ [
503
+ "environments",
504
+ "Environments",
505
+ list(facts.environments)
506
+ ],
507
+ [
508
+ "range",
509
+ "Time range",
510
+ facts.range
511
+ ]
512
+ ],
513
+ person: (facts) => [
514
+ [
515
+ "email",
516
+ "Email",
517
+ facts.email
518
+ ],
519
+ [
520
+ "slackHandle",
521
+ "Slack",
522
+ facts.slackHandle && `@${facts.slackHandle}`
523
+ ],
524
+ [
525
+ "githubHandle",
526
+ "GitHub",
527
+ facts.githubHandle && `@${facts.githubHandle}`,
528
+ facts.githubHandle && `https://github.com/${facts.githubHandle}`
529
+ ]
530
+ ]
531
+ };
532
+ function factFields(facts) {
533
+ const read = FACT_FIELDS[facts.type];
534
+ return read(facts);
535
+ }
245
536
  /** Show at most four card attributes, in priority order, on every surface. */
246
537
  function objectFactFields(facts) {
247
538
  if (!facts) return [];
248
- const fields = [];
249
- const list = (values) => values?.length ? `${values.join(", ")}${values.length === 5 ? " (up to 5 shown)" : ""}` : void 0;
250
- function add(key, label, value, href) {
251
- if (value !== void 0 && value !== "") fields.push({
252
- key,
253
- label,
254
- value: String(value),
255
- ...href && { href }
256
- });
257
- }
258
- switch (facts.type) {
259
- case "code_change":
260
- add("sourceBranch", "Branch", facts.sourceBranch);
261
- break;
262
- case "task":
263
- add("assignees", "Assignees", facts.assignees?.length === 0 ? "Unassigned" : list(facts.assignees));
264
- add("priority", "Priority", facts.priority);
265
- add("project", "Project", facts.project);
266
- add("cycle", "Cycle", facts.cycle);
267
- add("dueDate", "Due", facts.dueDate);
268
- add("labels", "Labels", list(facts.labels));
269
- break;
270
- case "deployment":
271
- add("environment", "Environment", facts.environment);
272
- add("project", "Project", facts.project);
273
- add("revision", "Revision", facts.revision);
274
- add("branch", "Branch", facts.branch);
275
- break;
276
- case "calendar_event":
277
- add("when", "When", facts.when);
278
- add("attendees", "Attendees", list(facts.attendees));
279
- break;
280
- case "conversation":
281
- add("participants", "Participants", list(facts.participants));
282
- add("lastActivityAt", "Last activity", facts.lastActivityAt && new Date(facts.lastActivityAt).toLocaleString(void 0, {
283
- dateStyle: "medium",
284
- timeStyle: "short"
285
- }));
286
- break;
287
- case "document":
288
- add("owner", "Owner", facts.owner);
289
- add("modifiedAt", "Modified", facts.modifiedAt && new Date(facts.modifiedAt).toLocaleString(void 0, {
290
- dateStyle: "medium",
291
- timeStyle: "short"
292
- }));
293
- break;
294
- case "message":
295
- add("channel", "Channel", facts.channel);
296
- add("author", "Author", facts.author);
297
- add("sentAt", "Sent", facts.sentAt && new Date(facts.sentAt).toLocaleString(void 0, {
298
- dateStyle: "medium",
299
- timeStyle: "short"
300
- }));
301
- break;
302
- case "web_page":
303
- add("siteName", "Site", facts.siteName);
304
- add("author", "Author", facts.author);
305
- break;
306
- case "chart":
307
- add("range", "Range", facts.range);
308
- break;
309
- case "event":
310
- add("level", "Level", facts.level);
311
- add("project", "Project", facts.project);
312
- add("release", "Release", facts.release);
313
- add("environment", "Environment", facts.environment);
314
- break;
315
- case "release":
316
- add("projects", "Projects", list(facts.projects));
317
- add("newIssues", "New issues", facts.newIssues?.toLocaleString("en-US"));
318
- add("crashFreeSessions", "Crash-free sessions", facts.crashFreeSessions === void 0 ? void 0 : `${Number(facts.crashFreeSessions.toFixed(2))}%`);
319
- add("deploys", "Deploys", facts.deployCount === void 0 ? void 0 : facts.lastDeploy ? `${facts.deployCount.toLocaleString("en-US")}, last to ${facts.lastDeploy.environment}` : facts.deployCount.toLocaleString("en-US"));
320
- break;
321
- case "monitor":
322
- add("kind", "Kind", MONITOR_KINDS[facts.kind]);
323
- add("project", "Project", facts.project);
324
- add("environment", "Environment", facts.environment);
325
- add("detail", MONITOR_DETAILS[facts.kind], facts.detail);
326
- break;
327
- case "trace":
328
- add("duration", "Duration", formatDuration(facts.durationMs));
329
- add("spans", "Spans", facts.spanCount.toLocaleString("en-US"));
330
- add("issues", "Issues", `${plural(facts.errorCount, "error")}, ${plural(facts.performanceIssueCount, "performance issue")}`);
331
- add("projects", "Projects", list(facts.projects));
332
- break;
333
- case "dashboard":
334
- add("widgets", "Widgets", facts.widgetCount.toLocaleString("en-US"));
335
- add("projects", "Projects", list(facts.projects));
336
- add("environments", "Environments", list(facts.environments));
337
- add("range", "Time range", facts.range);
338
- break;
339
- case "person":
340
- add("email", "Email", facts.email);
341
- add("slackHandle", "Slack", facts.slackHandle && `@${facts.slackHandle}`);
342
- add("githubHandle", "GitHub", facts.githubHandle && `@${facts.githubHandle}`, facts.githubHandle && `https://github.com/${facts.githubHandle}`);
343
- }
344
- return fields.slice(0, 4);
539
+ return factFields(facts).filter(([, , value]) => value !== void 0 && value !== "").map(([key, label, value, href]) => ({
540
+ key,
541
+ label,
542
+ value: String(value),
543
+ ...href && { href }
544
+ })).slice(0, 4);
345
545
  }
346
546
  // src/object-presentation.ts
347
547
  /** Native object types. `task` is the stored name for a Ticket. */
@@ -362,6 +562,7 @@ const objectTypeSchema = z.enum([
362
562
  "release",
363
563
  "dashboard",
364
564
  "monitor",
565
+ "alert",
365
566
  "item"
366
567
  ]);
367
568
  const objectTypeLabels = {
@@ -381,6 +582,7 @@ const objectTypeLabels = {
381
582
  release: "Release",
382
583
  dashboard: "Dashboard",
383
584
  monitor: "Monitor",
585
+ alert: "Alert",
384
586
  item: "Item"
385
587
  };
386
588
  /** Resolve identity and state without replacing the type icon with a warning. */
@@ -404,6 +606,7 @@ function objectPresentation(object) {
404
606
  release: "tag",
405
607
  dashboard: "apps",
406
608
  monitor: "bell",
609
+ alert: "bell",
407
610
  item: "package"
408
611
  }[type];
409
612
  let tone = type === "automation" ? "info" : "neutral";
@@ -433,6 +636,8 @@ function objectPresentation(object) {
433
636
  if (state === "ok") tone = "success";
434
637
  if (state === "failing") tone = "danger";
435
638
  if (state === "pending") tone = "info";
639
+ } else if (type === "alert") {
640
+ if (object.facts?.enabled) tone = "success";
436
641
  } else if (type === "conversation") {
437
642
  if (status === "running") tone = "info";
438
643
  if (status === "failed") tone = "danger";
@@ -1380,16 +1585,16 @@ const pluginEventTypeSchema = z.object({
1380
1585
  matchFields: eventMatchFieldsSchema.optional()
1381
1586
  }).strict().superRefine((resourceType, context) => {
1382
1587
  const supported = /* @__PURE__ */ new Set();
1383
- resourceType.supportedEvents.forEach((eventType, index) => {
1588
+ for (const [index, eventType] of resourceType.supportedEvents.entries()) {
1384
1589
  if (supported.has(eventType)) context.addIssue({
1385
1590
  code: "custom",
1386
1591
  message: `Duplicate supported event type "${eventType}".`,
1387
1592
  path: ["supportedEvents", index]
1388
1593
  });
1389
1594
  supported.add(eventType);
1390
- });
1595
+ }
1391
1596
  const suggested = /* @__PURE__ */ new Set();
1392
- resourceType.suggestedEvents?.forEach((eventType, index) => {
1597
+ for (const [index, eventType] of (resourceType.suggestedEvents ?? []).entries()) {
1393
1598
  if (suggested.has(eventType)) context.addIssue({
1394
1599
  code: "custom",
1395
1600
  message: `Duplicate suggested event type "${eventType}".`,
@@ -1401,18 +1606,16 @@ const pluginEventTypeSchema = z.object({
1401
1606
  path: ["suggestedEvents", index]
1402
1607
  });
1403
1608
  suggested.add(eventType);
1404
- });
1405
- for (const [key, field] of Object.entries(resourceType.matchFields ?? {})) field.events?.forEach((eventType, index) => {
1406
- if (!supported.has(eventType)) context.addIssue({
1407
- code: "custom",
1408
- message: `Match field "${key}" event type "${eventType}" is not supported.`,
1409
- path: [
1410
- "matchFields",
1411
- key,
1412
- "events",
1413
- index
1414
- ]
1415
- });
1609
+ }
1610
+ for (const [key, field] of Object.entries(resourceType.matchFields ?? {})) for (const [index, eventType] of (field.events ?? []).entries()) if (!supported.has(eventType)) context.addIssue({
1611
+ code: "custom",
1612
+ message: `Match field "${key}" event type "${eventType}" is not supported.`,
1613
+ path: [
1614
+ "matchFields",
1615
+ key,
1616
+ "events",
1617
+ index
1618
+ ]
1416
1619
  });
1417
1620
  });
1418
1621
  /**
@@ -1471,7 +1674,7 @@ const pluginEventsSchema = z.object({
1471
1674
  }).optional()
1472
1675
  }).strict().superRefine((registration, context) => {
1473
1676
  const seen = /* @__PURE__ */ new Set();
1474
- registration.resourceTypes.forEach((resourceType, index) => {
1677
+ for (const [index, resourceType] of registration.resourceTypes.entries()) {
1475
1678
  if (seen.has(resourceType.type)) context.addIssue({
1476
1679
  code: "custom",
1477
1680
  message: `Duplicate resource type "${resourceType.type}".`,
@@ -1482,7 +1685,7 @@ const pluginEventsSchema = z.object({
1482
1685
  ]
1483
1686
  });
1484
1687
  seen.add(resourceType.type);
1485
- });
1688
+ }
1486
1689
  const supported = new Set(registration.resourceTypes.flatMap((resourceType) => resourceType.supportedEvents));
1487
1690
  for (const eventType of supported) if (!registration.events[eventType]) context.addIssue({
1488
1691
  code: "custom",
@@ -2354,6 +2557,11 @@ const pluginUserPageContentSchema = z.object({
2354
2557
  metrics: z.array(pluginUserPageMetricSchema).max(6).optional(),
2355
2558
  nextCursor: nonBlankStringSchema.max(1e3).optional(),
2356
2559
  records: z.array(pluginUserPageRecordSchema).max(100),
2560
+ /**
2561
+ * Set when `read` matches `input.query`. The dashboard's command palette
2562
+ * then keeps every returned record as a match; without it, the palette
2563
+ * matches titles and descriptions itself.
2564
+ */
2357
2565
  searchPlaceholder: nonBlankStringSchema.max(120).optional(),
2358
2566
  type: z.literal("list")
2359
2567
  }).strict();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.306.0",
3
+ "version": "0.307.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,6 +15,10 @@
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
17
  "default": "./dist/index.js"
18
+ },
19
+ "./embeddings": {
20
+ "types": "./dist/embeddings.d.ts",
21
+ "default": "./dist/embeddings.js"
18
22
  }
19
23
  },
20
24
  "files": [
@@ -23,6 +27,7 @@
23
27
  ],
24
28
  "dependencies": {
25
29
  "commander": "^14.0.3",
30
+ "drizzle-orm": "^0.45.4",
26
31
  "zod": "^4.6.7"
27
32
  },
28
33
  "devDependencies": {