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

Function groupTriggersByProvider

scripts/generate-docs.ts:3597–3621  ·  view source on GitHub ↗

* Group triggers by provider; triggers within each group are sorted alphabetically. * When multiple triggers share the same display name (e.g. v1 + v2 of the same event), * only the highest-version variant is kept so docs don't show duplicate sections.

(
  registry: Map<string, TriggerFullInfo>
)

Source from the content-addressed store, hash-verified

3595 * only the highest-version variant is kept so docs don't show duplicate sections.
3596 */
3597function groupTriggersByProvider(
3598 registry: Map<string, TriggerFullInfo>
3599): Map<string, TriggerFullInfo[]> {
3600 const groups = new Map<string, TriggerFullInfo[]>()
3601 for (const trigger of registry.values()) {
3602 const bucket = groups.get(trigger.provider) ?? []
3603 bucket.push(trigger)
3604 groups.set(trigger.provider, bucket)
3605 }
3606 for (const [provider, triggers] of groups) {
3607 // Deduplicate by name: keep the highest-versioned trigger for each display name
3608 const byName = new Map<string, TriggerFullInfo>()
3609 for (const trigger of triggers) {
3610 const existing = byName.get(trigger.name)
3611 if (!existing || triggerVersionOrdinal(trigger.id) > triggerVersionOrdinal(existing.id)) {
3612 byName.set(trigger.name, trigger)
3613 }
3614 }
3615 groups.set(
3616 provider,
3617 [...byName.values()].sort((a, b) => a.name.localeCompare(b.name))
3618 )
3619 }
3620 return groups
3621}
3622
3623/**
3624 * Map subBlock UI type identifiers to semantic data types for documentation.

Callers 1

generateAllTriggerDocsFunction · 0.85

Calls 4

triggerVersionOrdinalFunction · 0.85
getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected