MCPcopy Index your code
hub / github.com/simstudioai/sim / buildTriggersSection

Function buildTriggersSection

scripts/generate-docs.ts:3652–3710  ·  view source on GitHub ↗

* Build the "## Triggers" section for an integration page. A trigger is a block * that starts a workflow, so this is appended to the service's actions page (or * used as the body of a trigger-only service page).

(triggers: TriggerFullInfo[])

Source from the content-addressed store, hash-verified

3650 * used as the body of a trigger-only service page).
3651 */
3652function buildTriggersSection(triggers: TriggerFullInfo[]): string {
3653 const allPolling = triggers.every((t) => t.polling)
3654 const mixedTypes = triggers.some((t) => t.polling) && triggers.some((t) => !t.polling)
3655
3656 let typeNote = ''
3657 if (allPolling) {
3658 typeNote =
3659 '\nThese run on a schedule \\(**polling-based**\\) — they check for new data rather than receiving push notifications.\n'
3660 } else if (mixedTypes) {
3661 typeNote =
3662 '\nSome of these are **polling-based** \\(checked on a schedule\\) while others are push-based webhooks.\n'
3663 }
3664
3665 let triggersSection = ''
3666 for (let i = 0; i < triggers.length; i++) {
3667 const trigger = triggers[i]
3668
3669 // Configuration table
3670 let configSection = ''
3671 if (trigger.configFields.length > 0) {
3672 configSection = '#### Configuration\n\n'
3673 configSection += '| Parameter | Type | Required | Description |\n'
3674 configSection += '| --------- | ---- | -------- | ----------- |\n'
3675 for (const field of trigger.configFields) {
3676 const type = toSemanticType(field.type)
3677 const desc = escapeMdxCell(field.description ?? field.placeholder ?? '')
3678 configSection += `| \`${field.id}\` | ${type} | ${field.required ? 'Yes' : 'No'} | ${desc} |\n`
3679 }
3680 configSection += '\n'
3681 }
3682
3683 // Output table
3684 let outputSection = ''
3685 if (Object.keys(trigger.outputs).length > 0) {
3686 outputSection = '#### Output\n\n'
3687 outputSection += '| Parameter | Type | Description |\n'
3688 outputSection += '| --------- | ---- | ----------- |\n'
3689 outputSection += formatOutputStructure(trigger.outputs)
3690 outputSection += '\n'
3691 }
3692
3693 const separator = i < triggers.length - 1 ? '\n---\n\n' : ''
3694
3695 triggersSection += `### ${trigger.name}\n\n`
3696 const escapedTriggerDescription = trigger.description
3697 .replace(/\{/g, '\\{')
3698 .replace(/\}/g, '\\}')
3699 triggersSection += `${escapedTriggerDescription}\n\n`
3700 triggersSection += configSection
3701 triggersSection += outputSection
3702 triggersSection += separator
3703 }
3704
3705 return `## Triggers
3706
3707A **Trigger** is a block that starts a workflow when an event happens in this service.
3708${typeNote}
3709${triggersSection}`

Callers 2

generateAllTriggerDocsFunction · 0.85

Calls 4

toSemanticTypeFunction · 0.85
escapeMdxCellFunction · 0.85
formatOutputStructureFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected