(trigger: StartBlockCandidate<T>)
| 343 | // Sort by priority (lower number = higher priority) |
| 344 | const sorted = [...candidates].sort((a, b) => { |
| 345 | const getPriority = (trigger: StartBlockCandidate<T>): number => { |
| 346 | // Start block - highest priority |
| 347 | if (trigger.path === StartBlockPath.UNIFIED) return 0 |
| 348 | if (trigger.path === StartBlockPath.LEGACY_STARTER) return 1 |
| 349 | |
| 350 | // For external triggers, differentiate schedules from webhooks |
| 351 | if (trigger.path === StartBlockPath.EXTERNAL_TRIGGER) { |
| 352 | if (trigger.block.type === 'schedule') return 2 |
| 353 | return 3 // Webhooks and other external triggers |
| 354 | } |
| 355 | |
| 356 | // Other trigger types |
| 357 | if (trigger.path === StartBlockPath.SPLIT_API) return 4 |
| 358 | if (trigger.path === StartBlockPath.SPLIT_INPUT) return 5 |
| 359 | if (trigger.path === StartBlockPath.SPLIT_MANUAL) return 6 |
| 360 | if (trigger.path === StartBlockPath.SPLIT_CHAT) return 7 |
| 361 | |
| 362 | return 99 // Unknown |
| 363 | } |
| 364 | |
| 365 | return getPriority(a) - getPriority(b) |
| 366 | }) |
no outgoing calls
no test coverage detected