MCPcopy Index your code
hub / github.com/simstudioai/sim / parseReadFileIds

Function parseReadFileIds

apps/sim/blocks/blocks/file.ts:537–561  ·  view source on GitHub ↗
(input: unknown)

Source from the content-addressed store, hash-verified

535}
536
537const 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
563export const FileV4Block: BlockConfig<FileParserV3Output> = {
564 ...FileV3Block,

Callers 1

file.tsFile · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected