Skip to content

Commit c48a704

Browse files
waleedlatif1claude
andcommitted
fix(generate-docs): extract all trigger configs from multi-export files
The buildTriggerRegistry function used a single regex exec per file, which only captured the first TriggerConfig export. Files that export both v1 and v2 triggers (consolidated same-file convention) had their v2 triggers silently dropped from integrations.json. Split each file into segments per export and parse each independently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eb19ec1 commit c48a704

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

apps/sim/app/(landing)/integrations/data/integrations.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4015,8 +4015,14 @@
40154015
}
40164016
],
40174017
"operationCount": 12,
4018-
"triggers": [],
4019-
"triggerCount": 0,
4018+
"triggers": [
4019+
{
4020+
"id": "gmail_poller",
4021+
"name": "Gmail Email Trigger",
4022+
"description": "Triggers when new emails are received in Gmail (requires Gmail credentials)"
4023+
}
4024+
],
4025+
"triggerCount": 1,
40204026
"authType": "oauth",
40214027
"category": "tools",
40224028
"integrationType": "email",
@@ -7256,7 +7262,7 @@
72567262
{
72577263
"id": "linear_webhook_v2",
72587264
"name": "Linear Webhook",
7259-
"description": "Trigger workflow from Linear data-change events included in this webhook subscription (Issues, Comments, Projects, etc.—not every Linear model)."
7265+
"description": "Trigger workflow from Linear events you select when creating the webhook in Linear (not guaranteed to be every model or event type)."
72607266
}
72617267
],
72627268
"triggerCount": 15,
@@ -8580,8 +8586,14 @@
85808586
}
85818587
],
85828588
"operationCount": 9,
8583-
"triggers": [],
8584-
"triggerCount": 0,
8589+
"triggers": [
8590+
{
8591+
"id": "outlook_poller",
8592+
"name": "Outlook Email Trigger",
8593+
"description": "Triggers when new emails are received in Outlook (requires Microsoft credentials)"
8594+
}
8595+
],
8596+
"triggerCount": 1,
85858597
"authType": "oauth",
85868598
"category": "tools",
85878599
"integrationType": "email",

scripts/generate-docs.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,17 +491,35 @@ async function buildTriggerRegistry(): Promise<Map<string, TriggerInfo>> {
491491
try {
492492
const content = fs.readFileSync(file, 'utf-8')
493493

494-
// Each trigger file exports a single TriggerConfig with id, name, description
495-
const idMatch = /\bid\s*:\s*['"]([^'"]+)['"]/.exec(content)
496-
const nameMatch = /\bname\s*:\s*['"]([^'"]+)['"]/.exec(content)
497-
const descMatch = /\bdescription\s*:\s*['"]([^'"]+)['"]/.exec(content)
498-
499-
if (idMatch && nameMatch) {
500-
registry.set(idMatch[1], {
501-
id: idMatch[1],
502-
name: nameMatch[1],
503-
description: descMatch?.[1] ?? '',
504-
})
494+
// A file may export multiple TriggerConfig objects (e.g. v1 + v2 in
495+
// the same file). Extract all exported configs by splitting on the
496+
// export boundaries and parsing each one independently.
497+
const exportRegex = /export\s+const\s+\w+\s*:\s*TriggerConfig\s*=\s*\{/g
498+
let exportMatch
499+
const exportStarts: number[] = []
500+
501+
while ((exportMatch = exportRegex.exec(content)) !== null) {
502+
exportStarts.push(exportMatch.index)
503+
}
504+
505+
// If no typed exports found, fall back to simple regex on whole file
506+
const segments =
507+
exportStarts.length > 0
508+
? exportStarts.map((start, i) => content.substring(start, exportStarts[i + 1]))
509+
: [content]
510+
511+
for (const segment of segments) {
512+
const idMatch = /\bid\s*:\s*['"]([^'"]+)['"]/.exec(segment)
513+
const nameMatch = /\bname\s*:\s*['"]([^'"]+)['"]/.exec(segment)
514+
const descMatch = /\bdescription\s*:\s*['"]([^'"]+)['"]/.exec(segment)
515+
516+
if (idMatch && nameMatch) {
517+
registry.set(idMatch[1], {
518+
id: idMatch[1],
519+
name: nameMatch[1],
520+
description: descMatch?.[1] ?? '',
521+
})
522+
}
505523
}
506524
} catch {
507525
// skip unreadable files silently

0 commit comments

Comments
 (0)