( bytes: Uint8Array, hint: OperationFileHint, contentType: string | null | undefined, )
| 560 | }; |
| 561 | |
| 562 | const fileFromBinaryBytes = ( |
| 563 | bytes: Uint8Array, |
| 564 | hint: OperationFileHint, |
| 565 | contentType: string | null | undefined, |
| 566 | ): ToolFileValue => { |
| 567 | const hintedMimeType = contentType ?? readHintMimeType(hint, "application/octet-stream"); |
| 568 | return { |
| 569 | _tag: "ToolFile", |
| 570 | mimeType: isGenericMimeType(hintedMimeType) |
| 571 | ? (sniffMimeType(bytes) ?? hintedMimeType) |
| 572 | : hintedMimeType, |
| 573 | encoding: "base64", |
| 574 | data: bytesToBase64(bytes), |
| 575 | byteLength: bytes.byteLength, |
| 576 | }; |
| 577 | }; |
| 578 | |
| 579 | type FormDataRecord = Parameters<typeof HttpClientRequest.bodyFormDataRecord>[1]; |
| 580 | type FormDataCoercible = FormDataRecord[string]; |
no test coverage detected