import isString from 'lodash/isString'; export function stringifyOccurrenceData(value: any): string { if (value === undefined) { return 'undefined'; } if (isString(value)) { try { value = JSON.parse(value); } catch (error) {} } return JSON.stringify(value, null, 4); } export function copyToClipboard(text: string) { const el = document.createElement('textarea'); el.value = text; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); } export function curlCommand(request: any, requestData: any, headers: any): null | string { if (!request.url || !request.method) { return null; } const curlLines = [`curl "${request.url}"`]; curlLines.push(` -X ${request.method}`); Object.entries(headers || {}).map(function ([key, value]) { curlLines.push(` -H '${key}: ${value}'`); }); const curlBodyString = curlBody(requestData, headers); if (curlBodyString) { curlLines.push(curlBodyString); } return curlLines.join(' \\\n'); } function curlBody(requestData: any, headers: any) { if (!requestData.body) { return null; } if (headers['content-type']?.[0]?.includes('application/json')) { return ` -d ${JSON.stringify(requestData.body)}`; } const formValues = Object.entries(requestData.body || {}).map(function ([key, value]) { return `-F '${key}=${value}'`; }); return ` ${formValues.join(' ')}`; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
components | Folder | 0755 |
|
|
contexts | Folder | 0755 |
|
|
hooks | Folder | 0755 |
|
|
vendor | Folder | 0755 |
|
|
Ignition.tsx | File | 2.25 KB | 0644 |
|
index.tsx | File | 2.31 KB | 0644 |
|
module.d.ts | File | 237 B | 0644 |
|
shareClient.ts | File | 2.42 KB | 0644 |
|
types.ts | File | 3.21 KB | 0644 |
|
util.ts | File | 1.58 KB | 0644 |
|