@sentry/junior-plugin-api 0.188.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, locationSchema, 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>;
@@ -13,6 +13,8 @@ export type User = z.output<typeof userSchema>;
13
13
  export type Source = z.output<typeof sourceSchema>;
14
14
  /** Validated Location associated with a Conversation. */
15
15
  export type Location = z.output<typeof locationSchema>;
16
+ /** Complete Slack Location associated with a Conversation. */
17
+ export type SlackLocation = z.output<typeof slackLocationSchema>;
16
18
  export type SlackSource = Extract<Source, {
17
19
  platform: "slack";
18
20
  }>;
package/dist/index.js CHANGED
@@ -119,16 +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 locationSchema = z4.object({
123
- /** Junior-owned stable identity for this location. */
122
+ var baseLocationSchema = z4.object({
123
+ /** Stable SQL identity used by Location configuration and reporting. */
124
124
  id: nonBlankStringSchema,
125
- /** Provider namespace that owns the provider and tenant identifiers. */
126
- provider: nonBlankStringSchema,
127
- /** Optional provider-native workspace, account, or tenant scope. */
128
- tenantId: nonBlankStringSchema.optional(),
129
- /** Provider-native identifier for the container within its tenant scope. */
130
- providerId: nonBlankStringSchema
125
+ provider: exactNonBlankStringSchema
131
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
+ ]);
132
136
  var platformSchema = z4.enum(["slack", "local"]);
133
137
  var sourceVisibilitySchema = z4.enum(["public", "private"]);
134
138
  var destinationVisibilitySchema = z4.enum(["public", "private"]);
@@ -147,29 +151,29 @@ var destinationSchema = z4.discriminatedUnion("platform", [
147
151
  localDestinationSchema
148
152
  ]);
149
153
  var slackSourceSchema = slackAddressSchema.extend({
150
- location: locationSchema.optional(),
151
154
  visibility: sourceVisibilitySchema,
152
155
  messageTs: nonBlankStringSchema.optional(),
153
156
  threadTs: nonBlankStringSchema.optional()
154
157
  }).strict();
155
158
  var localSourceSchema = z4.object({
156
- location: locationSchema.optional(),
157
159
  platform: z4.literal("local"),
158
160
  visibility: z4.literal("private"),
159
161
  conversationId: localConversationIdSchema
160
162
  }).strict();
161
163
  var webSourceSchema = z4.object({
162
- location: locationSchema.optional(),
163
164
  platform: z4.literal("web"),
164
165
  visibility: sourceVisibilitySchema,
165
166
  // Web can continue any existing conversation id, including Slack roots.
166
167
  conversationId: exactNonBlankStringSchema
167
168
  }).strict();
168
- var sourceSchema = z4.discriminatedUnion("platform", [
169
- slackSourceSchema,
170
- localSourceSchema,
171
- 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()
172
173
  ]);
174
+ var sourceSchema = sourceWithLegacyLocationSchema.transform(
175
+ ({ location: _legacyLocation, ...source }) => source
176
+ );
173
177
  var pluginCredentialSubjectSchema = z4.discriminatedUnion(
174
178
  "allowedWhen",
175
179
  [
@@ -1073,6 +1077,7 @@ export {
1073
1077
  resourceTypeSchema,
1074
1078
  slackActorSchema,
1075
1079
  slackDestinationSchema,
1080
+ slackLocationSchema,
1076
1081
  slackSourceSchema,
1077
1082
  sourceSchema,
1078
1083
  sourceVisibilitySchema,
package/dist/schemas.d.ts CHANGED
@@ -2,13 +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
- /** One place outside Junior where a Conversation can be delivered. */
6
- export declare const locationSchema: z.ZodObject<{
5
+ /** Complete Slack Location associated with a Conversation. */
6
+ export declare const slackLocationSchema: z.ZodObject<{
7
7
  id: z.ZodString;
8
- provider: z.ZodString;
9
- tenantId: z.ZodOptional<z.ZodString>;
10
- providerId: z.ZodString;
8
+ provider: z.ZodLiteral<"slack">;
9
+ teamId: z.ZodString;
10
+ channelId: z.ZodString;
11
+ threadTs: z.ZodOptional<z.ZodString>;
11
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">;
12
21
  /** Runtime platform names supported by plugin public contracts. */
13
22
  export declare const platformSchema: z.ZodEnum<{
14
23
  slack: "slack";
@@ -49,12 +58,6 @@ export declare const slackSourceSchema: z.ZodObject<{
49
58
  platform: z.ZodLiteral<"slack">;
50
59
  teamId: z.ZodString;
51
60
  channelId: z.ZodString;
52
- location: z.ZodOptional<z.ZodObject<{
53
- id: z.ZodString;
54
- provider: z.ZodString;
55
- tenantId: z.ZodOptional<z.ZodString>;
56
- providerId: z.ZodString;
57
- }, z.core.$strict>>;
58
61
  visibility: z.ZodEnum<{
59
62
  public: "public";
60
63
  private: "private";
@@ -64,24 +67,12 @@ export declare const slackSourceSchema: z.ZodObject<{
64
67
  }, z.core.$strict>;
65
68
  /** Runtime-owned local CLI coordinates for the inbound invocation. */
66
69
  export declare const localSourceSchema: z.ZodObject<{
67
- location: z.ZodOptional<z.ZodObject<{
68
- id: z.ZodString;
69
- provider: z.ZodString;
70
- tenantId: z.ZodOptional<z.ZodString>;
71
- providerId: z.ZodString;
72
- }, z.core.$strict>>;
73
70
  platform: z.ZodLiteral<"local">;
74
71
  visibility: z.ZodLiteral<"private">;
75
72
  conversationId: z.ZodString;
76
73
  }, z.core.$strict>;
77
74
  /** Runtime-owned dashboard/web coordinates for the inbound invocation. */
78
75
  export declare const webSourceSchema: z.ZodObject<{
79
- location: z.ZodOptional<z.ZodObject<{
80
- id: z.ZodString;
81
- provider: z.ZodString;
82
- tenantId: z.ZodOptional<z.ZodString>;
83
- providerId: z.ZodString;
84
- }, z.core.$strict>>;
85
76
  platform: z.ZodLiteral<"web">;
86
77
  visibility: z.ZodEnum<{
87
78
  public: "public";
@@ -89,47 +80,101 @@ export declare const webSourceSchema: z.ZodObject<{
89
80
  }>;
90
81
  conversationId: z.ZodString;
91
82
  }, z.core.$strict>;
92
- /** Runtime-owned provider-neutral coordinates for the inbound invocation. */
93
- 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<{
94
85
  platform: z.ZodLiteral<"slack">;
95
86
  teamId: z.ZodString;
96
87
  channelId: z.ZodString;
97
- location: z.ZodOptional<z.ZodObject<{
98
- id: z.ZodString;
99
- provider: z.ZodString;
100
- tenantId: z.ZodOptional<z.ZodString>;
101
- providerId: z.ZodString;
102
- }, z.core.$strict>>;
103
88
  visibility: z.ZodEnum<{
104
89
  public: "public";
105
90
  private: "private";
106
91
  }>;
107
92
  messageTs: z.ZodOptional<z.ZodString>;
108
93
  threadTs: z.ZodOptional<z.ZodString>;
109
- }, z.core.$strict>, z.ZodObject<{
110
- location: z.ZodOptional<z.ZodObject<{
94
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
111
95
  id: z.ZodString;
112
- provider: z.ZodString;
113
- tenantId: z.ZodOptional<z.ZodString>;
114
- providerId: z.ZodString;
115
- }, z.core.$strict>>;
96
+ provider: z.ZodLiteral<"slack">;
97
+ teamId: z.ZodString;
98
+ channelId: z.ZodString;
99
+ threadTs: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strict>], "provider">>;
101
+ }, z.core.$strict>, z.ZodObject<{
116
102
  platform: z.ZodLiteral<"local">;
117
103
  visibility: z.ZodLiteral<"private">;
118
104
  conversationId: z.ZodString;
119
- }, z.core.$strict>, z.ZodObject<{
120
- location: z.ZodOptional<z.ZodObject<{
105
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
121
106
  id: z.ZodString;
122
- provider: z.ZodString;
123
- tenantId: z.ZodOptional<z.ZodString>;
124
- providerId: z.ZodString;
125
- }, z.core.$strict>>;
107
+ provider: z.ZodLiteral<"slack">;
108
+ teamId: z.ZodString;
109
+ channelId: z.ZodString;
110
+ threadTs: z.ZodOptional<z.ZodString>;
111
+ }, z.core.$strict>], "provider">>;
112
+ }, z.core.$strict>, z.ZodObject<{
126
113
  platform: z.ZodLiteral<"web">;
127
114
  visibility: z.ZodEnum<{
128
115
  public: "public";
129
116
  private: "private";
130
117
  }>;
131
118
  conversationId: z.ZodString;
132
- }, 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
+ }>>;
133
178
  /** Stable user credential subject shape accepted from plugins. */
134
179
  export declare const pluginCredentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
135
180
  type: z.ZodLiteral<"user">;
@@ -247,44 +292,98 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
247
292
  label: z.ZodPipe<z.ZodString, z.ZodString>;
248
293
  detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
249
294
  }, z.core.$strict>>;
250
- source: z.ZodDiscriminatedUnion<[z.ZodObject<{
295
+ source: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
251
296
  platform: z.ZodLiteral<"slack">;
252
297
  teamId: z.ZodString;
253
298
  channelId: z.ZodString;
254
- location: z.ZodOptional<z.ZodObject<{
255
- id: z.ZodString;
256
- provider: z.ZodString;
257
- tenantId: z.ZodOptional<z.ZodString>;
258
- providerId: z.ZodString;
259
- }, z.core.$strict>>;
260
299
  visibility: z.ZodEnum<{
261
300
  public: "public";
262
301
  private: "private";
263
302
  }>;
264
303
  messageTs: z.ZodOptional<z.ZodString>;
265
304
  threadTs: z.ZodOptional<z.ZodString>;
266
- }, z.core.$strict>, z.ZodObject<{
267
- location: z.ZodOptional<z.ZodObject<{
305
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
268
306
  id: z.ZodString;
269
- provider: z.ZodString;
270
- tenantId: z.ZodOptional<z.ZodString>;
271
- providerId: z.ZodString;
272
- }, z.core.$strict>>;
307
+ provider: z.ZodLiteral<"slack">;
308
+ teamId: z.ZodString;
309
+ channelId: z.ZodString;
310
+ threadTs: z.ZodOptional<z.ZodString>;
311
+ }, z.core.$strict>], "provider">>;
312
+ }, z.core.$strict>, z.ZodObject<{
273
313
  platform: z.ZodLiteral<"local">;
274
314
  visibility: z.ZodLiteral<"private">;
275
315
  conversationId: z.ZodString;
276
- }, z.core.$strict>, z.ZodObject<{
277
- location: z.ZodOptional<z.ZodObject<{
316
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
278
317
  id: z.ZodString;
279
- provider: z.ZodString;
280
- tenantId: z.ZodOptional<z.ZodString>;
281
- providerId: z.ZodString;
282
- }, z.core.$strict>>;
318
+ provider: z.ZodLiteral<"slack">;
319
+ teamId: z.ZodString;
320
+ channelId: z.ZodString;
321
+ threadTs: z.ZodOptional<z.ZodString>;
322
+ }, z.core.$strict>], "provider">>;
323
+ }, z.core.$strict>, z.ZodObject<{
283
324
  platform: z.ZodLiteral<"web">;
284
325
  visibility: z.ZodEnum<{
285
326
  public: "public";
286
327
  private: "private";
287
328
  }>;
288
329
  conversationId: z.ZodString;
289
- }, 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
+ }>>;
290
389
  }, z.core.$strict>;
package/dist/tasks.d.ts CHANGED
@@ -148,46 +148,100 @@ 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;
155
- location: z.ZodOptional<z.ZodObject<{
156
- id: z.ZodString;
157
- provider: z.ZodString;
158
- tenantId: z.ZodOptional<z.ZodString>;
159
- providerId: z.ZodString;
160
- }, z.core.$strict>>;
161
155
  visibility: z.ZodEnum<{
162
156
  public: "public";
163
157
  private: "private";
164
158
  }>;
165
159
  messageTs: z.ZodOptional<z.ZodString>;
166
160
  threadTs: z.ZodOptional<z.ZodString>;
167
- }, z.core.$strict>, z.ZodObject<{
168
- location: z.ZodOptional<z.ZodObject<{
161
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
169
162
  id: z.ZodString;
170
- provider: z.ZodString;
171
- tenantId: z.ZodOptional<z.ZodString>;
172
- providerId: z.ZodString;
173
- }, z.core.$strict>>;
163
+ provider: z.ZodLiteral<"slack">;
164
+ teamId: z.ZodString;
165
+ channelId: z.ZodString;
166
+ threadTs: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strict>], "provider">>;
168
+ }, z.core.$strict>, z.ZodObject<{
174
169
  platform: z.ZodLiteral<"local">;
175
170
  visibility: z.ZodLiteral<"private">;
176
171
  conversationId: z.ZodString;
177
- }, z.core.$strict>, z.ZodObject<{
178
- location: z.ZodOptional<z.ZodObject<{
172
+ location: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
179
173
  id: z.ZodString;
180
- provider: z.ZodString;
181
- tenantId: z.ZodOptional<z.ZodString>;
182
- providerId: z.ZodString;
183
- }, z.core.$strict>>;
174
+ provider: z.ZodLiteral<"slack">;
175
+ teamId: z.ZodString;
176
+ channelId: z.ZodString;
177
+ threadTs: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strict>], "provider">>;
179
+ }, z.core.$strict>, z.ZodObject<{
184
180
  platform: z.ZodLiteral<"web">;
185
181
  visibility: z.ZodEnum<{
186
182
  public: "public";
187
183
  private: "private";
188
184
  }>;
189
185
  conversationId: z.ZodString;
190
- }, 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
+ }>>;
191
245
  transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
192
246
  type: z.ZodLiteral<"message">;
193
247
  role: z.ZodEnum<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.188.0",
3
+ "version": "0.189.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/context.ts CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  slackActorSchema,
12
12
  systemActorSchema,
13
13
  sourceSchema,
14
+ slackLocationSchema,
14
15
  userSchema,
15
16
  } from "./schemas";
16
17
 
@@ -26,6 +27,8 @@ export type User = z.output<typeof userSchema>;
26
27
  export type Source = z.output<typeof sourceSchema>;
27
28
  /** Validated Location associated with a Conversation. */
28
29
  export type Location = z.output<typeof locationSchema>;
30
+ /** Complete Slack Location associated with a Conversation. */
31
+ export type SlackLocation = z.output<typeof slackLocationSchema>;
29
32
  export type SlackSource = Extract<Source, { platform: "slack" }>;
30
33
  export type LocalSource = Extract<Source, { platform: "local" }>;
31
34
  export type WebSource = Extract<Source, { platform: "web" }>;
package/src/schemas.ts CHANGED
@@ -21,22 +21,30 @@ const exactNonBlankStringSchema = nonBlankStringSchema.refine(
21
21
  (value) => value === value.trim(),
22
22
  );
23
23
 
24
- /** One place outside Junior where a Conversation can be delivered. */
25
- // TODO(dcramer): Add the fields Location needs to identify the exact provider
26
- // Conversation. For Slack, this includes threadTs.
27
- export const locationSchema = z
24
+ /** Fields shared by every Location. */
25
+ const baseLocationSchema = z
28
26
  .object({
29
- /** Junior-owned stable identity for this location. */
27
+ /** Stable SQL identity used by Location configuration and reporting. */
30
28
  id: nonBlankStringSchema,
31
- /** Provider namespace that owns the provider and tenant identifiers. */
32
- provider: nonBlankStringSchema,
33
- /** Optional provider-native workspace, account, or tenant scope. */
34
- tenantId: nonBlankStringSchema.optional(),
35
- /** Provider-native identifier for the container within its tenant scope. */
36
- providerId: nonBlankStringSchema,
29
+ provider: exactNonBlankStringSchema,
37
30
  })
