{"version":3,"file":"downloadSampleEvents-Det4RCMG.js","sources":["../../src/scripts/downloadSampleEvents.ts"],"sourcesContent":["export async function getSampleEvents(streamPath: string, qty = 100){\r\n const query = new URLSearchParams({qty: qty.toFixed(0)})\r\n const events = await fetch('/events/downloadHistory/'+streamPath+'?'+query.toString()).then(r=>r.json())\r\n return events\r\n}\r\n\r\nexport async function downloadSampleEvents(streamPath: string, qty = 100){\r\n const events = await getSampleEvents(streamPath, qty)\r\n const fileContent = getNdjson(events)\r\n const blob = new Blob([fileContent],{type: 'application/x-ndjson', endings: 'transparent'})\r\n const link = document.createElement('a');\r\n link.href = URL.createObjectURL(blob);\r\n link.download = \"sample-\" + streamPath + \"-events.json\"\r\n link.click()\r\n URL.revokeObjectURL(link.href)\r\n}\r\n\r\n\r\nfunction getNdjson(array: any[]) {\r\n return array.map(({ received, ...i }) => JSON.stringify(i)).join(\"\\n\")\r\n}\r\n\r\nexport async function downloadStringAsFile(fileContent: string, filename: string, fileType: string) {\r\n const blob = new Blob([fileContent], { type: fileType, endings: \"transparent\" })\r\n const link = document.createElement(\"a\")\r\n link.href = URL.createObjectURL(blob)\r\n link.download = filename\r\n link.click()\r\n URL.revokeObjectURL(link.href)\r\n}\r\n\r\n\r\nexport async function getCountData(streamPath: string) {\r\n return await fetch(\"/events/stats/\" + streamPath).then(r => r.json())\r\n}\r\n\r\nexport async function downloadEventCountJson(streamPath: string) {\r\n const eventCount = await getCountData(streamPath)\r\n await downloadStringAsFile(JSON.stringify(eventCount), `${streamPath}-statistics.json`, \"application/x-ndjson\")\r\n}\r\n"],"names":["getSampleEvents","streamPath","qty","query","r","downloadSampleEvents","events","fileContent","getNdjson","blob","link","array","received","i","downloadStringAsFile","filename","fileType","getCountData","downloadEventCountJson","eventCount"],"mappings":"AAAsB,eAAAA,EAAgBC,EAAoBC,EAAM,IAAI,CAC5D,MAAAC,EAAQ,IAAI,gBAAgB,CAAC,IAAKD,EAAI,QAAQ,CAAC,CAAA,CAAE,EAEhD,OAD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