@sentry/junior-plugin-api 0.187.0 → 0.189.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/context.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import type { ZodTypeAny } from "zod";
3
- import { destinationSchema, identitySchema, webActorSchema, localActorSchema, platformSchema, actorSchema, slackActorSchema, systemActorSchema, sourceSchema, userSchema } from "./schemas";
3
+ import { destinationSchema, identitySchema, locationSchema, webActorSchema, localActorSchema, platformSchema, actorSchema, slackActorSchema, systemActorSchema, sourceSchema, slackLocationSchema, userSchema } from "./schemas";
4
4
  /** Runtime platform name without source or destination coordinates. */
5
5
  export type Platform = z.output<typeof platformSchema>;
6
6
  export type Actor = z.output<typeof actorSchema>;
@@ -11,6 +11,10 @@ export type SystemActor = z.output<typeof systemActorSchema>;
11
11
  export type Identity = z.output<typeof identitySchema>;
12
12
  export type User = z.output<typeof userSchema>;
13
13
  export type Source = z.output<typeof sourceSchema>;
14
+ /** Validated Location associated with a Conversation. */
15
+ export type Location = z.output<typeof locationSchema>;
16
+ /** Complete Slack Location associated with a Conversation. */
17
+ export type SlackLocation = z.output<typeof slackLocationSchema>;
14
18
  export type SlackSource = Extract<Source, {
15
19
  platform: "slack";
16
20
  }>;
package/dist/index.js CHANGED
@@ -119,6 +119,20 @@ var nonBlankStringSchema = z4.string().refine((value) => value.trim().length > 0
119
119
  var exactNonBlankStringSchema = nonBlankStringSchema.refine(
120
120
  (value) => value === value.trim()
121
121
  );
122
+ var baseLocationSchema = z4.object({
123
+ /** Stable SQL identity used by Location configuration and reporting. */
124
+ id: nonBlankStringSchema,
125
+ provider: exactNonBlankStringSchema
126
+ }).strict();
127
+ var slackLocationSchema = baseLocationSchema.extend({
128
+ provider: z4.literal("slack"),
129
+ teamId: slackTeamIdSchema,
130
+ channelId: slackConversationIdSchema,
131
+ threadTs: exactNonBlankStringSchema.optional()
132
+ }).strict();
133
+ var locationSchema = z4.discriminatedUnion("provider", [
134
+ slackLocationSchema
135
+ ]);
122
136
  var platformSchema = z4.enum(["slack", "local"]);
123
137
  var sourceVisibilitySchema = z4.enum(["public", "private"]);
124
138
  var destinationVisibilitySchema = z4.enum(["public", "private"]);
@@ -152,11 +166,14 @@ var webSourceSchema = z4.object({
152
166
  // Web can continue any existing conversation id, including Slack roots.
153
167
  conversationId: exactNonBlankStringSchema
154
168
  }).strict();
155
- var sourceSchema = z4.discriminatedUnion("platform", [
156
- slackSourceSchema,
157
- localSourceSchema,
158
- webSourceSchema
169
+ var sourceWithLegacyLocationSchema = z4.discriminatedUnion("platform", [
170
+ slackSourceSchema.extend({ location: locationSchema.optional() }).strict(),
171
+ localSourceSchema.extend({ location: locationSchema.optional() }).strict(),
172
+ webSourceSchema.extend({ location: locationSchema.optional() }).strict()
159
173
  ]);
174
+ var sourceSchema = sourceWithLegacyLocationSchema.transform(
175
+ ({ location: _legacyLocation, ...source }) => source
176
+ );
160
177
  var pluginCredentialSubjectSchema = z4.discriminatedUnion(
161
178
  "allowedWhen",
162
179
  [
@@ -1015,6 +1032,7 @@ export {
1015
1032
  localActorSchema,
1016
1033
  localDestinationSchema,
1017
1034
  localSourceSchema,
1035
+ locationSchema,
1018
1036
  missingToolAnnotationKeys,
1019
1037
  nonBlankStringSchema,
1020
1038
  normalizeResourceEventIdentifier,
@@ -1059,6 +1077,7 @@ export {
1059
1077
  resourceTypeSchema,
1060
1078
  slackActorSchema,
1061
1079
  slackDestinationSchema,
1080
+ slackLocationSchema,
1062
1081
  slackSourceSchema,
1063
1082
  sourceSchema,
1064
1083
  sourceVisibilitySchema,
package/dist/schemas.d.ts CHANGED
@@ -2,6 +2,22 @@ import { z } from "zod";
2
2
  /** Exact non-blank actor user id that rejects the sentinel "unknown". */
3
3
  export declare const actorUserIdSchema: z.ZodString;
4
4
  export declare const nonBlankStringSchema: z.ZodString;
5
+ /** Complete Slack Location associated with a Conversation. */
6
+ export declare const slackLocationSchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ provider: z.ZodLiteral<"slack">;
9
+ teamId: z.ZodString;
10
+ channelId: z.ZodString;
11
+ threadTs: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strict>;
13
+ /** Complete Location types supported by Junior. */
14
+ export declare const locationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
+ id: z.ZodString;
16
+ provider: z.ZodLiteral<"slack">;
17
+ teamId: z.ZodString;
18
+ channelId: z.ZodString;
19
+ threadTs: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strict>], "provider">;
5
21
  /** Runtime platform names supported by plugin public contracts. */
6
22
  export declare const platformSchema: z.ZodEnum<{
7
23
  slack: "slack";
@@ -64,8 +80,8 @@ export declare const webSourceSchema: z.ZodObject<{
64
80
  }>;
65
81
  conversationId: z.ZodString;
66
82
  }, z.core.$strict>;
67
- /** Runtime-owned provider-neutral coordinates for the inbound invocation. */
68
- export declare const sourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
83
+ /** Runtime-owned input Source. Legacy stored Location is accepted and removed. */
84
+ export declare const sourceSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
69
85
  platform: z.ZodLiteral<"slack">;
70
86
  teamId: z.ZodString;
71
87
  channelId: z.ZodString;
@@ -75,10 +91,24 @@ export declare const sourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
75
91
  }>;
76
92
  messageTs: z.ZodOptional<z.ZodString>;
77
93
  threadTs: z.ZodOptional<z.ZodString>;
94
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
95
+ id: z.ZodString;
96
+ provider: z.ZodLiteral<"slack">;
97
+ teamId: z.ZodString;
98
+ channelId: z.ZodString;
99
+ threadTs: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strict>], "provider">>;
78
101
  }, z.core.$strict>, z.ZodObject<{
79
102
  platform: z.ZodLiteral<"local">;
80
103
  visibility: z.ZodLiteral<"private">;
81
104
  conversationId: z.ZodString;
105
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
106
+ id: z.ZodString;
107
+ provider: z.ZodLiteral<"slack">;
108
+ teamId: z.ZodString;
109
+ channelId: z.ZodString;
110
+ threadTs: z.ZodOptional<z.ZodString>;
111
+ }, z.core.$strict>], "provider">>;
82
112
  }, z.core.$strict>, z.ZodObject<{
83
113
  platform: z.ZodLiteral<"web">;
84
114
  visibility: z.ZodEnum<{
@@ -86,7 +116,65 @@ export declare const sourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
86
116
  private: "private";
87
117
  }>;
88
118
  conversationId: z.ZodString;
89
- }, z.core.$strict>], "platform">;
119
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
120
+ id: z.ZodString;
121
+ provider: z.ZodLiteral<"slack">;
122
+ teamId: z.ZodString;
123
+ channelId: z.ZodString;
124
+ threadTs: z.ZodOptional<z.ZodString>;
125
+ }, z.core.$strict>], "provider">>;
126
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
127
+ platform: "slack";
128
+ teamId: string;
129
+ channelId: string;
130
+ visibility: "public" | "private";
131
+ messageTs?: string | undefined;
132
+ threadTs?: string | undefined;
133
+ } | {
134
+ platform: "local";
135
+ visibility: "private";
136
+ conversationId: string;
137
+ } | {
138
+ platform: "web";
139
+ visibility: "public" | "private";
140
+ conversationId: string;
141
+ }, {
142
+ platform: "slack";
143
+ teamId: string;
144
+ channelId: string;
145
+ visibility: "public" | "private";
146
+ messageTs?: string | undefined;
147
+ threadTs?: string | undefined;
148
+ location?: {
149
+ id: string;
150
+ provider: "slack";
151
+ teamId: string;
152
+ channelId: string;
153
+ threadTs?: string | undefined;
154
+ } | undefined;
155
+ } | {
156
+ platform: "local";
157
+ visibility: "private";
158
+ conversationId: string;
159
+ location?: {
160
+ id: string;
161
+ provider: "slack";
162
+ teamId: string;
163
+ channelId: string;
164
+ threadTs?: string | undefined;
165
+ } | undefined;
166
+ } | {
167
+ platform: "web";
168
+ visibility: "public" | "private";
169
+ conversationId: string;
170
+ location?: {
171
+ id: string;
172
+ provider: "slack";
173
+ teamId: string;
174
+ channelId: string;
175
+ threadTs?: string | undefined;
176
+ } | undefined;
177
+ }>>;
90
178
  /** Stable user credential subject shape accepted from plugins. */
91
179
  export declare const pluginCredentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
92
180
  type: z.ZodLiteral<"user">;
@@ -204,7 +292,7 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
204
292
  label: z.ZodPipe<z.ZodString, z.ZodString>;
205
293
  detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
206
294
  }, z.core.$strict>>;
207
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
295
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
208
296
  platform: z.ZodLiteral<"slack">;
209
297
  teamId: z.ZodString;
210
298
  channelId: z.ZodString;
@@ -214,10 +302,24 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
214
302
  }>;
215
303
  messageTs: z.ZodOptional<z.ZodString>;
216
304
  threadTs: z.ZodOptional<z.ZodString>;
305
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
306
+ id: z.ZodString;
307
+ provider: z.ZodLiteral<"slack">;
308
+ teamId: z.ZodString;
309
+ channelId: z.ZodString;
310
+ threadTs: z.ZodOptional<z.ZodString>;
311
+ }, z.core.$strict>], "provider">>;
217
312
  }, z.core.$strict>, z.ZodObject<{
218
313
  platform: z.ZodLiteral<"local">;
219
314
  visibility: z.ZodLiteral<"private">;
220
315
  conversationId: z.ZodString;
316
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
317
+ id: z.ZodString;
318
+ provider: z.ZodLiteral<"slack">;
319
+ teamId: z.ZodString;
320
+ channelId: z.ZodString;
321
+ threadTs: z.ZodOptional<z.ZodString>;
322
+ }, z.core.$strict>], "provider">>;
221
323
  }, z.core.$strict>, z.ZodObject<{
222
324
  platform: z.ZodLiteral<"web">;
223
325
  visibility: z.ZodEnum<{
@@ -225,5 +327,63 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
225
327
  private: "private";
226
328
  }>;
227
329
  conversationId: z.ZodString;
228
- }, z.core.$strict>], "platform">;
330
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
331
+ id: z.ZodString;
332
+ provider: z.ZodLiteral<"slack">;
333
+ teamId: z.ZodString;
334
+ channelId: z.ZodString;
335
+ threadTs: z.ZodOptional<z.ZodString>;
336
+ }, z.core.$strict>], "provider">>;
337
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
338
+ platform: "slack";
339
+ teamId: string;
340
+ channelId: string;
341
+ visibility: "public" | "private";
342
+ messageTs?: string | undefined;
343
+ threadTs?: string | undefined;
344
+ } | {
345
+ platform: "local";
346
+ visibility: "private";
347
+ conversationId: string;
348
+ } | {
349
+ platform: "web";
350
+ visibility: "public" | "private";
351
+ conversationId: string;
352
+ }, {
353
+ platform: "slack";
354
+ teamId: string;
355
+ channelId: string;
356
+ visibility: "public" | "private";
357
+ messageTs?: string | undefined;
358
+ threadTs?: string | undefined;
359
+ location?: {
360
+ id: string;
361
+ provider: "slack";
362
+ teamId: string;
363
+ channelId: string;
364
+ threadTs?: string | undefined;
365
+ } | undefined;
366
+ } | {
367
+ platform: "local";
368
+ visibility: "private";
369
+ conversationId: string;
370
+ location?: {
371
+ id: string;
372
+ provider: "slack";
373
+ teamId: string;
374
+ channelId: string;
375
+ threadTs?: string | undefined;
376
+ } | undefined;
377
+ } | {
378
+ platform: "web";
379
+ visibility: "public" | "private";
380
+ conversationId: string;
381
+ location?: {
382
+ id: string;
383
+ provider: "slack";
384
+ teamId: string;
385
+ channelId: string;
386
+ threadTs?: string | undefined;
387
+ } | undefined;
388
+ }>>;
229
389
  }, z.core.$strict>;
