MCPcopy Create free account
hub / github.com/simstudioai/sim / createFormData

Function createFormData

apps/sim/app/api/table/[tableId]/import/route.test.ts:83–116  ·  view source on GitHub ↗
(
  file: File,
  options?: {
    workspaceId?: string | null
    mode?: string | null
    mapping?: unknown
    createColumns?: unknown
  }
)

Source from the content-addressed store, hash-verified

81}
82
83function createFormData(
84 file: File,
85 options?: {
86 workspaceId?: string | null
87 mode?: string | null
88 mapping?: unknown
89 createColumns?: unknown
90 }
91): FormData {
92 // Text fields must precede the file part for the streaming parser.
93 const form = new FormData()
94 if (options?.workspaceId !== null) {
95 form.append('workspaceId', options?.workspaceId ?? 'workspace-1')
96 }
97 if (options?.mode !== null) {
98 form.append('mode', options?.mode ?? 'append')
99 }
100 if (options?.mapping !== undefined) {
101 form.append(
102 'mapping',
103 typeof options.mapping === 'string' ? options.mapping : JSON.stringify(options.mapping)
104 )
105 }
106 if (options?.createColumns !== undefined) {
107 form.append(
108 'createColumns',
109 typeof options.createColumns === 'string'
110 ? options.createColumns
111 : JSON.stringify(options.createColumns)
112 )
113 }
114 form.append('file', file)
115 return form
116}
117
118function buildTable(overrides: Partial<TableDefinition> = {}): TableDefinition {
119 return {

Callers 1

route.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected