@sentry/junior-plugin-api 0.198.0 → 0.200.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/src/user-pages.ts DELETED
@@ -1,130 +0,0 @@
1
- /**
2
- * Core-rendered plugin user pages.
3
- *
4
- * Plugins own bounded data projection; Junior owns viewer authorization,
5
- * routing, response validation, and browser rendering.
6
- */
7
- import { z } from "zod";
8
- import type { PluginContext, User } from "./context";
9
- import { nonBlankStringSchema } from "./schemas";
10
-
11
- const userPageIdSchema = nonBlankStringSchema
12
- .max(64)
13
- .regex(/^[a-z][a-z0-9-]*$/);
14
- const userPageLabelSchema = nonBlankStringSchema.max(80);
15
- const userPageDescriptionSchema = nonBlankStringSchema.max(500);
16
- const userPageNavigationSchema = z.enum(["primary", "profile"]);
17
-
18
- const pluginUserPageMetricSchema = z
19
- .object({
20
- detail: nonBlankStringSchema.max(500).optional(),
21
- label: nonBlankStringSchema.max(80),
22
- tone: z.enum(["good", "neutral", "warning"]).optional(),
23
- value: nonBlankStringSchema.max(120),
24
- })
25
- .strict();
26
-
27
- const pluginUserPageMetadataSchema = z
28
- .object({
29
- label: nonBlankStringSchema.max(80),
30
- value: nonBlankStringSchema.max(500),
31
- })
32
- .strict();
33
-
34
- const pluginUserPageActionSchema = z
35
- .object({
36
- confirmation: nonBlankStringSchema.max(500).optional(),
37
- href: nonBlankStringSchema
38
- .max(500)
39
- .regex(/^\/api\/plugins\/[a-z][a-z0-9-]*(?:\/|$)/),
40
- label: nonBlankStringSchema.max(80),
41
- method: z.literal("DELETE"),
42
- tone: z.enum(["danger", "neutral"]).optional(),
43
- })
44
- .strict();
45
-
46
- const pluginUserPageRecordSchema = z
47
- .object({
48
- actions: z.array(pluginUserPageActionSchema).max(4).optional(),
49
- description: nonBlankStringSchema.max(1_000).optional(),
50
- id: nonBlankStringSchema.max(128),
51
- metadata: z.array(pluginUserPageMetadataSchema).max(8).optional(),
52
- title: nonBlankStringSchema.max(4_000),
53
- })
54
- .strict();
55
-
56
- /** Bounded list content returned by a plugin-owned user page. */
57
- export const pluginUserPageContentSchema = z
58
- .object({
59
- emptyText: nonBlankStringSchema.max(500).optional(),
60
- metrics: z.array(pluginUserPageMetricSchema).max(6).optional(),
61
- nextCursor: nonBlankStringSchema.max(1_000).optional(),
62
- records: z.array(pluginUserPageRecordSchema).max(100),
63
- searchPlaceholder: nonBlankStringSchema.max(120).optional(),
64
- type: z.literal("list"),
65
- })
66
- .strict();
67
-
68
- /** Validated content for the current core-rendered list page type. */
69
- export type PluginUserPageContent = z.output<
70
- typeof pluginUserPageContentSchema
71
- >;
72
-
73
- export const pluginUserPageLinkSchema = z
74
- .object({
75
- description: userPageDescriptionSchema,
76
- id: userPageIdSchema,
77
- label: userPageLabelSchema,
78
- navigation: userPageNavigationSchema,
79
- pluginDisplayName: nonBlankStringSchema.max(200),
80
- pluginName: nonBlankStringSchema.max(100),
81
- })
82
- .strict();
83
-
84
- export const pluginUserPageLinksSchema = z.array(pluginUserPageLinkSchema);
85
-
86
- /** Safe navigation metadata for one registered plugin user page. */
87
- export type PluginUserPageLink = z.output<typeof pluginUserPageLinkSchema>;
88
-
89
- /** Optional cursor token for one plugin user page reader. */
90
- export const pluginUserPageCursorSchema = nonBlankStringSchema
91
- .max(1_000)
92
- .optional();
93
-
94
- /** Optional filter token for one plugin user page reader. */
95
- export const pluginUserPageFilterSchema = nonBlankStringSchema
96
- .max(64)
97
- .optional();
98
-
99
- /** Optional free-text query for one plugin user page reader. */
100
- export const pluginUserPageQuerySchema = z.string().trim().max(200).optional();
101
-
102
- /** Validated query state passed to one plugin user page reader. */
103
- export const pluginUserPageInputSchema = z
104
- .object({
105
- cursor: pluginUserPageCursorSchema,
106
- filter: pluginUserPageFilterSchema,
107
- limit: z.number().int().min(1).max(50),
108
- query: pluginUserPageQuerySchema,
109
- })
110
- .strict();
111
-
112
- export type PluginUserPageInput = z.output<typeof pluginUserPageInputSchema>;
113
-
114
- /** Trusted host context supplied while reading one plugin user page. */
115
- export interface PluginUserPageContext extends PluginContext {
116
- viewer: User;
117
- }
118
-
119
- /** Navigation metadata and reader for one core-rendered plugin user page. */
120
- export interface PluginUserPageDefinition {
121
- description: string;
122
- id: string;
123
- label: string;
124
- /** Dashboard navigation surface where this page is linked. */
125
- navigation?: "primary" | "profile";
126
- read(
127
- ctx: PluginUserPageContext,
128
- input: PluginUserPageInput,
129
- ): Promise<PluginUserPageContent> | PluginUserPageContent;
130
- }