package/dist/tasks.d.ts CHANGED
@@ -148,7 +148,7 @@ export declare const pluginRunContextSchema: z.ZodObject<{
148
148
  name: z.ZodString;
149
149
  }, z.core.$strict>], "platform">>;
150
150
  runId: z.ZodString;
151
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
151
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
152
152
  platform: z.ZodLiteral<"slack">;
153
153
  teamId: z.ZodString;
154
154
  channelId: z.ZodString;
@@ -158,10 +158,24 @@ export declare const pluginRunContextSchema: z.ZodObject<{
158
158
  }>;
159
159
  messageTs: z.ZodOptional<z.ZodString>;
160
160
  threadTs: z.ZodOptional<z.ZodString>;
161
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
162
+ id: z.ZodString;
163
+ provider: z.ZodLiteral<"slack">;
164
+ teamId: z.ZodString;
165
+ channelId: z.ZodString;
166
+ threadTs: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strict>], "provider">>;
161
168
  }, z.core.$strict>, z.ZodObject<{
162
169
  platform: z.ZodLiteral<"local">;
163
170
  visibility: z.ZodLiteral<"private">;
164
171
  conversationId: z.ZodString;
172
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
173
+ id: z.ZodString;
174
+ provider: z.ZodLiteral<"slack">;
175
+ teamId: z.ZodString;
176
+ channelId: z.ZodString;
177
+ threadTs: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strict>], "provider">>;
165
179
  }, z.core.$strict>, z.ZodObject<{
166
180
  platform: z.ZodLiteral<"web">;
167
181
  visibility: z.ZodEnum<{
@@ -169,7 +183,65 @@ export declare const pluginRunContextSchema: z.ZodObject<{
169
183
  private: "private";
170
184
  }>;
171
185
  conversationId: z.ZodString;
172
- }, z.core.$strict>], "platform">;
186
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
187
+ id: z.ZodString;
188
+ provider: z.ZodLiteral<"slack">;
189
+ teamId: z.ZodString;
190
+ channelId: z.ZodString;
191
+ threadTs: z.ZodOptional<z.ZodString>;
192
+ }, z.core.$strict>], "provider">>;
193
+ }, z.core.$strict>], "platform">, z.ZodTransform<{
194
+ platform: "slack";
195
+ teamId: string;
196
+ channelId: string;
197
+ visibility: "public" | "private";
198
+ messageTs?: string | undefined;
199
+ threadTs?: string | undefined;
200
+ } | {
201
+ platform: "local";
202
+ visibility: "private";
203
+ conversationId: string;
204
+ } | {
205
+ platform: "web";
206
+ visibility: "public" | "private";
207
+ conversationId: string;
208
+ }, {
209
+ platform: "slack";
210
+ teamId: string;
211
+ channelId: string;
212
+ visibility: "public" | "private";
213
+ messageTs?: string | undefined;
214
+ threadTs?: string | undefined;
215
+ location?: {
216
+ id: string;
217
+ provider: "slack";
218
+ teamId: string;
219
+ channelId: string;
220
+ threadTs?: string | undefined;
221
+ } | undefined;
222
+ } | {
223
+ platform: "local";
224
+ visibility: "private";
225
+ conversationId: string;
226
+ location?: {
227
+ id: string;
228
+ provider: "slack";
229
+ teamId: string;
230
+ channelId: string;
231
+ threadTs?: string | undefined;
232
+ } | undefined;
233
+ } | {
234
+ platform: "web";
235
+ visibility: "public" | "private";
236
+ conversationId: string;
237
+ location?: {
238
+ id: string;
239
+ provider: "slack";
240
+ teamId: string;
241
+ channelId: string;
242
+ threadTs?: string | undefined;
243
+ } | undefined;
244
+ }>>;
173
245
  transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
174
246
  type: z.ZodLiteral<"message">;
175
247
  role: z.ZodEnum<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.187.0",
