(params: Record<string, unknown>)
| 285 | } |
| 286 | |
| 287 | function parseInstallSource(params: Record<string, unknown>): DaemonInstallSource { |
| 288 | const source = params.source; |
| 289 | if (!source || typeof source !== 'object') { |
| 290 | throw new AppError('INVALID_ARGS', 'Invalid params: source is required'); |
| 291 | } |
| 292 | const record = source as Record<string, unknown>; |
| 293 | if (record.kind === 'url') { |
| 294 | const url = typeof record.url === 'string' ? record.url.trim() : ''; |
| 295 | if (!url) { |
| 296 | throw new AppError('INVALID_ARGS', 'Invalid params: source.url is required for url sources'); |
| 297 | } |
| 298 | const rawHeaders = record.headers; |
| 299 | const headers: Record<string, string> = {}; |
| 300 | if (rawHeaders !== undefined) { |
| 301 | if (!rawHeaders || typeof rawHeaders !== 'object' || Array.isArray(rawHeaders)) { |
| 302 | throw new AppError('INVALID_ARGS', 'Invalid params: source.headers must be a string map'); |
| 303 | } |
| 304 | for (const [key, value] of Object.entries(rawHeaders as Record<string, unknown>)) { |
| 305 | if (typeof value !== 'string') { |
| 306 | throw new AppError( |
| 307 | 'INVALID_ARGS', |
| 308 | 'Invalid params: source.headers values must be strings', |
| 309 | ); |
| 310 | } |
| 311 | headers[key] = value; |
| 312 | } |
| 313 | } |
| 314 | return Object.keys(headers).length > 0 ? { kind: 'url', url, headers } : { kind: 'url', url }; |
| 315 | } |
| 316 | if (record.kind === 'path') { |
| 317 | const artifactPath = typeof record.path === 'string' ? record.path.trim() : ''; |
| 318 | if (!artifactPath) { |
| 319 | throw new AppError( |
| 320 | 'INVALID_ARGS', |
| 321 | 'Invalid params: source.path is required for path sources', |
| 322 | ); |
| 323 | } |
| 324 | return { kind: 'path', path: artifactPath }; |
| 325 | } |
| 326 | if (record.kind === 'github-actions-artifact') { |
| 327 | return parseGitHubActionsArtifactSource(record); |
| 328 | } |
| 329 | throw new AppError( |
| 330 | 'INVALID_ARGS', |
| 331 | 'Invalid params: source.kind must be "url", "path", or "github-actions-artifact"', |
| 332 | ); |
| 333 | } |
| 334 | |
| 335 | function toInstallFromSourceDaemonRequest( |
| 336 | params: Record<string, unknown>, |
no test coverage detected