(source: Buffer, contentBounds: BufferJsonValueBounds | null)
| 704 | } |
| 705 | |
| 706 | function extractLargeUserTextBuffer(source: Buffer, contentBounds: BufferJsonValueBounds | null): string | undefined { |
| 707 | if (!contentBounds) return undefined |
| 708 | if (contentBounds.kind === 'string') return readJsonStringBuffer(source, contentBounds, USER_TEXT_CAP) |
| 709 | if (contentBounds.kind !== 'array') return undefined |
| 710 | |
| 711 | let text = '' |
| 712 | let i = contentBounds.start + 1 |
| 713 | while (i < contentBounds.end - 1 && text.length < USER_TEXT_CAP) { |
| 714 | while (i < contentBounds.end && isJsonWhitespaceByte(source[i])) i++ |
| 715 | if (source[i] === 0x2c) { |
| 716 | i++ |
| 717 | continue |
| 718 | } |
| 719 | if (source[i] !== 0x7b) { |
| 720 | i++ |
| 721 | continue |
| 722 | } |
| 723 | const objectEnd = findJsonContainerEndBuffer(source, i, 0x7b, 0x7d, contentBounds.end) |
| 724 | if (objectEnd === -1) break |
| 725 | const objectBounds = { start: i, end: objectEnd + 1, kind: 'object' as const } |
| 726 | const type = readJsonStringBuffer(source, findObjectFieldValueBuffer(source, objectBounds.start, objectBounds.end, 'type')) |
| 727 | if (type === 'text' || type === 'input_text') { |
| 728 | const part = readJsonStringBuffer( |
| 729 | source, |
| 730 | findObjectFieldValueBuffer(source, objectBounds.start, objectBounds.end, 'text'), |
| 731 | USER_TEXT_CAP - text.length, |
| 732 | ) |
| 733 | if (part) text += (text ? ' ' : '') + part |
| 734 | } |
| 735 | i = objectEnd + 1 |
| 736 | } |
| 737 | return text || undefined |
| 738 | } |
| 739 | |
| 740 | function extractLargeAddedNamesBuffer(source: Buffer, attachmentBounds: BufferJsonValueBounds | null): string[] { |
| 741 | if (!attachmentBounds || attachmentBounds.kind !== 'object') return [] |
no test coverage detected