@sentry/junior-plugin-api 0.301.0 → 0.303.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/LICENSE +201 -0
- package/dist/index.d.ts +753 -46
- package/dist/index.js +217 -13
- package/package.json +3 -6
package/dist/index.js
CHANGED
|
@@ -2,9 +2,15 @@ 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
|
+
const duration = z.number().finite().nonnegative();
|
|
6
|
+
const imagePath = z.string().max(4e3).regex(/^\/api\/images\/[\w-]+\.[\w-]+\?w=\d+(&v=[\w-]+)?$/);
|
|
5
7
|
/** The longest object summary, in UTF-16 code units. */
|
|
6
8
|
const OBJECT_SUMMARY_MAX_LENGTH = 280;
|
|
7
9
|
const summary = z.string().trim().min(1).max(280);
|
|
10
|
+
const trend = z.strictObject({
|
|
11
|
+
label: text,
|
|
12
|
+
points: z.array(z.number().finite().nonnegative()).min(2).max(60)
|
|
13
|
+
});
|
|
8
14
|
/** Small, provider-neutral facts. Missing values mean unknown, not success. */
|
|
9
15
|
const objectFactsSchema = z.discriminatedUnion("type", [
|
|
10
16
|
z.strictObject({
|
|
@@ -43,7 +49,8 @@ const objectFactsSchema = z.discriminatedUnion("type", [
|
|
|
43
49
|
project: text.optional(),
|
|
44
50
|
cycle: text.optional(),
|
|
45
51
|
dueDate: z.iso.date().optional(),
|
|
46
|
-
labels: z.array(text).max(5).optional()
|
|
52
|
+
labels: z.array(text).max(5).optional(),
|
|
53
|
+
trend: trend.optional()
|
|
47
54
|
}),
|
|
48
55
|
z.strictObject({
|
|
49
56
|
type: z.literal("deployment"),
|
|
@@ -69,7 +76,8 @@ const objectFactsSchema = z.discriminatedUnion("type", [
|
|
|
69
76
|
type: z.literal("document"),
|
|
70
77
|
summary: summary.optional(),
|
|
71
78
|
owner: text.optional(),
|
|
72
|
-
modifiedAt: z.iso.datetime({ offset: true }).optional()
|
|
79
|
+
modifiedAt: z.iso.datetime({ offset: true }).optional(),
|
|
80
|
+
thumbnailUrl: imagePath.optional()
|
|
73
81
|
}),
|
|
74
82
|
z.strictObject({
|
|
75
83
|
type: z.literal("message"),
|
|
@@ -83,7 +91,108 @@ const objectFactsSchema = z.discriminatedUnion("type", [
|
|
|
83
91
|
summary: summary.optional(),
|
|
84
92
|
siteName: text.optional(),
|
|
85
93
|
author: text.optional(),
|
|
86
|
-
|
|
94
|
+
media: z.enum(["video", "image"]).optional(),
|
|
95
|
+
thumbnailUrl: imagePath.optional()
|
|
96
|
+
}),
|
|
97
|
+
z.strictObject({
|
|
98
|
+
type: z.literal("chart"),
|
|
99
|
+
summary: summary.optional(),
|
|
100
|
+
display: z.enum([
|
|
101
|
+
"line",
|
|
102
|
+
"bar",
|
|
103
|
+
"area"
|
|
104
|
+
]),
|
|
105
|
+
yAxis: text,
|
|
106
|
+
range: text,
|
|
107
|
+
series: z.array(z.strictObject({
|
|
108
|
+
label: text,
|
|
109
|
+
points: z.array(z.number().finite()).min(2).max(120)
|
|
110
|
+
})).min(1).max(5)
|
|
111
|
+
}),
|
|
112
|
+
z.strictObject({
|
|
113
|
+
type: z.literal("event"),
|
|
114
|
+
summary: summary.optional(),
|
|
115
|
+
level: text.optional(),
|
|
116
|
+
project: text.optional(),
|
|
117
|
+
release: text.optional(),
|
|
118
|
+
environment: text.optional(),
|
|
119
|
+
occurredAt: z.iso.datetime({ offset: true }).optional()
|
|
120
|
+
}),
|
|
121
|
+
z.strictObject({
|
|
122
|
+
type: z.literal("release"),
|
|
123
|
+
summary: summary.optional(),
|
|
124
|
+
version: text,
|
|
125
|
+
projects: z.array(text).max(5),
|
|
126
|
+
newIssues: count.optional(),
|
|
127
|
+
crashFreeSessions: z.number().finite().min(0).max(100).optional(),
|
|
128
|
+
deployCount: count.optional(),
|
|
129
|
+
lastDeploy: z.strictObject({
|
|
130
|
+
environment: text,
|
|
131
|
+
finishedAt: z.iso.datetime({ offset: true }).optional()
|
|
132
|
+
}).optional(),
|
|
133
|
+
releasedAt: z.iso.datetime({ offset: true }).optional()
|
|
134
|
+
}),
|
|
135
|
+
z.strictObject({
|
|
136
|
+
type: z.literal("monitor"),
|
|
137
|
+
summary: summary.optional(),
|
|
138
|
+
kind: z.enum([
|
|
139
|
+
"metric",
|
|
140
|
+
"cron",
|
|
141
|
+
"uptime"
|
|
142
|
+
]),
|
|
143
|
+
state: z.enum([
|
|
144
|
+
"ok",
|
|
145
|
+
"failing",
|
|
146
|
+
"pending",
|
|
147
|
+
"paused"
|
|
148
|
+
]),
|
|
149
|
+
project: text.optional(),
|
|
150
|
+
environment: text.optional(),
|
|
151
|
+
detail: text.optional(),
|
|
152
|
+
lastCheckedAt: z.iso.datetime({ offset: true }).optional(),
|
|
153
|
+
trend: trend.optional()
|
|
154
|
+
}),
|
|
155
|
+
z.strictObject({
|
|
156
|
+
type: z.literal("trace"),
|
|
157
|
+
summary: summary.optional(),
|
|
158
|
+
rootOp: text.optional(),
|
|
159
|
+
rootName: text.optional(),
|
|
160
|
+
durationMs: duration,
|
|
161
|
+
spanCount: count,
|
|
162
|
+
errorCount: count,
|
|
163
|
+
performanceIssueCount: count,
|
|
164
|
+
projects: z.array(text).max(5),
|
|
165
|
+
spans: z.array(z.strictObject({
|
|
166
|
+
op: text.optional(),
|
|
167
|
+
name: text,
|
|
168
|
+
startMs: duration,
|
|
169
|
+
durationMs: duration,
|
|
170
|
+
issue: z.boolean().optional()
|
|
171
|
+
})).max(12)
|
|
172
|
+
}),
|
|
173
|
+
z.strictObject({
|
|
174
|
+
type: z.literal("dashboard"),
|
|
175
|
+
summary: summary.optional(),
|
|
176
|
+
widgetCount: count,
|
|
177
|
+
projects: z.array(text).max(5),
|
|
178
|
+
environments: z.array(text).max(5),
|
|
179
|
+
range: text,
|
|
180
|
+
widgets: z.array(z.strictObject({
|
|
181
|
+
title: text,
|
|
182
|
+
display: text
|
|
183
|
+
})).max(8),
|
|
184
|
+
charts: z.array(z.strictObject({
|
|
185
|
+
title: text,
|
|
186
|
+
display: z.enum([
|
|
187
|
+
"line",
|
|
188
|
+
"bar",
|
|
189
|
+
"area"
|
|
190
|
+
]),
|
|
191
|
+
series: z.array(z.strictObject({
|
|
192
|
+
label: text,
|
|
193
|
+
points: z.array(z.number().finite()).min(2).max(60)
|
|
194
|
+
})).min(1).max(3)
|
|
195
|
+
})).max(3)
|
|
87
196
|
}),
|
|
88
197
|
z.strictObject({
|
|
89
198
|
type: z.literal("person"),
|
|
@@ -114,6 +223,25 @@ function objectSummary(text) {
|
|
|
114
223
|
}
|
|
115
224
|
return `${cut}…`;
|
|
116
225
|
}
|
|
226
|
+
function plural(value, noun) {
|
|
227
|
+
return `${value.toLocaleString("en-US")} ${noun}${value === 1 ? "" : "s"}`;
|
|
228
|
+
}
|
|
229
|
+
/** Format a span or trace duration, such as "850 ms" or "2.4 s". */
|
|
230
|
+
function formatDuration(ms) {
|
|
231
|
+
if (ms < 1e3) return `${Math.round(ms)} ms`;
|
|
232
|
+
if (ms < 6e4) return `${Number((ms / 1e3).toPrecision(3))} s`;
|
|
233
|
+
return `${Number((ms / 6e4).toPrecision(3))} min`;
|
|
234
|
+
}
|
|
235
|
+
const MONITOR_KINDS = {
|
|
236
|
+
metric: "Metric alert",
|
|
237
|
+
cron: "Cron job",
|
|
238
|
+
uptime: "Uptime check"
|
|
239
|
+
};
|
|
240
|
+
const MONITOR_DETAILS = {
|
|
241
|
+
metric: "Alerts on",
|
|
242
|
+
cron: "Schedule",
|
|
243
|
+
uptime: "Checks"
|
|
244
|
+
};
|
|
117
245
|
/** Show at most four card attributes, in priority order, on every surface. */
|
|
118
246
|
function objectFactFields(facts) {
|
|
119
247
|
if (!facts) return [];
|
|
@@ -175,6 +303,39 @@ function objectFactFields(facts) {
|
|
|
175
303
|
add("siteName", "Site", facts.siteName);
|
|
176
304
|
add("author", "Author", facts.author);
|
|
177
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;
|
|
178
339
|
case "person":
|
|
179
340
|
add("email", "Email", facts.email);
|
|
180
341
|
add("slackHandle", "Slack", facts.slackHandle && `@${facts.slackHandle}`);
|
|
@@ -195,6 +356,12 @@ const objectTypeSchema = z.enum([
|
|
|
195
356
|
"document",
|
|
196
357
|
"message",
|
|
197
358
|
"web_page",
|
|
359
|
+
"chart",
|
|
360
|
+
"event",
|
|
361
|
+
"trace",
|
|
362
|
+
"release",
|
|
363
|
+
"dashboard",
|
|
364
|
+
"monitor",
|
|
198
365
|
"item"
|
|
199
366
|
]);
|
|
200
367
|
const objectTypeLabels = {
|
|
@@ -208,6 +375,12 @@ const objectTypeLabels = {
|
|
|
208
375
|
document: "Document",
|
|
209
376
|
message: "Message",
|
|
210
377
|
web_page: "Web page",
|
|
378
|
+
chart: "Chart",
|
|
379
|
+
event: "Event",
|
|
380
|
+
trace: "Trace",
|
|
381
|
+
release: "Release",
|
|
382
|
+
dashboard: "Dashboard",
|
|
383
|
+
monitor: "Monitor",
|
|
211
384
|
item: "Item"
|
|
212
385
|
};
|
|
213
386
|
/** Resolve identity and state without replacing the type icon with a warning. */
|
|
@@ -225,6 +398,12 @@ function objectPresentation(object) {
|
|
|
225
398
|
document: "file",
|
|
226
399
|
message: "comment",
|
|
227
400
|
web_page: "globe",
|
|
401
|
+
chart: "graph",
|
|
402
|
+
event: "pulse",
|
|
403
|
+
trace: "rows",
|
|
404
|
+
release: "tag",
|
|
405
|
+
dashboard: "apps",
|
|
406
|
+
monitor: "bell",
|
|
228
407
|
item: "package"
|
|
229
408
|
}[type];
|
|
230
409
|
let tone = type === "automation" ? "info" : "neutral";
|
|
@@ -249,6 +428,11 @@ function objectPresentation(object) {
|
|
|
249
428
|
if (status === "ready" || status === "succeeded") tone = "success";
|
|
250
429
|
if (status === "error" || status === "failed") tone = "danger";
|
|
251
430
|
if (status === "building" || status === "in_progress") tone = "info";
|
|
431
|
+
} else if (type === "monitor") {
|
|
432
|
+
const state = object.facts?.state;
|
|
433
|
+
if (state === "ok") tone = "success";
|
|
434
|
+
if (state === "failing") tone = "danger";
|
|
435
|
+
if (state === "pending") tone = "info";
|
|
252
436
|
} else if (type === "conversation") {
|
|
253
437
|
if (status === "running") tone = "info";
|
|
254
438
|
if (status === "failed") tone = "danger";
|
|
@@ -334,7 +518,13 @@ const objectIconPaths = {
|
|
|
334
518
|
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"],
|
|
335
519
|
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"],
|
|
336
520
|
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"],
|
|
337
|
-
|
|
521
|
+
graph: ["M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"],
|
|
522
|
+
pulse: ["M6 2c.306 0 .582.187.696.471L10 10.731l1.304-3.26A.751.751 0 0 1 12 7h3.25a.75.75 0 0 1 0 1.5h-2.742l-1.812 4.528a.751.751 0 0 1-1.392 0L6 4.77 4.696 8.03A.75.75 0 0 1 4 8.5H.75a.75.75 0 0 1 0-1.5h2.742l1.812-4.529A.751.751 0 0 1 6 2Z"],
|
|
523
|
+
bell: ["M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"],
|
|
524
|
+
rows: ["M16 10.75v2.5A1.75 1.75 0 0 1 14.25 15H1.75A1.75 1.75 0 0 1 0 13.25v-2.5C0 9.784.784 9 1.75 9h12.5c.966 0 1.75.784 1.75 1.75Zm0-8v2.5A1.75 1.75 0 0 1 14.25 7H1.75A1.75 1.75 0 0 1 0 5.25v-2.5C0 1.784.784 1 1.75 1h12.5c.966 0 1.75.784 1.75 1.75Zm-1.75-.25H1.75a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25Zm0 8H1.75a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25Z"],
|
|
525
|
+
tag: ["M1 7.775V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 0 1 0 2.474l-5.026 5.026a1.75 1.75 0 0 1-2.474 0l-6.25-6.25A1.752 1.752 0 0 1 1 7.775Zm1.5 0c0 .066.026.13.073.177l6.25 6.25a.25.25 0 0 0 .354 0l5.025-5.025a.25.25 0 0 0 0-.354l-6.25-6.25a.25.25 0 0 0-.177-.073H2.75a.25.25 0 0 0-.25.25ZM6 5a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"],
|
|
526
|
+
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"],
|
|
527
|
+
apps: ["M1.5 3.25c0-.966.784-1.75 1.75-1.75h2.5c.966 0 1.75.784 1.75 1.75v2.5A1.75 1.75 0 0 1 5.75 7.5h-2.5A1.75 1.75 0 0 1 1.5 5.75Zm7 0c0-.966.784-1.75 1.75-1.75h2.5c.966 0 1.75.784 1.75 1.75v2.5a1.75 1.75 0 0 1-1.75 1.75h-2.5A1.75 1.75 0 0 1 8.5 5.75Zm-7 7c0-.966.784-1.75 1.75-1.75h2.5c.966 0 1.75.784 1.75 1.75v2.5a1.75 1.75 0 0 1-1.75 1.75h-2.5a1.75 1.75 0 0 1-1.75-1.75Zm7 0c0-.966.784-1.75 1.75-1.75h2.5c.966 0 1.75.784 1.75 1.75v2.5a1.75 1.75 0 0 1-1.75 1.75h-2.5a1.75 1.75 0 0 1-1.75-1.75ZM3.25 3a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5A.25.25 0 0 0 6 5.75v-2.5A.25.25 0 0 0 5.75 3Zm7 0a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25Zm-7 7a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25Zm7 0a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25Z"]
|
|
338
528
|
};
|
|
339
529
|
// src/images.ts
|
|
340
530
|
const objectImageRefSchema = z.object({
|
|
@@ -705,17 +895,17 @@ function normalizeStoredSource(value) {
|
|
|
705
895
|
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
706
896
|
const source = value;
|
|
707
897
|
if ("kind" in source) {
|
|
708
|
-
const kind = typeof source
|
|
898
|
+
const kind = typeof source["kind"] === "string" ? {
|
|
709
899
|
event_task: "event_automation",
|
|
710
900
|
resource_event: "event",
|
|
711
901
|
scheduled_task: "scheduled_automation"
|
|
712
|
-
}[source
|
|
902
|
+
}[source["kind"]] : void 0;
|
|
713
903
|
return kind ? {
|
|
714
904
|
...source,
|
|
715
905
|
kind
|
|
716
906
|
} : value;
|
|
717
907
|
}
|
|
718
|
-
if (source
|
|
908
|
+
if (source["platform"] !== "slack" && source["platform"] !== "local" && source["platform"] !== "web") return value;
|
|
719
909
|
const { location: _location, platform: kind, ...fields } = source;
|
|
720
910
|
return {
|
|
721
911
|
...fields,
|
|
@@ -1641,7 +1831,11 @@ const pluginToolReplySchema = z.object({
|
|
|
1641
1831
|
}).strict();
|
|
1642
1832
|
/** Shared optional fields for canonical plugin tool outputs. */
|
|
1643
1833
|
const pluginToolOutputSchema = z.object({
|
|
1644
|
-
/**
|
|
1834
|
+
/**
|
|
1835
|
+
* Objects that the tool created or changed, to save as Annotations and
|
|
1836
|
+
* show with the next reply. Omit for silent updates. Read-only tools
|
|
1837
|
+
* (`readOnlyHint: true`) must omit it: core rejects the result.
|
|
1838
|
+
*/
|
|
1645
1839
|
objectAnnotations: z.array(objectAnnotationSchema).optional(),
|
|
1646
1840
|
/**
|
|
1647
1841
|
* Reply the tool posted for Junior, such as a pull request comment. Core
|
|
@@ -1713,8 +1907,8 @@ function createZodTool(definition, helperName) {
|
|
|
1713
1907
|
prepareArguments(args) {
|
|
1714
1908
|
return parsePluginToolInput(inputSchema, prepareArguments ? prepareArguments(args) : args);
|
|
1715
1909
|
},
|
|
1716
|
-
...execute ? { async execute(input, options) {
|
|
1717
|
-
const result = await execute(input, options);
|
|
1910
|
+
...execute ? { async execute(input, options, ctx) {
|
|
1911
|
+
const result = await execute(input, options, ctx);
|
|
1718
1912
|
if (isPluginToolOutputEnvelope(result)) return {
|
|
1719
1913
|
content: z.array(pluginToolContentSchema).parse(result.content),
|
|
1720
1914
|
details: outputSchema.parse(result.details)
|
|
@@ -1723,6 +1917,16 @@ function createZodTool(definition, helperName) {
|
|
|
1723
1917
|
} } : void 0
|
|
1724
1918
|
};
|
|
1725
1919
|
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Run tools that take a plugin-built context, such as deployment config plus
|
|
1922
|
+
* the Turn capabilities that they use. `toContext` runs on each call.
|
|
1923
|
+
*/
|
|
1924
|
+
function withToolContext(tools, toContext) {
|
|
1925
|
+
return Object.fromEntries(Object.entries(tools).map(([name, { execute, ...tool }]) => [name, {
|
|
1926
|
+
...tool,
|
|
1927
|
+
...execute ? { execute: async (input, options, ctx) => await execute(input, options, toContext(ctx)) } : void 0
|
|
1928
|
+
}]));
|
|
1929
|
+
}
|
|
1726
1930
|
/** Define a plugin tool with Zod input parsing and validated structured results. */
|
|
1727
1931
|
function zodTool(definition) {
|
|
1728
1932
|
return createZodTool(definition, "zodTool");
|
|
@@ -2024,10 +2228,10 @@ function validateObjectLinks(name, links) {
|
|
|
2024
2228
|
if (links === void 0) return;
|
|
2025
2229
|
if (!Array.isArray(links)) throw new Error(`Junior plugin "${name}" objectLinks must be an array.`);
|
|
2026
2230
|
for (const link of links) {
|
|
2027
|
-
if (!
|
|
2231
|
+
if (!Array.isArray(link?.objectTypes) || link.objectTypes.length === 0 || !link.objectTypes.every((type) => objectTypeSchema.safeParse(type).success) || typeof link.canView !== "function" || typeof link.resolve !== "function" || !Array.isArray(link.filters) || link.filters.length === 0) throw new Error(`Junior plugin "${name}" object links need objectTypes, filters, a canView function, and a resolve function.`);
|
|
2028
2232
|
for (const filter of link.filters) {
|
|
2029
2233
|
const parsed = objectLinkFilterSchema.safeParse(filter);
|
|
2030
|
-
if (!parsed.success) throw new Error(`Junior plugin "${name}" has an invalid ${link.
|
|
2234
|
+
if (!parsed.success) throw new Error(`Junior plugin "${name}" has an invalid ${link.objectTypes.join("/")} link filter.`, { cause: parsed.error });
|
|
2031
2235
|
}
|
|
2032
2236
|
}
|
|
2033
2237
|
}
|
|
@@ -2109,4 +2313,4 @@ const pluginUserPageInputSchema = z.object({
|
|
|
2109
2313
|
limit: z.number().int().min(1).max(50),
|
|
2110
2314
|
query: pluginUserPageQuerySchema
|
|
2111
2315
|
}).strict();
|
|
2112
|
-
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, decodeObjectImageRef, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, encodeObjectImageRef, 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 };
|
|
2316
|
+
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, decodeObjectImageRef, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, encodeObjectImageRef, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, formatDuration, 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, withToolContext, zodTool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-plugin-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.303.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,14 +26,11 @@
|
|
|
26
26
|
"zod": "^4.6.7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"tsdown": "0.23.1",
|
|
32
|
-
"typescript": "^7.0.2"
|
|
29
|
+
"tsdown": "0.23.7",
|
|
30
|
+
"typescript": "7.0.2"
|
|
33
31
|
},
|
|
34
32
|
"scripts": {
|
|
35
33
|
"build": "tsdown",
|
|
36
|
-
"lint": "oxlint --config ../junior/.oxlintrc.json --deny-warnings src tsdown.config.ts",
|
|
37
34
|
"typecheck": "tsc --noEmit"
|
|
38
35
|
}
|
|
39
36
|
}
|