38
31
  .strict();
39
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
+
40
48
  /** Runtime platform names supported by plugin public contracts. */
41
49
  export const platformSchema = z.enum(["slack", "local"]);
42
50
 
@@ -74,7 +82,6 @@ export const destinationSchema = z.discriminatedUnion("platform", [
74
82
  /** Runtime-owned Slack coordinates for the inbound invocation. */
75
83
  export const slackSourceSchema = slackAddressSchema
76
84
  .extend({
77
- location: locationSchema.optional(),
78
85
  visibility: sourceVisibilitySchema,
79
86
  messageTs: nonBlankStringSchema.optional(),
80
87
  threadTs: nonBlankStringSchema.optional(),
@@ -84,7 +91,6 @@ export const slackSourceSchema = slackAddressSchema
84
91
  /** Runtime-owned local CLI coordinates for the inbound invocation. */
85
92
  export const localSourceSchema = z
86
93
  .object({
87
- location: locationSchema.optional(),
88
94
  platform: z.literal("local"),
89
95
  visibility: z.literal("private"),
90
96
  conversationId: localConversationIdSchema,
@@ -94,7 +100,6 @@ export const localSourceSchema = z
94
100
  /** Runtime-owned dashboard/web coordinates for the inbound invocation. */
95
101
  export const webSourceSchema = z
96
102
  .object({
97
- location: locationSchema.optional(),
98
103
  platform: z.literal("web"),
99
104
  visibility: sourceVisibilitySchema,
100
105
  // Web can continue any existing conversation id, including Slack roots.
@@ -102,13 +107,21 @@ export const webSourceSchema = z
102
107
  })
103
108
  .strict();
104
109
 
105
- /** Runtime-owned provider-neutral coordinates for the inbound invocation. */
106
- export const sourceSchema = z.discriminatedUnion("platform", [
107
- slackSourceSchema,
108
- localSourceSchema,
109
- 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(),
110
116
  ]);
111
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
+
112
125
  /** Stable user credential subject shape accepted from plugins. */
113
126
  export const pluginCredentialSubjectSchema = z.discriminatedUnion(
114
127
  "allowedWhen",