( type: Type, instance: TriggerDotDevGlobalAPI[Type], allowOverride = false )
| 10 | const _global = _globalThis as TriggerDotDevGlobal; |
| 11 | |
| 12 | export function registerGlobal<Type extends keyof TriggerDotDevGlobalAPI>( |
| 13 | type: Type, |
| 14 | instance: TriggerDotDevGlobalAPI[Type], |
| 15 | allowOverride = false |
| 16 | ): boolean { |
| 17 | const api = (_global[GLOBAL_TRIGGER_DOT_DEV_KEY] = _global[GLOBAL_TRIGGER_DOT_DEV_KEY] ?? {}); |
| 18 | |
| 19 | if (!allowOverride && api[type]) { |
| 20 | // already registered an API of this type |
| 21 | const err = new Error(`trigger.dev: Attempted duplicate registration of API: ${type}`); |
| 22 | return false; |
| 23 | } |
| 24 | |
| 25 | api[type] = instance; |
| 26 | |
| 27 | return true; |
| 28 | } |
| 29 | |
| 30 | export function getGlobal<Type extends keyof TriggerDotDevGlobalAPI>( |
| 31 | type: Type |
no outgoing calls
no test coverage detected
searching dependent graphs…