@sentry/junior-plugin-api 0.298.0 → 0.300.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1822 -1506
  2. package/dist/index.js +252 -5
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,10 +2,14 @@ import * as z from "zod";
2
2
  // src/object-facts.ts
3
3
  const text = z.string().trim().min(1).max(160);
4
4
  const count = z.number().int().nonnegative();
5
+ /** The longest object summary, in UTF-16 code units. */
6
+ const OBJECT_SUMMARY_MAX_LENGTH = 280;
7
+ const summary = z.string().trim().min(1).max(280);
5
8
  /** Small, provider-neutral facts. Missing values mean unknown, not success. */
6
9
  const objectFactsSchema = z.discriminatedUnion("type", [
7
10
  z.strictObject({
8
11
  type: z.literal("code_change"),
12
+ summary: summary.optional(),
9
13
  author: text.optional(),
10
14
  sourceBranch: text.optional(),
11
15
  targetBranch: text.optional(),
@@ -23,10 +27,16 @@ const objectFactsSchema = z.discriminatedUnion("type", [
23
27
  mergeable: z.boolean().optional(),
24
28
  changedFiles: count.optional(),
25
29
  additions: count.optional(),
26
- deletions: count.optional()
30
+ deletions: count.optional(),
31
+ /**
32
+ * Public images from the description that the dashboard can show. The
33
+ * 4 KiB facts limit sets how many fit.
34
+ */
35
+ previewImageUrls: z.array(z.url({ protocol: /^https?$/ }).max(512)).min(1).optional()
27
36
  }),
28
37
  z.strictObject({
29
38
  type: z.literal("task"),
39
+ summary: summary.optional(),
30
40
  assignees: z.array(text).max(5).optional(),
31
41
  priority: text.optional(),
32
42
  project: text.optional(),
@@ -36,6 +46,7 @@ const objectFactsSchema = z.discriminatedUnion("type", [
36
46
  }),
37
47
  z.strictObject({
38
48
  type: z.literal("deployment"),
49
+ summary: summary.optional(),
39
50
  project: text.optional(),
40
51
  environment: text.optional(),
41
52
  revision: text.optional(),
@@ -43,20 +54,76 @@ const objectFactsSchema = z.discriminatedUnion("type", [
43
54
  }),
44
55
  z.strictObject({
45
56
  type: z.literal("calendar_event"),
57
+ summary: summary.optional(),
46
58
  when: text.optional(),
47
59
  attendees: z.array(text).max(5).optional()
60
+ }),
61
+ z.strictObject({
62
+ type: z.literal("conversation"),
63
+ summary: summary.optional(),
64
+ participants: z.array(text).max(5).optional(),
65
+ lastActivityAt: z.iso.datetime({ offset: true }).optional()
66
+ }),
67
+ z.strictObject({
68
+ type: z.literal("document"),
69
+ summary: summary.optional(),
70
+ owner: text.optional(),
71
+ modifiedAt: z.iso.datetime({ offset: true }).optional()
72
+ }),
73
+ z.strictObject({
74
+ type: z.literal("message"),
75
+ summary: summary.optional(),
76
+ channel: text.optional(),
77
+ author: text.optional(),
78
+ sentAt: z.iso.datetime({ offset: true }).optional()
79
+ }),
80
+ z.strictObject({
81
+ type: z.literal("web_page"),
82
+ summary: summary.optional(),
83
+ siteName: text.optional(),
84
+ author: text.optional(),
85
+ thumbnailUrl: z.string().max(4e3).regex(/^\/api\/images\/[\w-]+\.[\w-]+\?w=\d+$/).optional()
86
+ }),
87
+ z.strictObject({
88
+ type: z.literal("person"),
89
+ summary: summary.optional(),
90
+ email: text.optional(),
91
+ slackHandle: text.optional(),
92
+ githubHandle: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/).optional(),
93
+ avatarUrl: z.string().max(500).regex(/^\/api\/people\/avatars\/[^/?#]+(\?v=[\w-]+)?$/).optional()
48
94
  })
49
95
  ]);
96
+ /**
97
+ * Make an object summary from plain text. Join whitespace and cut overlong
98
+ * text at a word, with an ellipsis. Empty text gives no summary.
99
+ */
100
+ function objectSummary(text) {
101
+ const words = text.split(/\s+/).filter(Boolean);
102
+ const joined = words.join(" ");
103
+ if (joined.length <= 280) return joined || void 0;
104
+ let cut = "";
105
+ for (const word of words) {
106
+ const next = cut ? `${cut} ${word}` : word;
107
+ if (next.length >= 280) break;
108
+ cut = next;
109
+ }
110
+ if (!cut) {
111
+ cut = joined.slice(0, 279);
112
+ if (/[\ud800-\udbff]$/.test(cut)) cut = cut.slice(0, -1);
113
+ }
114
+ return `${cut}…`;
115
+ }
50
116
  /** Show at most four card attributes, in priority order, on every surface. */
51
117
  function objectFactFields(facts) {
52
118
  if (!facts) return [];
53
119
  const fields = [];
54
120
  const list = (values) => values?.length ? `${values.join(", ")}${values.length === 5 ? " (up to 5 shown)" : ""}` : void 0;
55
- function add(key, label, value) {
121
+ function add(key, label, value, href) {
56
122
  if (value !== void 0 && value !== "") fields.push({
57
123
  key,
58
124
  label,
59
- value: String(value)
125
+ value: String(value),
126
+ ...href && { href }
60
127
  });
61
128
  }
62
129
  switch (facts.type) {
@@ -80,6 +147,37 @@ function objectFactFields(facts) {
80
147
  case "calendar_event":
81
148
  add("when", "When", facts.when);
82
149
  add("attendees", "Attendees", list(facts.attendees));
150
+ break;
151
+ case "conversation":
152
+ add("participants", "Participants", list(facts.participants));
153
+ add("lastActivityAt", "Last activity", facts.lastActivityAt && new Date(facts.lastActivityAt).toLocaleString(void 0, {
154
+ dateStyle: "medium",
155
+ timeStyle: "short"
156
+ }));
157
+ break;
158
+ case "document":
159
+ add("owner", "Owner", facts.owner);
160
+ add("modifiedAt", "Modified", facts.modifiedAt && new Date(facts.modifiedAt).toLocaleString(void 0, {
161
+ dateStyle: "medium",
162
+ timeStyle: "short"
163
+ }));
164
+ break;
165
+ case "message":
166
+ add("channel", "Channel", facts.channel);
167
+ add("author", "Author", facts.author);
168
+ add("sentAt", "Sent", facts.sentAt && new Date(facts.sentAt).toLocaleString(void 0, {
169
+ dateStyle: "medium",
170
+ timeStyle: "short"
171
+ }));
172
+ break;
173
+ case "web_page":
174
+ add("siteName", "Site", facts.siteName);
175
+ add("author", "Author", facts.author);
176
+ break;
177
+ case "person":
178
+ add("email", "Email", facts.email);
179
+ add("slackHandle", "Slack", facts.slackHandle && `@${facts.slackHandle}`);
180
+ add("githubHandle", "GitHub", facts.githubHandle && `@${facts.githubHandle}`, facts.githubHandle && `https://github.com/${facts.githubHandle}`);
83
181
  }
84
182
  return fields.slice(0, 4);
85
183
  }
@@ -91,6 +189,11 @@ const objectTypeSchema = z.enum([
91
189
  "automation",
92
190
  "deployment",
93
191
  "calendar_event",
192
+ "conversation",
193
+ "person",
194
+ "document",
195
+ "message",
196
+ "web_page",
94
197
  "item"
95
198
  ]);
96
199
  const objectTypeLabels = {
@@ -99,6 +202,11 @@ const objectTypeLabels = {
99
202
  automation: "Automation",
100
203
  deployment: "Deployment",
101
204
  calendar_event: "Calendar event",
205
+ conversation: "Conversation",
206
+ person: "Person",
207
+ document: "Document",
208
+ message: "Message",
209
+ web_page: "Web page",
102
210
  item: "Item"
103
211
  };
104
212
  /** Resolve identity and state without replacing the type icon with a warning. */
@@ -111,6 +219,11 @@ function objectPresentation(object) {
111
219
  automation: "workflow",
112
220
  deployment: "rocket",
113
221
  calendar_event: "calendar",
222
+ conversation: "comment-discussion",
223
+ person: "person",
224
+ document: "file",
225
+ message: "comment",
226
+ web_page: "globe",
114
227
  item: "package"
115
228
  }[type];
116
229
  let tone = type === "automation" ? "info" : "neutral";
@@ -135,6 +248,9 @@ function objectPresentation(object) {
135
248
  if (status === "ready" || status === "succeeded") tone = "success";
136
249
  if (status === "error" || status === "failed") tone = "danger";
137
250
  if (status === "building" || status === "in_progress") tone = "info";
251
+ } else if (type === "conversation") {
252
+ if (status === "running") tone = "info";
253
+ if (status === "failed") tone = "danger";
138
254
  }
139
255
  if (status === "warning" || status === "blocked") tone = "warning";
140
256
  return {
@@ -152,6 +268,25 @@ function objectIconPath(icon) {
152
268
  function objectFactsMatchType(facts, objectType) {
153
269
  return facts.type === "deployment" ? objectType === "deployment" || objectType === "item" : facts.type === objectType;
154
270
  }
271
+ /** The largest size of object facts, in UTF-8 bytes of their JSON. */
272
+ const OBJECT_FACTS_MAX_BYTES = 4096;
273
+ /** Return the size that the object facts limit counts. */
274
+ function objectFactsBytes(facts) {
275
+ return utf8ByteLength(JSON.stringify(facts));
276
+ }
277
+ function utf8ByteLength(text) {
278
+ let bytes = 0;
279
+ for (let index = 0; index < text.length; index += 1) {
280
+ const code = text.charCodeAt(index);
281
+ if (code < 128) bytes += 1;
282
+ else if (code < 2048) bytes += 2;
283
+ else if (code >= 55296 && code <= 56319 && (text.charCodeAt(index + 1) & 64512) === 56320) {
284
+ bytes += 4;
285
+ index += 1;
286
+ } else bytes += 3;
287
+ }
288
+ return bytes;
289
+ }
155
290
  /**
156
291
  * Verified facts shared by Conversation annotations and Message cards.
157
292
  * Plugins select small facts from responses they already have. Each surface owns
@@ -177,7 +312,7 @@ const objectAnnotationSchema = z.object({
177
312
  warning: z.string().max(1e3).optional(),
178
313
  displayType: z.string().trim().min(1).max(80).optional(),
179
314
  sourceUpdatedAt: z.iso.datetime({ offset: true }).optional(),
180
- facts: objectFactsSchema.refine((facts) => new TextEncoder().encode(JSON.stringify(facts)).length <= 4096, "Object facts must not exceed 4 KiB").optional()
315
+ facts: objectFactsSchema.refine((facts) => objectFactsBytes(facts) <= OBJECT_FACTS_MAX_BYTES, "Object facts must not exceed 4 KiB").optional()
181
316
  }).strict().refine((annotation) => !annotation.facts || objectFactsMatchType(annotation.facts, annotation.objectType), "Object facts must match the object type");
182
317
  /** A saved object snapshot with its trusted owner. */
183
318
  const ownedObjectAnnotationSchema = objectAnnotationSchema.safeExtend({ plugin: z.string().min(1) });
@@ -193,8 +328,102 @@ const objectIconPaths = {
193
328
  workflow: ["M0 1.75C0 .784.784 0 1.75 0h3.5C6.216 0 7 .784 7 1.75v3.5A1.75 1.75 0 0 1 5.25 7H4v4a1 1 0 0 0 1 1h4v-1.25C9 9.784 9.784 9 10.75 9h3.5c.966 0 1.75.784 1.75 1.75v3.5A1.75 1.75 0 0 1 14.25 16h-3.5A1.75 1.75 0 0 1 9 14.25v-.75H5A2.5 2.5 0 0 1 2.5 11V7h-.75A1.75 1.75 0 0 1 0 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Zm9 9a.25.25 0 0 0-.25.25v3.5c0 .138.112.25.25.25h3.5a.25.25 0 0 0 .25-.25v-3.5a.25.25 0 0 0-.25-.25Z"],
194
329
  rocket: ["M14.064 0h.186C15.216 0 16 .784 16 1.75v.186a8.752 8.752 0 0 1-2.564 6.186l-.458.459c-.314.314-.641.616-.979.904v3.207c0 .608-.315 1.172-.833 1.49l-2.774 1.707a.749.749 0 0 1-1.11-.418l-.954-3.102a1.214 1.214 0 0 1-.145-.125L3.754 9.816a1.218 1.218 0 0 1-.124-.145L.528 8.717a.749.749 0 0 1-.418-1.11l1.71-2.774A1.748 1.748 0 0 1 3.31 4h3.204c.288-.338.59-.665.904-.979l.459-.458A8.749 8.749 0 0 1 14.064 0ZM8.938 3.623h-.002l-.458.458c-.76.76-1.437 1.598-2.02 2.5l-1.5 2.317 2.143 2.143 2.317-1.5c.902-.583 1.74-1.26 2.499-2.02l.459-.458a7.25 7.25 0 0 0 2.123-5.127V1.75a.25.25 0 0 0-.25-.25h-.186a7.249 7.249 0 0 0-5.125 2.123ZM3.56 14.56c-.732.732-2.334 1.045-3.005 1.148a.234.234 0 0 1-.201-.064.234.234 0 0 1-.064-.201c.103-.671.416-2.273 1.15-3.003a1.502 1.502 0 1 1 2.12 2.12Zm6.94-3.935c-.088.06-.177.118-.266.175l-2.35 1.521.548 1.783 1.949-1.2a.25.25 0 0 0 .119-.213ZM3.678 8.116 5.2 5.766c.058-.09.117-.178.176-.266H3.309a.25.25 0 0 0-.213.119l-1.2 1.95ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"],
195
330
  calendar: ["M4.75 0a.75.75 0 0 1 .75.75V2h5V.75a.75.75 0 0 1 1.5 0V2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V3.75C1 2.784 1.784 2 2.75 2H4V.75A.75.75 0 0 1 4.75 0ZM2.5 7.5v6.75c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V7.5Zm10.75-4H2.75a.25.25 0 0 0-.25.25V6h11V3.75a.25.25 0 0 0-.25-.25Z"],
331
+ "comment-discussion": ["M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.061l-2.574 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.458 1.458 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h1a.25.25 0 0 0 .25-.25Z"],
332
+ person: ["M10.561 8.073a6.005 6.005 0 0 1 3.432 5.142.75.75 0 1 1-1.498.07 4.5 4.5 0 0 0-8.99 0 .75.75 0 0 1-1.498-.07 6.004 6.004 0 0 1 3.431-5.142 3.999 3.999 0 1 1 5.123 0ZM10.5 5a2.5 2.5 0 1 0-5 0 2.5 2.5 0 0 0 5 0Z"],
333
+ file: ["M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"],
334
+ comment: ["M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"],
335
+ globe: ["M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM5.78 8.75a9.64 9.64 0 0 0 1.363 4.177c.255.426.542.832.857 1.215.245-.296.551-.705.857-1.215A9.64 9.64 0 0 0 10.22 8.75Zm4.44-1.5a9.64 9.64 0 0 0-1.363-4.177c-.307-.51-.612-.919-.857-1.215a9.927 9.927 0 0 0-.857 1.215A9.64 9.64 0 0 0 5.78 7.25Zm-5.944 1.5H1.543a6.507 6.507 0 0 0 4.666 5.5c-.123-.181-.24-.365-.352-.552-.715-1.192-1.437-2.874-1.581-4.948Zm-2.733-1.5h2.733c.144-2.074.866-3.756 1.58-4.948.12-.197.237-.381.353-.552a6.507 6.507 0 0 0-4.666 5.5Zm10.181 1.5c-.144 2.074-.866 3.756-1.58 4.948-.12.197-.237.381-.353.552a6.507 6.507 0 0 0 4.666-5.5Zm2.733-1.5a6.507 6.507 0 0 0-4.666-5.5c.123.181.24.365.353.552.714 1.192 1.436 2.874 1.58 4.948Z"],
196
336
  package: ["m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"]
197
337
  };
338
+ // src/object-links.ts
339
+ /**
340
+ * Link types: URLs that a plugin or core can show as object cards.
341
+ *
342
+ * A link type declares static filters, like an Android `<intent-filter>`.
343
+ * Junior matches a URL against the filters without plugin code, and then
344
+ * calls the `resolve` of the most specific match for the viewer.
345
+ */
346
+ const hostSchema = z.string().regex(/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*(:\d+)?$/, "Use a lowercase host, or `*.` and a lowercase domain.");
347
+ const pathSchema = z.string().max(500).startsWith("/");
348
+ const pathPatternSchema = pathSchema.regex(/^(\/([^/*]+|\*))+$/, "Use `/` segments. A `*` segment matches one segment.");
349
+ /** Which URLs a link type claims. Give at most one path field. */
350
+ const objectLinkFilterSchema = z.strictObject({
351
+ /** Defaults to `https`. */
352
+ scheme: z.enum([
353
+ "https",
354
+ "http",
355
+ "mailto"
356
+ ]).optional(),
357
+ /** An exact host, or `*.example.com` for its subdomains. */
358
+ host: hostSchema.optional(),
359
+ path: pathSchema.optional(),
360
+ pathPattern: pathPatternSchema.optional(),
361
+ pathPrefix: pathSchema.optional()
362
+ }).refine((filter) => [
363
+ filter.path,
364
+ filter.pathPattern,
365
+ filter.pathPrefix
366
+ ].filter((value) => value !== void 0).length <= 1, "Give at most one of path, pathPattern, and pathPrefix.").refine((filter) => filter.scheme === "mailto" ? filter.host === void 0 && !hasPathFilter(filter) : filter.host !== void 0, "An http or https filter needs a host. A mailto filter has no host or path.");
367
+ function hasPathFilter(filter) {
368
+ return filter.path !== void 0 || filter.pathPattern !== void 0 || filter.pathPrefix !== void 0;
369
+ }
370
+ function normalizedPath(url) {
371
+ const path = url.pathname;
372
+ return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
373
+ }
374
+ /** Return whether a filter claims a URL. A trailing slash does not count. */
375
+ function objectLinkFilterMatches(filter, url) {
376
+ if (url.protocol !== `${filter.scheme ?? "https"}:`) return false;
377
+ if (filter.host !== void 0) {
378
+ const host = url.host.toLowerCase();
379
+ if (!(filter.host.startsWith("*.") ? host.endsWith(filter.host.slice(1)) : host === filter.host)) return false;
380
+ }
381
+ const path = normalizedPath(url);
382
+ if (filter.path !== void 0) return path === filter.path;
383
+ if (filter.pathPrefix !== void 0) return path.startsWith(filter.pathPrefix);
384
+ if (filter.pathPattern !== void 0) {
385
+ const pattern = filter.pathPattern.split("/");
386
+ const segments = path.split("/");
387
+ return pattern.length === segments.length && pattern.every((part, index) => part === "*" ? segments[index] !== "" : part === segments[index]);
388
+ }
389
+ return true;
390
+ }
391
+ /**
392
+ * Rank how specific a filter is. Compare ranks in order: an exact host
393
+ * before a wildcard host, an exact path before a pattern before a prefix,
394
+ * and then the longer match.
395
+ */
396
+ function objectLinkFilterSpecificity(filter) {
397
+ const host = filter.host ?? "";
398
+ const hostRank = !filter.host ? 0 : host.startsWith("*.") ? 1 : 2;
399
+ if (filter.path !== void 0) return [
400
+ hostRank,
401
+ host.length,
402
+ 3,
403
+ filter.path.length
404
+ ];
405
+ if (filter.pathPattern !== void 0) {
406
+ const literals = filter.pathPattern.split("/").filter((part) => part && part !== "*");
407
+ return [
408
+ hostRank,
409
+ host.length,
410
+ 2,
411
+ literals.length
412
+ ];
413
+ }
414
+ if (filter.pathPrefix !== void 0) return [
415
+ hostRank,
416
+ host.length,
417
+ 1,
418
+ filter.pathPrefix.length
419
+ ];
420
+ return [
421
+ hostRank,
422
+ host.length,
423
+ 0,
424
+ 0
425
+ ];
426
+ }
198
427
  // src/annotations.ts
199
428
  function usesHttpProtocol(value) {
200
429
  try {
@@ -251,6 +480,11 @@ const codeChangeStateSchema = z.enum([
251
480
  const codeChangeInputSchema = z.object({
252
481
  closedAt: z.date().optional(),
253
482
  conversationIds: z.array(z.string().min(1)).default([]),
483
+ /**
484
+ * Whether the code change is a draft. When omitted, Junior keeps the
485
+ * stored value; a new code change is not a draft.
486
+ */
487
+ draft: z.boolean().optional(),
254
488
  mergedAt: z.date().optional(),
255
489
  number: z.number().int().positive(),
256
490
  openedAt: z.date(),
@@ -1739,6 +1973,8 @@ function defineJuniorPlugin(plugin) {
1739
1973
  const parsed = pluginEventsSchema.safeParse(plugin.events);
1740
1974
  if (!parsed.success) throw new Error(`Junior plugin "${name}" events is invalid.`, { cause: parsed.error });
1741
1975
  }
1976
+ validateObjectLinks(name, plugin.objectLinks);
1977
+ if (plugin.images !== void 0 && typeof plugin.images.resolve !== "function") throw new Error(`Junior plugin "${name}" images must have a resolve function.`);
1742
1978
  const conversationEventIds = /* @__PURE__ */ new Set();
1743
1979
  for (const event of plugin.conversationEvents ?? []) {
1744
1980
  if (!event || typeof event !== "object" && typeof event !== "function" || typeof event.parse !== "function" || typeof event.renderEvent !== "function") throw new Error(`Junior plugin "${name}" conversation event definitions must be created with defineConversationEvent().`);
@@ -1759,6 +1995,17 @@ function defineJuniorPlugin(plugin) {
1759
1995
  }
1760
1996
  return { ...plugin };
1761
1997
  }
1998
+ function validateObjectLinks(name, links) {
1999
+ if (links === void 0) return;
2000
+ if (!Array.isArray(links)) throw new Error(`Junior plugin "${name}" objectLinks must be an array.`);
2001
+ for (const link of links) {
2002
+ if (!objectTypeSchema.safeParse(link?.objectType).success || typeof link.resolve !== "function" || !Array.isArray(link.filters) || link.filters.length === 0) throw new Error(`Junior plugin "${name}" object links need an objectType, filters, and a resolve function.`);
2003
+ for (const filter of link.filters) {
2004
+ const parsed = objectLinkFilterSchema.safeParse(filter);
2005
+ if (!parsed.success) throw new Error(`Junior plugin "${name}" has an invalid ${link.objectType} link filter.`, { cause: parsed.error });
2006
+ }
2007
+ }
2008
+ }
1762
2009
  // src/user-pages.ts
1763
2010
  /**
1764
2011
  * Core-rendered plugin user pages.
@@ -1837,4 +2084,4 @@ const pluginUserPageInputSchema = z.object({
1837
2084
  limit: z.number().int().min(1).max(50),
1838
2085
  query: pluginUserPageQuerySchema
1839
2086
  }).strict();
1840
- export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, agentInvocationSourceSchema, anyResourceEvents, anyResourceMatchFields, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, getSourceKey, identitySchema, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectPresentation, objectTypeSchema, ownedObjectAnnotationSchema, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuditAttributesSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginToolReplySchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, subscribableResourceSchema, systemActorSchema, taskOutcomeSchema, toolApprovalModeSchema, userSchema, watchResultSchema, webActorSchema, webSourceSchema, zodTool };
2087
+ export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, OBJECT_FACTS_MAX_BYTES, OBJECT_SUMMARY_MAX_LENGTH, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, agentInvocationSourceSchema, anyResourceEvents, anyResourceMatchFields, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, getSourceKey, identitySchema, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsBytes, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectLinkFilterMatches, objectLinkFilterSchema, objectLinkFilterSpecificity, objectPresentation, objectSummary, objectTypeSchema, ownedObjectAnnotationSchema, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuditAttributesSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginToolReplySchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, subscribableResourceSchema, systemActorSchema, taskOutcomeSchema, toolApprovalModeSchema, userSchema, watchResultSchema, webActorSchema, webSourceSchema, zodTool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.298.0",
3
+ "version": "0.300.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "commander": "^14.0.3",
26
- "zod": "^4.5.4"
26
+ "zod": "^4.6.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@oxlint/plugins": "1.79.0",