(value: unknown)
| 76 | }; |
| 77 | |
| 78 | export function validateDataAppCode(value: unknown): DataAppCode { |
| 79 | const v = value as Partial<DataAppCode>; |
| 80 | if (!v || typeof v !== 'object') |
| 81 | throw new Error('Invalid app bundle: not an object'); |
| 82 | if (!v.manifest || typeof v.manifest !== 'object') |
| 83 | throw new Error('Invalid app bundle: missing manifest'); |
| 84 | if (!Array.isArray(v.files)) |
| 85 | throw new Error('Invalid app bundle: missing files'); |
| 86 | for (const f of v.files) { |
| 87 | if (!f || typeof f !== 'object') |
| 88 | throw new Error('Invalid app bundle: file entry is not an object'); |
| 89 | if (!isSafeRelPath(f?.path)) |
| 90 | throw new Error( |
| 91 | `Invalid app bundle: unsafe file path "${f?.path}"`, |
| 92 | ); |
| 93 | if (typeof f?.contentBase64 !== 'string') |
| 94 | throw new Error( |
| 95 | `Invalid app bundle: file "${f?.path}" missing content`, |
| 96 | ); |
| 97 | } |
| 98 | return v as DataAppCode; |
| 99 | } |
no test coverage detected