(runtime, options)
| 208 | TriggerAppEventCommandOptions, |
| 209 | TriggerAppEventCommandResult |
| 210 | > = async (runtime, options): Promise<TriggerAppEventCommandResult> => { |
| 211 | if (!runtime.backend.triggerAppEvent) { |
| 212 | throw new AppError( |
| 213 | 'UNSUPPORTED_OPERATION', |
| 214 | 'apps.triggerEvent is not supported by this backend', |
| 215 | ); |
| 216 | } |
| 217 | |
| 218 | const name = requireAppEventName(options.name); |
| 219 | assertPayload(options.payload, `apps.triggerEvent payload for "${name}"`); |
| 220 | const backendResult = await runtime.backend.triggerAppEvent( |
| 221 | toAppBackendContext(runtime, options), |
| 222 | { |
| 223 | name, |
| 224 | ...(options.payload ? { payload: options.payload } : {}), |
| 225 | }, |
| 226 | ); |
| 227 | |
| 228 | const formattedBackendResult = toBackendResult(backendResult); |
| 229 | return { |
| 230 | kind: 'appEventTriggered', |
| 231 | name, |
| 232 | ...(options.payload ? { payload: options.payload } : {}), |
| 233 | ...(formattedBackendResult ? { backendResult: formattedBackendResult } : {}), |
| 234 | ...successText(`Triggered app event: ${name}`), |
| 235 | }; |
| 236 | }; |
| 237 | |
| 238 | function normalizeOpenTarget(options: OpenAppCommandOptions): BackendOpenTarget { |
| 239 | const app = normalizeOptionalText(options.app, 'app'); |
nothing calls this directly
no test coverage detected
searching dependent graphs…