@sentry/junior-plugin-api 0.303.0 → 0.305.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.d.ts +10 -0
- package/dist/index.js +34 -23
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1789,6 +1789,13 @@ export declare const conversationSidebarIconSchema: z.ZodEnum<{
|
|
|
1789
1789
|
"git-pull-request": "git-pull-request";
|
|
1790
1790
|
"triangle-alert": "triangle-alert";
|
|
1791
1791
|
}>;
|
|
1792
|
+
/**
|
|
1793
|
+
* One linked object on a Conversation row. `label` is the short chip text.
|
|
1794
|
+
* `title` and `url` are the saved object's own, for rows with room for a
|
|
1795
|
+
* card; leave them out when the plugin has not saved them. `imageUrl` is a
|
|
1796
|
+
* public image that previews the object, such as the first screenshot of a
|
|
1797
|
+
* code change.
|
|
1798
|
+
*/
|
|
1792
1799
|
export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
|
|
1793
1800
|
icon: z.ZodOptional<z.ZodEnum<{
|
|
1794
1801
|
"circle-dashed": "circle-dashed";
|
|
@@ -1820,6 +1827,9 @@ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
|
|
|
1820
1827
|
status: z.ZodOptional<z.ZodString>;
|
|
1821
1828
|
key: z.ZodString;
|
|
1822
1829
|
label: z.ZodString;
|
|
1830
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1831
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1832
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
1823
1833
|
}, z.core.$strict>;
|
|
1824
1834
|
export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
|
|
1825
1835
|
export interface ConversationSidebarHookContext extends PluginContext {
|
package/dist/index.js
CHANGED
|
@@ -648,6 +648,7 @@ function usesHttpProtocol(value) {
|
|
|
648
648
|
return false;
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
+
const httpUrlSchema = z.string().url().max(2048).refine(usesHttpProtocol, "URL must use HTTP or HTTPS.");
|
|
651
652
|
/**
|
|
652
653
|
* Link an object to a Conversation when the owner has no typed object preview.
|
|
653
654
|
* Keep a stable key, compact label, source URL, and optional short context or
|
|
@@ -659,7 +660,7 @@ const resourceLinkAnnotationSchema = z.object({
|
|
|
659
660
|
objectType: objectTypeSchema.optional(),
|
|
660
661
|
key: z.string().trim().min(1).max(256),
|
|
661
662
|
label: z.string().trim().min(1).max(256),
|
|
662
|
-
url:
|
|
663
|
+
url: httpUrlSchema,
|
|
663
664
|
description: z.string().trim().min(1).max(512).optional(),
|
|
664
665
|
status: z.enum([
|
|
665
666
|
"open",
|
|
@@ -679,12 +680,22 @@ const conversationSidebarIconSchema = z.enum([
|
|
|
679
680
|
"git-pull-request",
|
|
680
681
|
"triangle-alert"
|
|
681
682
|
]);
|
|
683
|
+
/**
|
|
684
|
+
* One linked object on a Conversation row. `label` is the short chip text.
|
|
685
|
+
* `title` and `url` are the saved object's own, for rows with room for a
|
|
686
|
+
* card; leave them out when the plugin has not saved them. `imageUrl` is a
|
|
687
|
+
* public image that previews the object, such as the first screenshot of a
|
|
688
|
+
* code change.
|
|
689
|
+
*/
|
|
682
690
|
const conversationSidebarAnnotationSchema = z.object({
|
|
683
691
|
icon: conversationSidebarIconSchema.optional(),
|
|
684
692
|
objectType: objectTypeSchema.optional(),
|
|
685
693
|
status: z.string().trim().min(1).max(100).optional(),
|
|
686
694
|
key: z.string().trim().min(1).max(256),
|
|
687
|
-
label: z.string().trim().min(1).max(256)
|
|
695
|
+
label: z.string().trim().min(1).max(256),
|
|
696
|
+
title: z.string().trim().min(1).max(512).optional(),
|
|
697
|
+
url: httpUrlSchema.optional(),
|
|
698
|
+
imageUrl: httpUrlSchema.optional()
|
|
688
699
|
}).strict();
|
|
689
700
|
// src/code.ts
|
|
690
701
|
const codeChangeStateSchema = z.enum([
|
|
@@ -2191,47 +2202,47 @@ function defineJuniorPlugin(plugin) {
|
|
|
2191
2202
|
const manifest = plugin.manifest;
|
|
2192
2203
|
if (!manifest) throw new Error("defineJuniorPlugin() requires a manifest. Use a package name string in defineJuniorPlugins([...]) for plugin.yaml packages.");
|
|
2193
2204
|
const name = manifest.name;
|
|
2194
|
-
if (!name) throw new Error("
|
|
2195
|
-
if (!PLUGIN_NAME_RE.test(name)) throw new Error(`
|
|
2196
|
-
if (name === "junior") throw new Error("
|
|
2197
|
-
if (typeof manifest.displayName !== "string" || !manifest.displayName.trim()) throw new Error(`
|
|
2198
|
-
if (typeof manifest.description !== "string" || !manifest.description.trim()) throw new Error(`
|
|
2199
|
-
if (plugin.userPages !== void 0 && !Array.isArray(plugin.userPages)) throw new Error(`
|
|
2200
|
-
if (plugin.conversationEvents !== void 0 && !Array.isArray(plugin.conversationEvents)) throw new Error(`
|
|
2205
|
+
if (!name) throw new Error("Plugin manifest.name is required.");
|
|
2206
|
+
if (!PLUGIN_NAME_RE.test(name)) throw new Error(`Plugin registration name "${name}" must be a lowercase plugin identifier.`);
|
|
2207
|
+
if (name === "junior") throw new Error("Plugin registration name \"junior\" is reserved for native host events.");
|
|
2208
|
+
if (typeof manifest.displayName !== "string" || !manifest.displayName.trim()) throw new Error(`Plugin "${name}" manifest.displayName is required.`);
|
|
2209
|
+
if (typeof manifest.description !== "string" || !manifest.description.trim()) throw new Error(`Plugin "${name}" manifest.description is required.`);
|
|
2210
|
+
if (plugin.userPages !== void 0 && !Array.isArray(plugin.userPages)) throw new Error(`Plugin "${name}" userPages must be an array.`);
|
|
2211
|
+
if (plugin.conversationEvents !== void 0 && !Array.isArray(plugin.conversationEvents)) throw new Error(`Plugin "${name}" conversationEvents must be an array.`);
|
|
2201
2212
|
if (plugin.events !== void 0) {
|
|
2202
2213
|
const parsed = pluginEventsSchema.safeParse(plugin.events);
|
|
2203
|
-
if (!parsed.success) throw new Error(`
|
|
2214
|
+
if (!parsed.success) throw new Error(`Plugin "${name}" events is invalid.`, { cause: parsed.error });
|
|
2204
2215
|
}
|
|
2205
2216
|
validateObjectLinks(name, plugin.objectLinks);
|
|
2206
|
-
if (plugin.images !== void 0 && typeof plugin.images.resolve !== "function") throw new Error(`
|
|
2217
|
+
if (plugin.images !== void 0 && typeof plugin.images.resolve !== "function") throw new Error(`Plugin "${name}" images must have a resolve function.`);
|
|
2207
2218
|
const conversationEventIds = /* @__PURE__ */ new Set();
|
|
2208
2219
|
for (const event of plugin.conversationEvents ?? []) {
|
|
2209
|
-
if (!event || typeof event !== "object" && typeof event !== "function" || typeof event.parse !== "function" || typeof event.renderEvent !== "function") throw new Error(`
|
|
2210
|
-
if (isPluginModelCostEventName(event.eventName)) throw new Error(`
|
|
2220
|
+
if (!event || typeof event !== "object" && typeof event !== "function" || typeof event.parse !== "function" || typeof event.renderEvent !== "function") throw new Error(`Plugin "${name}" conversation event definitions must be created with defineConversationEvent().`);
|
|
2221
|
+
if (isPluginModelCostEventName(event.eventName)) throw new Error(`Plugin "${name}" cannot register host-owned conversation event "${event.eventName}".`);
|
|
2211
2222
|
const id = `${event.eventName}@${event.version}`;
|
|
2212
|
-
if (conversationEventIds.has(id)) throw new Error(`
|
|
2223
|
+
if (conversationEventIds.has(id)) throw new Error(`Plugin "${name}" has duplicate conversation event "${id}".`);
|
|
2213
2224
|
conversationEventIds.add(id);
|
|
2214
2225
|
}
|
|
2215
2226
|
const userPageIds = /* @__PURE__ */ new Set();
|
|
2216
2227
|
for (const page of plugin.userPages ?? []) {
|
|
2217
|
-
if (!page || typeof page !== "object") throw new Error(`
|
|
2218
|
-
if (typeof page.id !== "string" || page.id.length > 64 || !USER_PAGE_ID_RE.test(page.id)) throw new Error(`
|
|
2219
|
-
if (userPageIds.has(page.id)) throw new Error(`
|
|
2220
|
-
if (typeof page.label !== "string" || !page.label.trim() || page.label.length > 80 || typeof page.description !== "string" || !page.description.trim() || page.description.length > 500) throw new Error(`
|
|
2221
|
-
if (page.navigation !== void 0 && page.navigation !== "primary" && page.navigation !== "profile" && page.navigation !== "admin") throw new Error(`
|
|
2222
|
-
if (typeof page.read !== "function") throw new Error(`
|
|
2228
|
+
if (!page || typeof page !== "object") throw new Error(`Plugin "${name}" user pages must be objects.`);
|
|
2229
|
+
if (typeof page.id !== "string" || page.id.length > 64 || !USER_PAGE_ID_RE.test(page.id)) throw new Error(`Plugin "${name}" user page id "${page.id}" must be a lowercase identifier.`);
|
|
2230
|
+
if (userPageIds.has(page.id)) throw new Error(`Plugin "${name}" has duplicate user page id "${page.id}".`);
|
|
2231
|
+
if (typeof page.label !== "string" || !page.label.trim() || page.label.length > 80 || typeof page.description !== "string" || !page.description.trim() || page.description.length > 500) throw new Error(`Plugin "${name}" user page "${page.id}" requires label and description.`);
|
|
2232
|
+
if (page.navigation !== void 0 && page.navigation !== "primary" && page.navigation !== "profile" && page.navigation !== "admin") throw new Error(`Plugin "${name}" user page "${page.id}" navigation must be "primary", "profile", or "admin".`);
|
|
2233
|
+
if (typeof page.read !== "function") throw new Error(`Plugin "${name}" user page "${page.id}" requires a read function.`);
|
|
2223
2234
|
userPageIds.add(page.id);
|
|
2224
2235
|
}
|
|
2225
2236
|
return { ...plugin };
|
|
2226
2237
|
}
|
|
2227
2238
|
function validateObjectLinks(name, links) {
|
|
2228
2239
|
if (links === void 0) return;
|
|
2229
|
-
if (!Array.isArray(links)) throw new Error(`
|
|
2240
|
+
if (!Array.isArray(links)) throw new Error(`Plugin "${name}" objectLinks must be an array.`);
|
|
2230
2241
|
for (const link of links) {
|
|
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(`
|
|
2242
|
+
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(`Plugin "${name}" object links need objectTypes, filters, a canView function, and a resolve function.`);
|
|
2232
2243
|
for (const filter of link.filters) {
|
|
2233
2244
|
const parsed = objectLinkFilterSchema.safeParse(filter);
|
|
2234
|
-
if (!parsed.success) throw new Error(`
|
|
2245
|
+
if (!parsed.success) throw new Error(`Plugin "${name}" has an invalid ${link.objectTypes.join("/")} link filter.`, { cause: parsed.error });
|
|
2235
2246
|
}
|
|
2236
2247
|
}
|
|
2237
2248
|
}
|