///|
pub fn export_bundle(source : String) -> ExportBundle raise ParseError {
let inspection = inspect_step(source)
let model = inspection.model
let property_sets = model.property_sets()
let scene = inspection.scene()
{
headline: inspection.headline(),
json: inspection.to_json(),
products_csv: products_to_csv(model.products()),
properties_csv: property_sets_to_csv(property_sets),
scene_json: scene.to_json(),
}
}
///|
pub fn ExportBundle::file_names(self : ExportBundle) -> Array[String] {
ignore(self)
["model.json", "products.csv", "properties.csv", "scene.json"]
}
///|
pub fn ExportBundle::has_content(self : ExportBundle) -> Bool {
self.json.length() > 0 &&
self.products_csv.length() > 0 &&
self.scene_json.length() > 0
}
///|
pub fn ExportBundle::report(self : ExportBundle) -> String {
self.headline +
"\n" +
"files: " +
self.file_names().join(", ") +
"\n" +
"json bytes: " +
self.json.length().to_string() +
"\n" +
"product rows: " +
(self.products_csv.split("\n").length() - 2).to_string() +
"\n" +
"property rows: " +
(self.properties_csv.split("\n").length() - 2).to_string()
}
///|
pub fn ExportBundle::payload(self : ExportBundle) -> String {
"{\"model\":" +
self.json +
",\"products_csv\":" +
json_string(self.products_csv) +
",\"properties_csv\":" +
json_string(self.properties_csv) +
",\"scene\":" +
self.scene_json +
"}"
}