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

Function normalizeFileInput

apps/sim/blocks/utils.ts:574–606  ·  view source on GitHub ↗
(
  fileParam: unknown,
  options?: { single?: boolean; errorMessage?: string }
)

Source from the content-addressed store, hash-verified

572 options?: { single?: false }
573): object[] | undefined
574export function normalizeFileInput(
575 fileParam: unknown,
576 options?: { single?: boolean; errorMessage?: string }
577): object | object[] | undefined {
578 if (!fileParam) return undefined
579
580 if (typeof fileParam === 'string') {
581 try {
582 fileParam = JSON.parse(fileParam)
583 } catch {
584 return undefined
585 }
586 }
587
588 let files: object[] | undefined
589
590 if (Array.isArray(fileParam)) {
591 files = fileParam.length > 0 ? fileParam : undefined
592 } else if (typeof fileParam === 'object' && fileParam !== null) {
593 files = [fileParam]
594 }
595
596 if (!files) return undefined
597
598 if (options?.single) {
599 if (files.length > 1) {
600 throw new Error(options.errorMessage ?? DEFAULT_MULTIPLE_FILES_ERROR)
601 }
602 return files[0]
603 }
604
605 return files
606}
607
608/**
609 * Block types that are built-in to the platform (as opposed to third-party integrations).

Callers 15

firecrawl.tsFile · 0.90
extend.tsFile · 0.90
reducto.tsFile · 0.90
textract.tsFile · 0.90
telegram.tsFile · 0.90
linq.tsFile · 0.90
persona.tsFile · 0.90
servicenow.tsFile · 0.90
sharepoint.tsFile · 0.90
docusign.tsFile · 0.90
slack.tsFile · 0.90
mistral_parse.tsFile · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected