terse-types 0.0.77 → 0.1.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/Events.d.ts +112 -0
- package/dist/Events.js +32 -0
- package/dist/Integrations.d.ts +6 -0
- package/dist/Integrations.js +9 -0
- package/dist/Tools.js +4 -2
- package/dist/TriggerDefinition.d.ts +34 -0
- package/dist/TriggerDefinition.js +6 -0
- package/dist/TriggerPresenters.d.ts +38 -8
- package/dist/TriggerPresenters.js +233 -294
- package/dist/TriggerProjections.d.ts +18 -0
- package/dist/TriggerProjections.js +167 -0
- package/dist/Triggers.d.ts +2111 -30
- package/dist/Triggers.js +633 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +66 -66
- package/package.json +1 -1
- package/dist/AttioRecordFlatten.d.ts +0 -19
- package/dist/AttioRecordFlatten.js +0 -71
- package/dist/OrganizationMetadata.d.ts +0 -6
- package/dist/OrganizationMetadata.js +0 -10
- package/dist/json-schema/terse-types.schema.json +0 -15994
|
@@ -1,129 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
manual_sample: {
|
|
4
|
-
formatForAgent: (event) => `Manual sample event for ${event.integrationType}.`,
|
|
5
|
-
debug: (event) => `${event.integrationType} ${event.eventType}`,
|
|
6
|
-
display: (event) => ({
|
|
7
|
-
title: `Manual ${event.integrationType} sample`,
|
|
8
|
-
subtitle: event.eventType
|
|
9
|
-
})
|
|
10
|
-
},
|
|
11
|
-
[IntegrationType.GITHUB]: {
|
|
12
|
-
formatForAgent: formatGithubTrigger,
|
|
13
|
-
debug: (event) => `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`,
|
|
14
|
-
display: formatGithubDisplay
|
|
15
|
-
},
|
|
16
|
-
[IntegrationType.SLACK]: {
|
|
17
|
-
formatForAgent: formatSlackTrigger,
|
|
18
|
-
debug: (event) => {
|
|
19
|
-
const isDM = event.channelType === "im";
|
|
20
|
-
return `Slack Event: ${event.eventType} - ${isDM ? "DM" : event.channelName || event.channelId} - ${event.userName || event.userId}`;
|
|
21
|
-
},
|
|
22
|
-
display: formatSlackDisplay
|
|
23
|
-
},
|
|
24
|
-
[IntegrationType.GMAIL]: {
|
|
25
|
-
formatForAgent: formatGmailTrigger,
|
|
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
|
-
})
|
|
31
|
-
},
|
|
32
|
-
[IntegrationType.LINEAR]: {
|
|
33
|
-
formatForAgent: formatLinearTrigger,
|
|
34
|
-
debug: (event) => {
|
|
35
|
-
if (event.type === "Issue") {
|
|
36
|
-
return `Linear ${event.type} Event: ${event.data.identifier} - ${event.data.title} (${event.action})`;
|
|
37
|
-
}
|
|
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
|
-
};
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
[IntegrationType.WORKOS]: {
|
|
54
|
-
formatForAgent: formatWorkOSTrigger,
|
|
55
|
-
debug: (event) => `WorkOS ${event.eventType}`,
|
|
56
|
-
display: formatWorkOSDisplay
|
|
57
|
-
},
|
|
58
|
-
[IntegrationType.HEY_REACH]: {
|
|
59
|
-
formatForAgent: formatHeyReachTrigger,
|
|
60
|
-
debug: (event) => `HeyReach ${event.eventType}${event.lead?.id != null ? ` lead=${event.lead.id}` : ""}`,
|
|
61
|
-
display: formatHeyReachDisplay
|
|
62
|
-
},
|
|
63
|
-
[IntegrationType.ATTIO]: {
|
|
64
|
-
formatForAgent: formatAttioTrigger,
|
|
65
|
-
debug: (event) => `Attio ${event.eventType}${event.objectSlug ? ` object=${event.objectSlug}` : ""}`,
|
|
66
|
-
display: formatAttioDisplay
|
|
67
|
-
},
|
|
68
|
-
[IntegrationType.WEBHOOK]: {
|
|
69
|
-
formatForAgent: formatWebhookTrigger,
|
|
70
|
-
debug: (event) => `Webhook Trigger (${event.method})`,
|
|
71
|
-
display: formatWebhookDisplay
|
|
72
|
-
},
|
|
73
|
-
[IntegrationType.CRON_JOB]: {
|
|
74
|
-
formatForAgent: formatCronTrigger,
|
|
75
|
-
debug: (event) => (event.isManualTrigger ? "Manual Trigger" : "Scheduled Event"),
|
|
76
|
-
display: formatCronDisplay
|
|
77
|
-
},
|
|
78
|
-
[IntegrationType.WEBMONITOR]: {
|
|
79
|
-
formatForAgent: formatWebMonitorTrigger,
|
|
80
|
-
debug: (event) => `${event.query.slice(0, 80)}${event.query.length > 80 ? "…" : ""}`,
|
|
81
|
-
display: formatWebMonitorDisplay
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
function dispatchPresenter(event, method) {
|
|
85
|
-
switch (event.integrationType) {
|
|
86
|
-
case IntegrationType.GITHUB:
|
|
87
|
-
return TriggerPresenters[IntegrationType.GITHUB][method](event);
|
|
88
|
-
case IntegrationType.SLACK:
|
|
89
|
-
return TriggerPresenters[IntegrationType.SLACK][method](event);
|
|
90
|
-
case IntegrationType.GMAIL:
|
|
91
|
-
return TriggerPresenters[IntegrationType.GMAIL][method](event);
|
|
92
|
-
case IntegrationType.LINEAR:
|
|
93
|
-
return TriggerPresenters[IntegrationType.LINEAR][method](event);
|
|
94
|
-
case IntegrationType.WORKOS:
|
|
95
|
-
return TriggerPresenters[IntegrationType.WORKOS][method](event);
|
|
96
|
-
case IntegrationType.HEY_REACH:
|
|
97
|
-
return TriggerPresenters[IntegrationType.HEY_REACH][method](event);
|
|
98
|
-
case IntegrationType.ATTIO:
|
|
99
|
-
return TriggerPresenters[IntegrationType.ATTIO][method](event);
|
|
100
|
-
case IntegrationType.WEBHOOK:
|
|
101
|
-
return TriggerPresenters[IntegrationType.WEBHOOK][method](event);
|
|
102
|
-
case IntegrationType.CRON_JOB:
|
|
103
|
-
return TriggerPresenters[IntegrationType.CRON_JOB][method](event);
|
|
104
|
-
case IntegrationType.WEBMONITOR:
|
|
105
|
-
return TriggerPresenters[IntegrationType.WEBMONITOR][method](event);
|
|
106
|
-
}
|
|
1
|
+
export function formatManualSampleTrigger(event) {
|
|
2
|
+
return `Manual sample event for ${event.integrationType}.`;
|
|
107
3
|
}
|
|
108
|
-
export function
|
|
109
|
-
|
|
110
|
-
return TriggerPresenters.manual_sample.formatForAgent(event);
|
|
111
|
-
}
|
|
112
|
-
return dispatchPresenter(event, "formatForAgent");
|
|
4
|
+
export function debugManualSampleTrigger(event) {
|
|
5
|
+
return `${event.integrationType} ${event.eventType}`;
|
|
113
6
|
}
|
|
114
|
-
export function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
export function displayTrigger(event) {
|
|
121
|
-
if (event.eventType === "manual_sample") {
|
|
122
|
-
return TriggerPresenters.manual_sample.display(event);
|
|
123
|
-
}
|
|
124
|
-
return dispatchPresenter(event, "display");
|
|
7
|
+
export function displayManualSampleTrigger(event) {
|
|
8
|
+
return {
|
|
9
|
+
title: `Manual ${event.integrationType} sample`,
|
|
10
|
+
subtitle: event.eventType
|
|
11
|
+
};
|
|
125
12
|
}
|
|
126
|
-
function formatGithubTrigger(event) {
|
|
13
|
+
export function formatGithubTrigger(event) {
|
|
127
14
|
const indentMultiline = (text) => text
|
|
128
15
|
.split("\n")
|
|
129
16
|
.map(line => ` ${line}`)
|
|
@@ -210,7 +97,37 @@ function formatGithubTrigger(event) {
|
|
|
210
97
|
...(commitsInfo ? [`\n${commitsInfo}`] : [])
|
|
211
98
|
].join("\n\n");
|
|
212
99
|
}
|
|
213
|
-
function
|
|
100
|
+
export function debugGithubTrigger(event) {
|
|
101
|
+
return `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`;
|
|
102
|
+
}
|
|
103
|
+
export function formatGithubDisplay(event) {
|
|
104
|
+
if (event.eventType === "issue_comment.created") {
|
|
105
|
+
const kind = event.issue.isPullRequest ? "PR" : "Issue";
|
|
106
|
+
return {
|
|
107
|
+
title: `Comment on #${event.issue.number} ${truncateForDisplay(event.issue.title, 80)}`,
|
|
108
|
+
subtitle: `${event.repository.owner}/${event.repository.name} · ${kind} comment by ${event.sender.login}`
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (event.pullRequest) {
|
|
112
|
+
return {
|
|
113
|
+
title: `#${event.pullRequest.number} ${truncateForDisplay(event.pullRequest.title, 80)}`,
|
|
114
|
+
subtitle: `${event.repository.owner}/${event.repository.name} · ${event.eventType} by ${event.sender.login}`
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (event.commits.length > 0) {
|
|
118
|
+
const latestCommit = event.commits[event.commits.length - 1];
|
|
119
|
+
const commitMessage = latestCommit.message || latestCommit.name || latestCommit.sha.slice(0, 7);
|
|
120
|
+
return {
|
|
121
|
+
title: truncateForDisplay(commitMessage, 80),
|
|
122
|
+
subtitle: `${event.repository.owner}/${event.repository.name} · ${event.commits.length} commit${event.commits.length === 1 ? "" : "s"} on ${event.branch || "branch"}`
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
title: `${event.repository.owner}/${event.repository.name}`,
|
|
127
|
+
subtitle: `${event.eventType} by ${event.sender.login}`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export function formatSlackTrigger(event) {
|
|
214
131
|
const blockContent = JSON.stringify(event.blocks);
|
|
215
132
|
const attachmentContent = JSON.stringify(event.attachments);
|
|
216
133
|
const messageText = event.text || "(no plain text)";
|
|
@@ -243,7 +160,11 @@ function formatSlackTrigger(event) {
|
|
|
243
160
|
: ""}
|
|
244
161
|
`;
|
|
245
162
|
}
|
|
246
|
-
function
|
|
163
|
+
export function debugSlackTrigger(event) {
|
|
164
|
+
const isDM = event.channelType === "im";
|
|
165
|
+
return `Slack Event: ${event.eventType} - ${isDM ? "DM" : event.channelName || event.channelId} - ${event.userName || event.userId}`;
|
|
166
|
+
}
|
|
167
|
+
export function formatSlackDisplay(event) {
|
|
247
168
|
const channelLabel = event.channelType === "im" ? "DM" : event.channelName || event.channelId;
|
|
248
169
|
const actorLabel = event.userName || event.userId;
|
|
249
170
|
if (event.eventType === "reaction_added") {
|
|
@@ -258,115 +179,7 @@ function formatSlackDisplay(event) {
|
|
|
258
179
|
subtitle: `${channelLabel} by ${actorLabel}`
|
|
259
180
|
};
|
|
260
181
|
}
|
|
261
|
-
function
|
|
262
|
-
return value.length > maxLength ? `${value.slice(0, maxLength - 1)}…` : value;
|
|
263
|
-
}
|
|
264
|
-
function formatGithubDisplay(event) {
|
|
265
|
-
if (event.eventType === "issue_comment.created") {
|
|
266
|
-
const kind = event.issue.isPullRequest ? "PR" : "Issue";
|
|
267
|
-
return {
|
|
268
|
-
title: `Comment on #${event.issue.number} ${truncateForDisplay(event.issue.title, 80)}`,
|
|
269
|
-
subtitle: `${event.repository.owner}/${event.repository.name} · ${kind} comment by ${event.sender.login}`
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
if (event.pullRequest) {
|
|
273
|
-
return {
|
|
274
|
-
title: `#${event.pullRequest.number} ${truncateForDisplay(event.pullRequest.title, 80)}`,
|
|
275
|
-
subtitle: `${event.repository.owner}/${event.repository.name} · ${event.eventType} by ${event.sender.login}`
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
if (event.commits.length > 0) {
|
|
279
|
-
const latestCommit = event.commits[event.commits.length - 1];
|
|
280
|
-
const commitMessage = latestCommit.message || latestCommit.name || latestCommit.sha.slice(0, 7);
|
|
281
|
-
return {
|
|
282
|
-
title: truncateForDisplay(commitMessage, 80),
|
|
283
|
-
subtitle: `${event.repository.owner}/${event.repository.name} · ${event.commits.length} commit${event.commits.length === 1 ? "" : "s"} on ${event.branch || "branch"}`
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
title: `${event.repository.owner}/${event.repository.name}`,
|
|
288
|
-
subtitle: `${event.eventType} by ${event.sender.login}`
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function formatWorkOSDisplay(event) {
|
|
292
|
-
if ("user" in event && event.user) {
|
|
293
|
-
return {
|
|
294
|
-
title: event.user.email,
|
|
295
|
-
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
if ("organization" in event && event.organization) {
|
|
299
|
-
return {
|
|
300
|
-
title: event.organization.name,
|
|
301
|
-
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
if ("invitation" in event && event.invitation) {
|
|
305
|
-
return {
|
|
306
|
-
title: event.invitation.email,
|
|
307
|
-
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
if ("membership" in event && event.membership) {
|
|
311
|
-
return {
|
|
312
|
-
title: event.membership.role.slug,
|
|
313
|
-
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
return {
|
|
317
|
-
title: "WorkOS event",
|
|
318
|
-
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
function humanizeWorkOSEventType(eventType) {
|
|
322
|
-
return eventType.replaceAll(".", " ");
|
|
323
|
-
}
|
|
324
|
-
function formatWebhookDisplay(event) {
|
|
325
|
-
const bodyPreview = summarizeUnknown(event.body);
|
|
326
|
-
return {
|
|
327
|
-
title: bodyPreview || "Webhook trigger",
|
|
328
|
-
subtitle: event.method
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
function formatCronDisplay(event) {
|
|
332
|
-
return {
|
|
333
|
-
title: event.isManualTrigger ? "Manual trigger" : "Scheduled event",
|
|
334
|
-
subtitle: event.manualContext ? truncateForDisplay(event.manualContext, 80) : event.inputId
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
function formatWebMonitorDisplay(event) {
|
|
338
|
-
const sourceLabel = firstHost(event.sourceUrls);
|
|
339
|
-
const outputPreview = typeof event.payload === "string" ? event.payload : typeof event.rawPayload === "string" ? event.rawPayload : "";
|
|
340
|
-
return {
|
|
341
|
-
title: sourceLabel ? `Change detected on ${sourceLabel}` : "Web monitor match",
|
|
342
|
-
subtitle: truncateForDisplay(outputPreview || event.query, 100)
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
function firstHost(urls) {
|
|
346
|
-
const first = urls[0];
|
|
347
|
-
if (!first)
|
|
348
|
-
return null;
|
|
349
|
-
try {
|
|
350
|
-
return new URL(first).host;
|
|
351
|
-
}
|
|
352
|
-
catch {
|
|
353
|
-
return first;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
function summarizeUnknown(value) {
|
|
357
|
-
if (typeof value === "string") {
|
|
358
|
-
return truncateForDisplay(value.trim() || "Webhook trigger", 80);
|
|
359
|
-
}
|
|
360
|
-
if (value && typeof value === "object") {
|
|
361
|
-
const record = value;
|
|
362
|
-
const preferred = [record.title, record.subject, record.name, record.action, record.type, record.event].find(v => typeof v === "string" && v.trim().length > 0);
|
|
363
|
-
if (typeof preferred === "string") {
|
|
364
|
-
return truncateForDisplay(preferred, 80);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return "Webhook trigger";
|
|
368
|
-
}
|
|
369
|
-
function formatGmailTrigger(event) {
|
|
182
|
+
export function formatGmailTrigger(event) {
|
|
370
183
|
const attachmentInfo = event.attachments?.map(attachment => `- ${attachment.filename} ${attachment.isInline ? "Inline" : "Attachment"} (${attachment.mimeType})`).join("\n") || "No attachments";
|
|
371
184
|
return `
|
|
372
185
|
Incoming Email Event.
|
|
@@ -384,7 +197,16 @@ function formatGmailTrigger(event) {
|
|
|
384
197
|
${attachmentInfo}
|
|
385
198
|
`;
|
|
386
199
|
}
|
|
387
|
-
function
|
|
200
|
+
export function debugGmailTrigger(event) {
|
|
201
|
+
return `Gmail Event: ${event.subject} message ID: ${event.messageId}`;
|
|
202
|
+
}
|
|
203
|
+
export function formatGmailDisplay(event) {
|
|
204
|
+
return {
|
|
205
|
+
title: event.subject || "(no subject)",
|
|
206
|
+
subtitle: `from ${event.from}`
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export function formatLinearTrigger(event) {
|
|
388
210
|
const indentMultiline = (text) => text
|
|
389
211
|
.split("\n")
|
|
390
212
|
.map(line => ` ${line}`)
|
|
@@ -425,7 +247,25 @@ function formatLinearTrigger(event) {
|
|
|
425
247
|
}
|
|
426
248
|
return sections.join("\n\n");
|
|
427
249
|
}
|
|
428
|
-
function
|
|
250
|
+
export function debugLinearTrigger(event) {
|
|
251
|
+
if (event.type === "Issue") {
|
|
252
|
+
return `Linear ${event.type} Event: ${event.data.identifier} - ${event.data.title} (${event.action})`;
|
|
253
|
+
}
|
|
254
|
+
return `Linear ${event.type} Event: Comment on issue ${event.data.issueId || "Unknown"} (${event.action})`;
|
|
255
|
+
}
|
|
256
|
+
export function formatLinearDisplay(event) {
|
|
257
|
+
if (event.type === "Issue") {
|
|
258
|
+
return {
|
|
259
|
+
title: `${event.data.identifier} ${event.data.title}`,
|
|
260
|
+
subtitle: `${event.data.team?.name || "Linear"} · ${event.action} issue`
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
title: `Comment on ${event.data.issueId || "Unknown issue"}`,
|
|
265
|
+
subtitle: `${event.actor.name} · ${event.action} comment`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
export function formatWorkOSTrigger(event) {
|
|
429
269
|
const parts = [`WorkOS Event: ${event.eventType}`];
|
|
430
270
|
if ("user" in event && event.user) {
|
|
431
271
|
parts.push(`User Email: ${event.user.email}`);
|
|
@@ -437,35 +277,43 @@ function formatWorkOSTrigger(event) {
|
|
|
437
277
|
parts.push(`\nFull Event Data:\n${JSON.stringify(event, null, 2)}`);
|
|
438
278
|
return parts.join("\n");
|
|
439
279
|
}
|
|
440
|
-
function
|
|
441
|
-
return `
|
|
280
|
+
export function debugWorkOSTrigger(event) {
|
|
281
|
+
return `WorkOS ${event.eventType}`;
|
|
442
282
|
}
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
`Output Type: ${event.outputType}`
|
|
450
|
-
];
|
|
451
|
-
if (Object.keys(event.metadata).length > 0) {
|
|
452
|
-
lines.push(`Metadata:\n${JSON.stringify(event.metadata, null, 2)}`);
|
|
283
|
+
export function formatWorkOSDisplay(event) {
|
|
284
|
+
if ("user" in event && event.user) {
|
|
285
|
+
return {
|
|
286
|
+
title: event.user.email,
|
|
287
|
+
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
288
|
+
};
|
|
453
289
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
290
|
+
if ("organization" in event && event.organization) {
|
|
291
|
+
return {
|
|
292
|
+
title: event.organization.name,
|
|
293
|
+
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
294
|
+
};
|
|
457
295
|
}
|
|
458
|
-
|
|
296
|
+
if ("invitation" in event && event.invitation) {
|
|
297
|
+
return {
|
|
298
|
+
title: event.invitation.email,
|
|
299
|
+
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if ("membership" in event && event.membership) {
|
|
303
|
+
return {
|
|
304
|
+
title: event.membership.role.slug,
|
|
305
|
+
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return {
|
|
309
|
+
title: "WorkOS event",
|
|
310
|
+
subtitle: humanizeWorkOSEventType(event.eventType)
|
|
311
|
+
};
|
|
459
312
|
}
|
|
460
|
-
function
|
|
461
|
-
|
|
462
|
-
if (!lead)
|
|
463
|
-
return null;
|
|
464
|
-
const composed = [lead.first_name, lead.last_name].filter(Boolean).join(" ").trim() || lead.full_name?.trim() || "";
|
|
465
|
-
const idStr = lead.id != null ? String(lead.id) : null;
|
|
466
|
-
return composed || idStr;
|
|
313
|
+
function humanizeWorkOSEventType(eventType) {
|
|
314
|
+
return eventType.replaceAll(".", " ");
|
|
467
315
|
}
|
|
468
|
-
function formatHeyReachTrigger(event) {
|
|
316
|
+
export function formatHeyReachTrigger(event) {
|
|
469
317
|
const lines = [`HeyReach Event: ${event.eventType}`, `Event ID: ${event.eventId}`, `Created At: ${event.createdAt}`];
|
|
470
318
|
const leadName = heyReachLeadFullName(event);
|
|
471
319
|
if (leadName)
|
|
@@ -494,6 +342,28 @@ function formatHeyReachTrigger(event) {
|
|
|
494
342
|
lines.push(`\nFull Payload:\n${JSON.stringify(event.rawPayload, null, 2)}`);
|
|
495
343
|
return lines.join("\n");
|
|
496
344
|
}
|
|
345
|
+
export function debugHeyReachTrigger(event) {
|
|
346
|
+
return `HeyReach ${event.eventType}${event.lead?.id != null ? ` lead=${event.lead.id}` : ""}`;
|
|
347
|
+
}
|
|
348
|
+
export function formatHeyReachDisplay(event) {
|
|
349
|
+
const subtitle = humanizeHeyReachEventType(event.eventType);
|
|
350
|
+
const leadName = heyReachLeadFullName(event);
|
|
351
|
+
if (leadName) {
|
|
352
|
+
return { title: leadName, subtitle };
|
|
353
|
+
}
|
|
354
|
+
if (event.campaign?.name) {
|
|
355
|
+
return { title: event.campaign.name, subtitle };
|
|
356
|
+
}
|
|
357
|
+
return { title: "HeyReach event", subtitle };
|
|
358
|
+
}
|
|
359
|
+
function heyReachLeadFullName(event) {
|
|
360
|
+
const lead = event.lead;
|
|
361
|
+
if (!lead)
|
|
362
|
+
return null;
|
|
363
|
+
const composed = [lead.first_name, lead.last_name].filter(Boolean).join(" ").trim() || lead.full_name?.trim() || "";
|
|
364
|
+
const idStr = lead.id != null ? String(lead.id) : null;
|
|
365
|
+
return composed || idStr;
|
|
366
|
+
}
|
|
497
367
|
function humanizeHeyReachEventType(eventType) {
|
|
498
368
|
return eventType
|
|
499
369
|
.split("_")
|
|
@@ -501,6 +371,34 @@ function humanizeHeyReachEventType(eventType) {
|
|
|
501
371
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
502
372
|
.join(" ");
|
|
503
373
|
}
|
|
374
|
+
export function formatAttioTrigger(event) {
|
|
375
|
+
const lines = [`Attio Event: ${event.eventType}`, `Event ID: ${event.eventId}`, `Created At: ${event.createdAt}`, `Workspace ID: ${event.workspaceId}`];
|
|
376
|
+
if (event.objectSlug)
|
|
377
|
+
lines.push(`Object: ${event.objectSlug}`);
|
|
378
|
+
const resource = attioResourceLabel(event);
|
|
379
|
+
if (resource)
|
|
380
|
+
lines.push(`Resource: ${resource}`);
|
|
381
|
+
if (event.actor.type)
|
|
382
|
+
lines.push(`Actor: ${event.actor.type}${event.actor.id ? ` (${event.actor.id})` : ""}`);
|
|
383
|
+
lines.push(`\nFull Event:\n${JSON.stringify(event.rawEvent, null, 2)}`);
|
|
384
|
+
return lines.join("\n");
|
|
385
|
+
}
|
|
386
|
+
export function debugAttioTrigger(event) {
|
|
387
|
+
return `Attio ${event.eventType}${event.objectSlug ? ` object=${event.objectSlug}` : ""}`;
|
|
388
|
+
}
|
|
389
|
+
export function formatAttioDisplay(event) {
|
|
390
|
+
const subtitle = humanizeAttioEventType(event.eventType);
|
|
391
|
+
const resource = attioResourceLabel(event);
|
|
392
|
+
return { title: resource ?? "Attio event", subtitle };
|
|
393
|
+
}
|
|
394
|
+
export function humanizeAttioEventType(eventType) {
|
|
395
|
+
return eventType
|
|
396
|
+
.replace(/[-.]/g, " ")
|
|
397
|
+
.split(" ")
|
|
398
|
+
.filter(Boolean)
|
|
399
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
400
|
+
.join(" ");
|
|
401
|
+
}
|
|
504
402
|
function attioResourceLabel(event) {
|
|
505
403
|
const ids = event.resourceIds;
|
|
506
404
|
if (ids.record_id)
|
|
@@ -523,43 +421,20 @@ function attioResourceLabel(event) {
|
|
|
523
421
|
return `attribute ${ids.attribute_id}`;
|
|
524
422
|
return null;
|
|
525
423
|
}
|
|
526
|
-
export function
|
|
527
|
-
return
|
|
528
|
-
.replace(/[-.]/g, " ")
|
|
529
|
-
.split(" ")
|
|
530
|
-
.filter(Boolean)
|
|
531
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
532
|
-
.join(" ");
|
|
533
|
-
}
|
|
534
|
-
function formatAttioTrigger(event) {
|
|
535
|
-
const lines = [`Attio Event: ${event.eventType}`, `Event ID: ${event.eventId}`, `Created At: ${event.createdAt}`, `Workspace ID: ${event.workspaceId}`];
|
|
536
|
-
if (event.objectSlug)
|
|
537
|
-
lines.push(`Object: ${event.objectSlug}`);
|
|
538
|
-
const resource = attioResourceLabel(event);
|
|
539
|
-
if (resource)
|
|
540
|
-
lines.push(`Resource: ${resource}`);
|
|
541
|
-
if (event.actor.type)
|
|
542
|
-
lines.push(`Actor: ${event.actor.type}${event.actor.id ? ` (${event.actor.id})` : ""}`);
|
|
543
|
-
lines.push(`\nFull Event:\n${JSON.stringify(event.rawEvent, null, 2)}`);
|
|
544
|
-
return lines.join("\n");
|
|
424
|
+
export function formatWebhookTrigger(event) {
|
|
425
|
+
return `Webhook request received.\n\nMethod: ${event.method}\n\nPayload:\n${JSON.stringify(event.body, null, 2)}`;
|
|
545
426
|
}
|
|
546
|
-
function
|
|
547
|
-
|
|
548
|
-
const resource = attioResourceLabel(event);
|
|
549
|
-
return { title: resource ?? "Attio event", subtitle };
|
|
427
|
+
export function debugWebhookTrigger(event) {
|
|
428
|
+
return `Webhook Trigger (${event.method})`;
|
|
550
429
|
}
|
|
551
|
-
function
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
if (event.campaign?.name) {
|
|
558
|
-
return { title: event.campaign.name, subtitle };
|
|
559
|
-
}
|
|
560
|
-
return { title: "HeyReach event", subtitle };
|
|
430
|
+
export function formatWebhookDisplay(event) {
|
|
431
|
+
const bodyPreview = summarizeUnknown(event.body);
|
|
432
|
+
return {
|
|
433
|
+
title: bodyPreview || "Webhook trigger",
|
|
434
|
+
subtitle: event.method
|
|
435
|
+
};
|
|
561
436
|
}
|
|
562
|
-
function formatCronTrigger(event) {
|
|
437
|
+
export function formatCronTrigger(event) {
|
|
563
438
|
if (event.isManualTrigger) {
|
|
564
439
|
let message = `This is a manually triggered event for the channel input ${event.inputId}.`;
|
|
565
440
|
if (event.manualContext) {
|
|
@@ -569,3 +444,67 @@ function formatCronTrigger(event) {
|
|
|
569
444
|
}
|
|
570
445
|
return `This is a scheduled event for the channel input ${event.inputId}. The channel input is configured to run at the following cron expression.`;
|
|
571
446
|
}
|
|
447
|
+
export function debugCronTrigger(event) {
|
|
448
|
+
return event.isManualTrigger ? "Manual Trigger" : "Scheduled Event";
|
|
449
|
+
}
|
|
450
|
+
export function formatCronDisplay(event) {
|
|
451
|
+
return {
|
|
452
|
+
title: event.isManualTrigger ? "Manual trigger" : "Scheduled event",
|
|
453
|
+
subtitle: event.manualContext ? truncateForDisplay(event.manualContext, 80) : event.inputId
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
export function formatWebMonitorTrigger(event) {
|
|
457
|
+
const lines = [
|
|
458
|
+
`Web event for monitored query (frequency: ${event.frequency.number}${event.frequency.unit}).`,
|
|
459
|
+
`Query: ${event.query}`,
|
|
460
|
+
`Monitor ID: ${event.monitorId}`,
|
|
461
|
+
`Event Group ID: ${event.eventGroupId}`,
|
|
462
|
+
`Output Type: ${event.outputType}`
|
|
463
|
+
];
|
|
464
|
+
if (Object.keys(event.metadata).length > 0) {
|
|
465
|
+
lines.push(`Metadata:\n${JSON.stringify(event.metadata, null, 2)}`);
|
|
466
|
+
}
|
|
467
|
+
lines.push(`Payload:\n${JSON.stringify(event.payload, null, 2)}`);
|
|
468
|
+
if (event.rawPayload) {
|
|
469
|
+
lines.push(`Raw Payload:\n${event.rawPayload}`);
|
|
470
|
+
}
|
|
471
|
+
return lines.join("\n\n");
|
|
472
|
+
}
|
|
473
|
+
export function debugWebMonitorTrigger(event) {
|
|
474
|
+
return `${event.query.slice(0, 80)}${event.query.length > 80 ? "…" : ""}`;
|
|
475
|
+
}
|
|
476
|
+
export function formatWebMonitorDisplay(event) {
|
|
477
|
+
const sourceLabel = firstHost(event.sourceUrls);
|
|
478
|
+
const outputPreview = typeof event.payload === "string" ? event.payload : typeof event.rawPayload === "string" ? event.rawPayload : "";
|
|
479
|
+
return {
|
|
480
|
+
title: sourceLabel ? `Change detected on ${sourceLabel}` : "Web monitor match",
|
|
481
|
+
subtitle: truncateForDisplay(outputPreview || event.query, 100)
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function firstHost(urls) {
|
|
485
|
+
const first = urls[0];
|
|
486
|
+
if (!first)
|
|
487
|
+
return null;
|
|
488
|
+
try {
|
|
489
|
+
return new URL(first).host;
|
|
490
|
+
}
|
|
491
|
+
catch {
|
|
492
|
+
return first;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function summarizeUnknown(value) {
|
|
496
|
+
if (typeof value === "string") {
|
|
497
|
+
return truncateForDisplay(value.trim() || "Webhook trigger", 80);
|
|
498
|
+
}
|
|
499
|
+
if (value && typeof value === "object") {
|
|
500
|
+
const record = value;
|
|
501
|
+
const preferred = [record.title, record.subject, record.name, record.action, record.type, record.event].find(v => typeof v === "string" && v.trim().length > 0);
|
|
502
|
+
if (typeof preferred === "string") {
|
|
503
|
+
return truncateForDisplay(preferred, 80);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return "Webhook trigger";
|
|
507
|
+
}
|
|
508
|
+
function truncateForDisplay(value, maxLength) {
|
|
509
|
+
return value.length > maxLength ? `${value.slice(0, maxLength - 1)}…` : value;
|
|
510
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as z from "zod";
|
|
2
|
+
export declare const triggerPayloadProjections: Readonly<Record<string, TriggerPayloadProjection>>;
|
|
3
|
+
export declare function isProjectedTriggerName(name: string): boolean;
|
|
4
|
+
export type TriggerPayloadSchemaProjection = {
|
|
5
|
+
kind: "schema";
|
|
6
|
+
schema: z.ZodType;
|
|
7
|
+
/** Printed verbatim after the payload interface name, e.g. "<TBody = unknown>". */
|
|
8
|
+
typeParams?: string;
|
|
9
|
+
/** Dot-path within the payload -> TypeScript type expression printed instead of the schema field. */
|
|
10
|
+
fieldOverrides?: Record<string, string>;
|
|
11
|
+
/** Extra terse-sdk type imports the overrides reference. */
|
|
12
|
+
sdkImports?: string[];
|
|
13
|
+
};
|
|
14
|
+
export type TriggerPayloadUnionProjection = {
|
|
15
|
+
kind: "union";
|
|
16
|
+
members: string[];
|
|
17
|
+
};
|
|
18
|
+
export type TriggerPayloadProjection = TriggerPayloadSchemaProjection | TriggerPayloadUnionProjection;
|