| 106 | } |
| 107 | |
| 108 | export async function auditIfc(ifcId: string, idsData: number[] | Uint8Array | ArrayBuffer) { |
| 109 | const reporter = pyodide.pyimport("ifctester.reporter"); |
| 110 | const api = pyodide.pyimport("api"); |
| 111 | |
| 112 | const idsString = new TextDecoder().decode(new Uint8Array(idsData)); |
| 113 | const specs = api.ids_from_xml_string(idsString, true); |
| 114 | const ifc = LoadedIFC.get(ifcId); |
| 115 | |
| 116 | // Run audit |
| 117 | specs.validate(ifc); |
| 118 | |
| 119 | // Create report in both HTML and JSON formats |
| 120 | const jsonReporter = reporter.Json(specs); |
| 121 | jsonReporter.report(); |
| 122 | const jsonReport = jsonReporter.to_string(); |
| 123 | |
| 124 | const htmlReporter = reporter.Html(specs); |
| 125 | htmlReporter.report(); |
| 126 | const htmlReport = htmlReporter.to_string(); |
| 127 | |
| 128 | return { |
| 129 | json: JSON.parse(jsonReport) as AuditReportData, |
| 130 | html: htmlReport |
| 131 | }; |
| 132 | } |
| 133 | |
| 134 | // Expose interface |
| 135 | export const API = { |