(s, o, i, a = '')
| 35143 | } |
| 35144 | return s |
| 35145 | } |
| 35146 | const curlify = (s, o, i, a = '') => { |
| 35147 | let u = !1, |
| 35148 | _ = '' |
| 35149 | const addWords = (...s) => (_ += ' ' + s.map(o).join(' ')), |
| 35150 | addWordsWithoutLeadingSpace = (...s) => (_ += s.map(o).join(' ')), |
| 35151 | addNewLine = () => (_ += ` ${i}`), |
| 35152 | addIndent = (s = 1) => (_ += ' '.repeat(s)) |
| 35153 | let w = s.get('headers') |
| 35154 | _ += 'curl' + a |
| 35155 | const x = s.get('curlOptions') |
| 35156 | if ( |
| 35157 | (ze.List.isList(x) && !x.isEmpty() && addWords(...s.get('curlOptions')), |
| 35158 | addWords('-X', s.get('method')), |
| 35159 | addNewLine(), |
| 35160 | addIndent(), |
| 35161 | addWordsWithoutLeadingSpace(`${s.get('url')}`), |
| 35162 | w && w.size) |
| 35163 | ) |
| 35164 | for (let o of s.get('headers').entries()) { |
| 35165 | ;(addNewLine(), addIndent()) |
| 35166 | let [s, i] = o |
| 35167 | ;(addWordsWithoutLeadingSpace('-H', `${s}: ${i}`), |
| 35168 | (u = u || (/^content-type$/i.test(s) && /^multipart\/form-data$/i.test(i)))) |
| 35169 | } |
| 35170 | const C = s.get('body') |
| 35171 | if (C) |
| 35172 | if (u && ['POST', 'PUT', 'PATCH'].includes(s.get('method'))) |
| 35173 | for (let [s, o] of C.entrySeq()) { |
| 35174 | let i = extractKey(s) |
| 35175 | ;(addNewLine(), |
| 35176 | addIndent(), |
| 35177 | addWordsWithoutLeadingSpace('-F'), |
| 35178 | o instanceof lt.File && 'string' == typeof o.valueOf() |
| 35179 | ? addWords(`${i}=${o.data}${o.type ? `;type=${o.type}` : ''}`) |
| 35180 | : o instanceof lt.File |
| 35181 | ? addWords(`${i}=@${o.name}${o.type ? `;type=${o.type}` : ''}`) |
| 35182 | : addWords(`${i}=${o}`)) |
| 35183 | } |
| 35184 | else if (C instanceof lt.File) |
| 35185 | (addNewLine(), |
| 35186 | addIndent(), |
| 35187 | addWordsWithoutLeadingSpace(`--data-binary '@${C.name}'`)) |
| 35188 | else { |
| 35189 | ;(addNewLine(), addIndent(), addWordsWithoutLeadingSpace('-d ')) |
| 35190 | let o = C |
| 35191 | ze.Map.isMap(o) |
| 35192 | ? addWordsWithoutLeadingSpace( |
| 35193 | (function getStringBodyOfMap(s) { |
| 35194 | let o = [] |
| 35195 | for (let [i, a] of s.get('body').entrySeq()) { |
| 35196 | let s = extractKey(i) |
| 35197 | a instanceof lt.File |
| 35198 | ? o.push( |
| 35199 | ` "${s}": {\n "name": "${a.name}"${a.type ? `,\n "type": "${a.type}"` : ''}\n }` |
| 35200 | ) |
| 35201 | : o.push( |
| 35202 | ` "${s}": ${JSON.stringify(a, null, 2).replace(/(\r\n|\r|\n)/g, '\n ')}` |
no test coverage detected