(message: CodexFetchMessage)
| 158 | } |
| 159 | |
| 160 | function parsePickFilesRequest(message: CodexFetchMessage): PickFilesRequest { |
| 161 | if (!message.body) { |
| 162 | return {}; |
| 163 | } |
| 164 | |
| 165 | try { |
| 166 | const parsed = JSON.parse(message.body) as unknown; |
| 167 | if (!isRecord(parsed)) { |
| 168 | return {}; |
| 169 | } |
| 170 | return { |
| 171 | imagesOnly: |
| 172 | typeof parsed.imagesOnly === "boolean" ? parsed.imagesOnly : undefined, |
| 173 | pickerTitle: |
| 174 | typeof parsed.pickerTitle === "string" ? parsed.pickerTitle : undefined, |
| 175 | }; |
| 176 | } catch { |
| 177 | return {}; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | function sendFetchResponse( |
| 182 | message: CodexFetchMessage, |
no test coverage detected