terse-types 0.0.19 → 0.0.20

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.
@@ -114,6 +114,7 @@ export declare const ApiRoutes: {
114
114
  INTEGRATIONS: {
115
115
  INSTALLATION_DETAILS_BY_TYPE: string;
116
116
  LIST: string;
117
+ DISCONNECT_BY_TYPE: string;
117
118
  ACTIVE: string;
118
119
  };
119
120
  NOTIFICATION_DESTINATIONS: {
@@ -114,6 +114,7 @@
114
114
  "INTEGRATIONS": {
115
115
  "INSTALLATION_DETAILS_BY_TYPE": "/integrations/:integrationType/installation-details",
116
116
  "LIST": "/integrations",
117
+ "DISCONNECT_BY_TYPE": "/integrations/:integrationType/disconnect",
117
118
  "ACTIVE": "/integrations/active"
118
119
  },
119
120
  "NOTIFICATION_DESTINATIONS": {
@@ -230,9 +230,26 @@ export declare const SnowflakeIntegrationSchema: z.ZodObject<{
230
230
  schemaName: z.ZodOptional<z.ZodString>;
231
231
  }, z.core.$strip>;
232
232
  export type SnowflakeIntegration = z.infer<typeof SnowflakeIntegrationSchema>;
233
+ export declare const CliIntegrationDisplayStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
234
+ status: z.ZodLiteral<"not_connected">;
235
+ }, z.core.$strip>, z.ZodObject<{
236
+ status: z.ZodLiteral<"connected">;
237
+ summaryLabel: z.ZodString;
238
+ summaryValue: z.ZodString;
239
+ integrationId: z.ZodString;
240
+ }, z.core.$strip>], "status">;
241
+ export type CliIntegrationDisplayState = z.infer<typeof CliIntegrationDisplayStateSchema>;
233
242
  export declare const IntegrationWithStatusSchema: z.ZodObject<{
234
243
  integrationType: z.ZodEnum<typeof IntegrationType>;
235
244
  isActive: z.ZodBoolean;
245
+ cliDisplayState: z.ZodDiscriminatedUnion<[z.ZodObject<{
246
+ status: z.ZodLiteral<"not_connected">;
247
+ }, z.core.$strip>, z.ZodObject<{
248
+ status: z.ZodLiteral<"connected">;
249
+ summaryLabel: z.ZodString;
250
+ summaryValue: z.ZodString;
251
+ integrationId: z.ZodString;
252
+ }, z.core.$strip>], "status">;
236
253
  }, z.core.$strip>;
237
254
  export type IntegrationWithStatus = z.infer<typeof IntegrationWithStatusSchema>;
238
255
  export {};
@@ -192,7 +192,19 @@ export const SnowflakeIntegrationSchema = IntegrationInstanceSchema.extend({
192
192
  databaseName: z.string().optional(),
193
193
  schemaName: z.string().optional()
194
194
  });
195
+ export const CliIntegrationDisplayStateSchema = z.discriminatedUnion("status", [
196
+ z.object({
197
+ status: z.literal("not_connected")
198
+ }),
199
+ z.object({
200
+ status: z.literal("connected"),
201
+ summaryLabel: z.string(),
202
+ summaryValue: z.string(),
203
+ integrationId: z.string()
204
+ })
205
+ ]);
195
206
  export const IntegrationWithStatusSchema = z.object({
196
207
  integrationType: integrationTypeEnum,
197
- isActive: z.boolean()
208
+ isActive: z.boolean(),
209
+ cliDisplayState: CliIntegrationDisplayStateSchema
198
210
  });
@@ -1,3 +1,8 @@
1
1
  import type { Trigger } from "./Triggers.js";
2
+ export interface TriggerDisplay {
3
+ title: string;
4
+ subtitle: string;
5
+ }
2
6
  export declare function formatTriggerForAgent(event: Trigger): string;
3
7
  export declare function debugTrigger(event: Trigger): string;
8
+ export declare function displayTrigger(event: Trigger): TriggerDisplay;
@@ -2,22 +2,32 @@ import { IntegrationType } from "./Integrations.js";
2
2
  const TriggerPresenters = {
3
3
  manual_sample: {
4
4
  formatForAgent: (event) => `Manual sample event for ${event.integrationType}.`,
5
- debug: (event) => `${event.integrationType} ${event.eventType}`
5
+ debug: (event) => `${event.integrationType} ${event.eventType}`,
6
+ display: (event) => ({
7
+ title: `Manual ${event.integrationType} sample`,
8
+ subtitle: event.eventType
9
+ })
6
10
  },
7
11
  [IntegrationType.GITHUB]: {
8
12
  formatForAgent: formatGithubTrigger,
9
- debug: (event) => `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`
13
+ debug: (event) => `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`,
14
+ display: formatGithubDisplay
10
15
  },
11
16
  [IntegrationType.SLACK]: {
12
17
  formatForAgent: formatSlackTrigger,
13
18
  debug: (event) => {
14
19
  const isDM = event.channelType === "im";
15
20
  return `Slack Event: ${event.eventType} - ${isDM ? "DM" : event.channelName || event.channelId} - ${event.userName || event.userId}`;
16
- }
21
+ },
22
+ display: formatSlackDisplay
17
23
  },
18
24
  [IntegrationType.GMAIL]: {
19
25
  formatForAgent: formatGmailTrigger,
20
- debug: (event) => `Gmail Event: ${event.subject} message ID: ${event.messageId}`
26
+ debug: (event) => `Gmail Event: ${event.subject} message ID: ${event.messageId}`,
27
+ display: (event) => ({
28
+ title: event.subject || "(no subject)",
29
+ subtitle: `from ${event.from}`
30
+ })
21
31
  },
22
32
  [IntegrationType.LINEAR]: {
23
33
  formatForAgent: formatLinearTrigger,
@@ -26,23 +36,39 @@ const TriggerPresenters = {
26
36
  return `Linear ${event.type} Event: ${event.data.identifier} - ${event.data.title} (${event.action})`;
27
37
  }
28
38
  return `Linear ${event.type} Event: Comment on issue ${event.data.issueId || "Unknown"} (${event.action})`;
39
+ },
40
+ display: (event) => {
41
+ if (event.type === "Issue") {
42
+ return {
43
+ title: `${event.data.identifier} ${event.data.title}`,
44
+ subtitle: `${event.data.team?.name || "Linear"} · ${event.action} issue`
45
+ };
46
+ }
47
+ return {
48
+ title: `Comment on ${event.data.issueId || "Unknown issue"}`,
49
+ subtitle: `${event.actor.name} · ${event.action} comment`
50
+ };
29
51
  }
30
52
  },
31
53
  [IntegrationType.WORKOS]: {
32
54
  formatForAgent: formatWorkOSTrigger,
33
- debug: (event) => `WorkOS ${event.eventType}`
55
+ debug: (event) => `WorkOS ${event.eventType}`,
56
+ display: formatWorkOSDisplay
34
57
  },
35
58
  [IntegrationType.WEBHOOK]: {
36
59
  formatForAgent: formatWebhookTrigger,
37
- debug: (event) => `Webhook Trigger (${event.method})`
60
+ debug: (event) => `Webhook Trigger (${event.method})`,
61
+ display: formatWebhookDisplay
38
62
  },
39
63
  [IntegrationType.CRON_JOB]: {
40
64
  formatForAgent: formatCronTrigger,
41
- debug: (event) => (event.isManualTrigger ? "Manual Trigger" : "Scheduled Event")
65
+ debug: (event) => (event.isManualTrigger ? "Manual Trigger" : "Scheduled Event"),
66
+ display: formatCronDisplay
42
67
  },
43
68
  [IntegrationType.WEBMONITOR]: {
44
69
  formatForAgent: formatWebMonitorTrigger,
45
- debug: (event) => `${event.query.slice(0, 80)}${event.query.length > 80 ? "…" : ""}`
70
+ debug: (event) => `${event.query.slice(0, 80)}${event.query.length > 80 ? "…" : ""}`,
71
+ display: formatWebMonitorDisplay
46
72
  }
47
73
  };
48
74
  function dispatchPresenter(event, method) {
@@ -77,6 +103,12 @@ export function debugTrigger(event) {
77
103
  }
78
104
  return dispatchPresenter(event, "debug");
79
105
  }
106
+ export function displayTrigger(event) {
107
+ if (event.eventType === "manual_sample") {
108
+ return TriggerPresenters.manual_sample.display(event);
109
+ }
110
+ return dispatchPresenter(event, "display");
111
+ }
80
112
  function formatGithubTrigger(event) {
81
113
  const indentMultiline = (text) => text
82
114
  .split("\n")
@@ -174,6 +206,122 @@ function formatSlackTrigger(event) {
174
206
  : ""}
175
207
  `;
176
208
  }
209
+ function formatSlackDisplay(event) {
210
+ const channelLabel = event.channelType === "im" ? "DM" : event.channelName || event.channelId;
211
+ const actorLabel = event.userName || event.userId;
212
+ if (event.eventType === "reaction_added") {
213
+ return {
214
+ title: `:${event.reaction || "reaction"}: reaction`,
215
+ subtitle: `${channelLabel} by ${actorLabel}`
216
+ };
217
+ }
218
+ const messageText = event.text?.trim();
219
+ return {
220
+ title: messageText && messageText.length > 0 ? truncateForDisplay(messageText, 80) : "(no message text)",
221
+ subtitle: `${channelLabel} by ${actorLabel}`
222
+ };
223
+ }
224
+ function truncateForDisplay(value, maxLength) {
225
+ return value.length > maxLength ? `${value.slice(0, maxLength - 1)}…` : value;
226
+ }
227
+ function formatGithubDisplay(event) {
228
+ if (event.pullRequest) {
229
+ return {
230
+ title: `#${event.pullRequest.number} ${truncateForDisplay(event.pullRequest.title, 80)}`,
231
+ subtitle: `${event.repository.owner}/${event.repository.name} · ${event.eventType} by ${event.sender.login}`
232
+ };
233
+ }
234
+ if (event.commits.length > 0) {
235
+ const latestCommit = event.commits[event.commits.length - 1];
236
+ const commitMessage = latestCommit.message || latestCommit.name || latestCommit.sha.slice(0, 7);
237
+ return {
238
+ title: truncateForDisplay(commitMessage, 80),
239
+ subtitle: `${event.repository.owner}/${event.repository.name} · ${event.commits.length} commit${event.commits.length === 1 ? "" : "s"} on ${event.branch || "branch"}`
240
+ };
241
+ }
242
+ return {
243
+ title: `${event.repository.owner}/${event.repository.name}`,
244
+ subtitle: `${event.eventType} by ${event.sender.login}`
245
+ };
246
+ }
247
+ function formatWorkOSDisplay(event) {
248
+ if ("user" in event && event.user) {
249
+ return {
250
+ title: event.user.email,
251
+ subtitle: humanizeWorkOSEventType(event.eventType)
252
+ };
253
+ }
254
+ if ("organization" in event && event.organization) {
255
+ return {
256
+ title: event.organization.name,
257
+ subtitle: humanizeWorkOSEventType(event.eventType)
258
+ };
259
+ }
260
+ if ("invitation" in event && event.invitation) {
261
+ return {
262
+ title: event.invitation.email,
263
+ subtitle: humanizeWorkOSEventType(event.eventType)
264
+ };
265
+ }
266
+ if ("membership" in event && event.membership) {
267
+ return {
268
+ title: event.membership.role.slug,
269
+ subtitle: humanizeWorkOSEventType(event.eventType)
270
+ };
271
+ }
272
+ return {
273
+ title: "WorkOS event",
274
+ subtitle: humanizeWorkOSEventType(event.eventType)
275
+ };
276
+ }
277
+ function humanizeWorkOSEventType(eventType) {
278
+ return eventType.replaceAll(".", " ");
279
+ }
280
+ function formatWebhookDisplay(event) {
281
+ const bodyPreview = summarizeUnknown(event.body);
282
+ return {
283
+ title: bodyPreview || "Webhook trigger",
284
+ subtitle: event.method
285
+ };
286
+ }
287
+ function formatCronDisplay(event) {
288
+ return {
289
+ title: event.isManualTrigger ? "Manual trigger" : "Scheduled event",
290
+ subtitle: event.manualContext ? truncateForDisplay(event.manualContext, 80) : event.inputId
291
+ };
292
+ }
293
+ function formatWebMonitorDisplay(event) {
294
+ const sourceLabel = firstHost(event.sourceUrls);
295
+ const outputPreview = typeof event.payload === "string" ? event.payload : typeof event.rawPayload === "string" ? event.rawPayload : "";
296
+ return {
297
+ title: sourceLabel ? `Change detected on ${sourceLabel}` : "Web monitor match",
298
+ subtitle: truncateForDisplay(outputPreview || event.query, 100)
299
+ };
300
+ }
301
+ function firstHost(urls) {
302
+ const first = urls[0];
303
+ if (!first)
304
+ return null;
305
+ try {
306
+ return new URL(first).host;
307
+ }
308
+ catch {
309
+ return first;
310
+ }
311
+ }
312
+ function summarizeUnknown(value) {
313
+ if (typeof value === "string") {
314
+ return truncateForDisplay(value.trim() || "Webhook trigger", 80);
315
+ }
316
+ if (value && typeof value === "object") {
317
+ const record = value;
318
+ const preferred = [record.title, record.subject, record.name, record.action, record.type, record.event].find(v => typeof v === "string" && v.trim().length > 0);
319
+ if (typeof preferred === "string") {
320
+ return truncateForDisplay(preferred, 80);
321
+ }
322
+ }
323
+ return "Webhook trigger";
324
+ }
177
325
  function formatGmailTrigger(event) {
178
326
  const attachmentInfo = event.attachments?.map(attachment => `- ${attachment.filename} ${attachment.isInline ? "Inline" : "Attachment"} (${attachment.mimeType})`).join("\n") || "No attachments";
179
327
  return `
@@ -2820,6 +2820,7 @@ export declare function createManualTrigger(params?: {
2820
2820
  }): Trigger;
2821
2821
  export declare function formatTriggerForAgent(event: Trigger): string;
2822
2822
  export declare function debugTrigger(event: Trigger): string;
2823
+ export declare function displayTrigger(event: Trigger): SerializedEventDisplay;
2823
2824
  export declare const TriggerArraySchema: z.ZodArray<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
2824
2825
  integrationType: z.ZodLiteral<IntegrationType.SLACK>;
2825
2826
  channelId: z.ZodString;
@@ -3496,6 +3497,11 @@ export declare const TriggerArraySchema: z.ZodArray<z.ZodUnion<readonly [z.ZodDi
3496
3497
  integrationType: z.ZodEnum<typeof IntegrationType>;
3497
3498
  eventType: z.ZodLiteral<"manual_sample">;
3498
3499
  }, z.core.$strip>]>>;
3500
+ export declare const serializedEventDisplaySchema: z.ZodObject<{
3501
+ title: z.ZodString;
3502
+ subtitle: z.ZodString;
3503
+ }, z.core.$strip>;
3504
+ export type SerializedEventDisplay = z.infer<typeof serializedEventDisplaySchema>;
3499
3505
  export declare const serializedEventSchema: z.ZodObject<{
3500
3506
  integrationType: z.ZodEnum<typeof IntegrationType>;
3501
3507
  eventType: z.ZodUnion<readonly [z.ZodEnum<{
@@ -3529,6 +3535,10 @@ export declare const serializedEventSchema: z.ZodObject<{
3529
3535
  }>, z.ZodLiteral<"webhook">, z.ZodLiteral<"cron">, z.ZodLiteral<"webmonitor">, z.ZodLiteral<"manual_sample">]>;
3530
3536
  formattedContent: z.ZodString;
3531
3537
  debugLog: z.ZodString;
3538
+ display: z.ZodOptional<z.ZodObject<{
3539
+ title: z.ZodString;
3540
+ subtitle: z.ZodString;
3541
+ }, z.core.$strip>>;
3532
3542
  data: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
3533
3543
  integrationType: z.ZodLiteral<IntegrationType.SLACK>;
3534
3544
  channelId: z.ZodString;
package/dist/Triggers.js CHANGED
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { GitHubEventType, WorkOSEventType, frequencyUnitSchema, gitHubEventTypeSchema, gmailEventTypeSchema, linearEventTypeSchema, slackEventTypeSchema, workOSEventTypeSchema } from "./Configs.js";
3
3
  import { IntegrationType, integrationTypeEnum } from "./Integrations.js";
4
4
  import { SlackChannelType } from "./SlackTypes.js";
5
- import { debugTrigger as debugTriggerWithPresenter, formatTriggerForAgent as formatTriggerForAgentWithPresenter } from "./TriggerPresenters.js";
5
+ import { debugTrigger as debugTriggerWithPresenter, displayTrigger as displayTriggerWithPresenter, formatTriggerForAgent as formatTriggerForAgentWithPresenter } from "./TriggerPresenters.js";
6
6
  const providerTriggerTypeSchema = z.union([slackEventTypeSchema, gitHubEventTypeSchema, linearEventTypeSchema, gmailEventTypeSchema, workOSEventTypeSchema]);
7
7
  const TriggerHeaderSchema = z.object({
8
8
  integrationType: integrationTypeEnum,
@@ -474,11 +474,19 @@ export function formatTriggerForAgent(event) {
474
474
  export function debugTrigger(event) {
475
475
  return debugTriggerWithPresenter(event);
476
476
  }
477
+ export function displayTrigger(event) {
478
+ return displayTriggerWithPresenter(event);
479
+ }
477
480
  export const TriggerArraySchema = z.array(TriggerSchema);
481
+ export const serializedEventDisplaySchema = z.object({
482
+ title: z.string(),
483
+ subtitle: z.string()
484
+ });
478
485
  export const serializedEventSchema = z.object({
479
486
  integrationType: integrationTypeEnum,
480
487
  eventType: TriggerTypeSchema,
481
488
  formattedContent: z.string(),
482
489
  debugLog: z.string(),
490
+ display: serializedEventDisplaySchema.optional(),
483
491
  data: TriggerSchema
484
492
  });
package/dist/types.d.ts CHANGED
@@ -3442,6 +3442,12 @@ export declare const formFieldDefinitionSchema: z.ZodObject<{
3442
3442
  hint: z.ZodOptional<z.ZodString>;
3443
3443
  }, z.core.$strip>;
3444
3444
  export type FormFieldDefinition = z.infer<typeof formFieldDefinitionSchema>;
3445
+ export declare const formIntegrationSetupSchema: z.ZodObject<{
3446
+ title: z.ZodString;
3447
+ url: z.ZodString;
3448
+ instructions: z.ZodArray<z.ZodString>;
3449
+ }, z.core.$strip>;
3450
+ export type FormIntegrationSetup = z.infer<typeof formIntegrationSetupSchema>;
3445
3451
  export declare const configurationFieldTypeSchema: z.ZodEnum<{
3446
3452
  radio: "radio";
3447
3453
  select: "select";
@@ -3497,6 +3503,11 @@ export declare const integrationFieldsResponseSchema: z.ZodObject<{
3497
3503
  required: z.ZodOptional<z.ZodBoolean>;
3498
3504
  hint: z.ZodOptional<z.ZodString>;
3499
3505
  }, z.core.$strip>>]>;
3506
+ setup: z.ZodOptional<z.ZodObject<{
3507
+ title: z.ZodString;
3508
+ url: z.ZodString;
3509
+ instructions: z.ZodArray<z.ZodString>;
3510
+ }, z.core.$strip>>;
3500
3511
  }, z.core.$strip>;
3501
3512
  export type IntegrationFieldsResponse = z.infer<typeof integrationFieldsResponseSchema>;
3502
3513
  export declare const statsIntervalSchema: z.ZodEnum<{
@@ -5793,6 +5804,10 @@ export declare const sdkRunTriggerEventResponseSchema: z.ZodObject<{
5793
5804
  }>, z.ZodLiteral<"webhook">, z.ZodLiteral<"cron">, z.ZodLiteral<"webmonitor">, z.ZodLiteral<"manual_sample">]>;
5794
5805
  formattedContent: z.ZodString;
5795
5806
  debugLog: z.ZodString;
5807
+ display: z.ZodOptional<z.ZodObject<{
5808
+ title: z.ZodString;
5809
+ subtitle: z.ZodString;
5810
+ }, z.core.$strip>>;
5796
5811
  data: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
5797
5812
  integrationType: z.ZodLiteral<import("./Integrations.js").IntegrationType.SLACK>;
5798
5813
  channelId: z.ZodString;
@@ -7390,6 +7405,10 @@ export declare const webhookJobTriggerRequestSchema: z.ZodObject<{
7390
7405
  }>, z.ZodLiteral<"webhook">, z.ZodLiteral<"cron">, z.ZodLiteral<"webmonitor">, z.ZodLiteral<"manual_sample">]>;
7391
7406
  formattedContent: z.ZodString;
7392
7407
  debugLog: z.ZodString;
7408
+ display: z.ZodOptional<z.ZodObject<{
7409
+ title: z.ZodString;
7410
+ subtitle: z.ZodString;
7411
+ }, z.core.$strip>>;
7393
7412
  data: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
7394
7413
  integrationType: z.ZodLiteral<import("./Integrations.js").IntegrationType.SLACK>;
7395
7414
  channelId: z.ZodString;
package/dist/types.js CHANGED
@@ -337,6 +337,11 @@ export const formFieldDefinitionSchema = z.object({
337
337
  required: z.boolean().optional(),
338
338
  hint: z.string().optional()
339
339
  });
340
+ export const formIntegrationSetupSchema = z.object({
341
+ title: z.string(),
342
+ url: z.string(),
343
+ instructions: z.array(z.string())
344
+ });
340
345
  export const configurationFieldTypeSchema = z.enum(["radio", "select"]);
341
346
  export const configurationOptionSchema = z.object({
342
347
  label: z.string(),
@@ -352,7 +357,8 @@ export const configurationFieldDefinitionSchema = z.object({
352
357
  });
353
358
  export const integrationFieldsResponseSchema = z.object({
354
359
  installationType: z.enum(["form", "oauth"]),
355
- fields: z.union([z.array(formFieldDefinitionSchema), z.array(configurationFieldDefinitionSchema)])
360
+ fields: z.union([z.array(formFieldDefinitionSchema), z.array(configurationFieldDefinitionSchema)]),
361
+ setup: formIntegrationSetupSchema.optional()
356
362
  });
357
363
  export const statsIntervalSchema = z.enum(["1h", "24h", "7d", "1mo", "3mo", "1y"]);
358
364
  export const dailyEventCountSchema = z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terse-types",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "description": "Shared Terse TypeScript types, enums, constants, and helpers.",
6
6
  "main": "./dist/index.js",