| 535 | } |
| 536 | |
| 537 | const parseReadFileIds = (input: unknown): string | string[] | null => { |
| 538 | let value = input |
| 539 | |
| 540 | if (typeof value === 'string') { |
| 541 | const trimmed = value.trim() |
| 542 | if (!trimmed) return null |
| 543 | |
| 544 | try { |
| 545 | value = JSON.parse(trimmed) |
| 546 | } catch { |
| 547 | return trimmed |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | if (Array.isArray(value)) { |
| 552 | const fileIds = value |
| 553 | .map((item) => (typeof item === 'string' ? item.trim() : '')) |
| 554 | .filter((item) => item.length > 0) |
| 555 | |
| 556 | if (fileIds.length === 0) return null |
| 557 | return fileIds.length === 1 ? fileIds[0] : fileIds |
| 558 | } |
| 559 | |
| 560 | return null |
| 561 | } |
| 562 | |
| 563 | export const FileV4Block: BlockConfig<FileParserV3Output> = { |
| 564 | ...FileV3Block, |