3
+ "version": "0.189.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/context.ts CHANGED
@@ -3,6 +3,7 @@ import type { ZodTypeAny } from "zod";
3
3
  import {
4
4
  destinationSchema,
5
5
  identitySchema,
6
+ locationSchema,
6
7
  webActorSchema,
7
8
  localActorSchema,
8
9
  platformSchema,
@@ -10,6 +11,7 @@ import {
10
11
  slackActorSchema,
11
12
  systemActorSchema,
12
13
  sourceSchema,
14
+ slackLocationSchema,
13
15
  userSchema,
14
16
  } from "./schemas";
15
17
 
@@ -23,6 +25,10 @@ export type SystemActor = z.output<typeof systemActorSchema>;
23
25
  export type Identity = z.output<typeof identitySchema>;
24
26
  export type User = z.output<typeof userSchema>;
25
27
  export type Source = z.output<typeof sourceSchema>;
28
+ /** Validated Location associated with a Conversation. */
29
+ export type Location = z.output<typeof locationSchema>;
30
+ /** Complete Slack Location associated with a Conversation. */
31
+ export type SlackLocation = z.output<typeof slackLocationSchema>;
26
32
  export type SlackSource = Extract<Source, { platform: "slack" }>;
27
33
  export type LocalSource = Extract<Source, { platform: "local" }>;
28
34
  export type WebSource = Extract<Source, { platform: "web" }>;
package/src/schemas.ts CHANGED
@@ -21,6 +21,30 @@ const exactNonBlankStringSchema = nonBlankStringSchema.refine(
21
21
  (value) => value === value.trim(),
22
22
  );
23
23
 
24
+ /** Fields shared by every Location. */
25
+ const baseLocationSchema = z
26
+ .object({
27
+ /** Stable SQL identity used by Location configuration and reporting. */
28
+ id: nonBlankStringSchema,
29
+ provider: exactNonBlankStringSchema,
30
+ })
31
+ .strict();
32
+
33
+ /** Complete Slack Location associated with a Conversation. */
34
+ export const slackLocationSchema = baseLocationSchema
35
+ .extend({
36
+ provider: z.literal("slack"),
37
+ teamId: slackTeamIdSchema,
38
+ channelId: slackConversationIdSchema,
39
+ threadTs: exactNonBlankStringSchema.optional(),
40
+ })
41
+ .strict();
42
+
43
+ /** Complete Location types supported by Junior. */
44
+ export const locationSchema = z.discriminatedUnion("provider", [
45
+ slackLocationSchema,
46
+ ]);
47
+
24
48
  /** Runtime platform names supported by plugin public contracts. */
25
49
  export const platformSchema = z.enum(["slack", "local"]);
26
50
 
@@ -83,13 +107,21 @@ export const webSourceSchema = z
83
107
  })
84
108
  .strict();
85
109
 
86
- /** Runtime-owned provider-neutral coordinates for the inbound invocation. */
87
- export const sourceSchema = z.discriminatedUnion("platform", [
88
- slackSourceSchema,
89
- localSourceSchema,
90
- webSourceSchema,
110
+ // TODO(dcramer): Replace Source.platform with Source.kind after every input
111
+ // owner emits a first-class Source kind and deployed readers accept it.
112
+ const sourceWithLegacyLocationSchema = z.discriminatedUnion("platform", [
113
+ slackSourceSchema.extend({ location: locationSchema.optional() }).strict(),
114
+ localSourceSchema.extend({ location: locationSchema.optional() }).strict(),
115
+ webSourceSchema.extend({ location: locationSchema.optional() }).strict(),
91
116
  ]);
92
117
 
118
+ /** Runtime-owned input Source. Legacy stored Location is accepted and removed. */
119
+ // TODO(dcramer): Parse sourceSchema directly from the three Source schemas after
120
+ // no stored SQL, Redis, queue, or public Source can contain Location.
121
+ export const sourceSchema = sourceWithLegacyLocationSchema.transform(
122
+ ({ location: _legacyLocation, ...source }) => source,
123
+ );
124
+
93
125
  /** Stable user credential subject shape accepted from plugins. */
94
126
  export const pluginCredentialSubjectSchema = z.discriminatedUnion(
95
127
  "allowedWhen",