(source: BackendInstallSource | undefined)
| 220 | } |
| 221 | |
| 222 | function normalizeInstallSource(source: BackendInstallSource | undefined): BackendInstallSource { |
| 223 | if (!source || typeof source !== 'object') { |
| 224 | throw new AppError('INVALID_ARGS', 'install source is required'); |
| 225 | } |
| 226 | if (source.kind === 'path') { |
| 227 | return { kind: 'path', path: requireText(source.path, 'source.path') }; |
| 228 | } |
| 229 | if (source.kind === 'uploadedArtifact') { |
| 230 | return { kind: 'uploadedArtifact', id: requireText(source.id, 'source.id') }; |
| 231 | } |
| 232 | if (source.kind === 'url') { |
| 233 | const url = requireText(source.url, 'source.url'); |
| 234 | assertHttpUrl(url); |
| 235 | return { kind: 'url', url }; |
| 236 | } |
| 237 | throw new AppError('INVALID_ARGS', 'install source kind must be path, uploadedArtifact, or url'); |
| 238 | } |
| 239 | |
| 240 | function assertHttpUrl(url: string): void { |
| 241 | let parsed: URL; |
no test coverage detected
searching dependent graphs…