import "typeLib" as typeLib; #["DEBUG:",{"creationDate":"number","ingestions":[{"administrationRoute":"string","consumerName":"null","creationDate":"number","customUnitId":"null","dose":"number","estimatedDoseStandardDeviation":"null","isDoseAnEstimate":"boolean","notes":"string","stomachFullness":"null","substanceName":"string","time":"number","units":"string"}],"isFavorite":"boolean","location":"null","ratings":"array:empty/unknown","sortDate":"number","text":"string","timedNotes":"array:empty/unknown","title":"string"}] def ensureExperience: . as $experience | typeLib::ensureObject | debug(. | typeLib::dumpType) | $experience | typeLib::ensureKey("experience"; "title") | .title | typeLib::ensureWrapError("experience:title"; typeLib::ensureString) | $experience | typeLib::ensureKey("experience"; "text") | .text | typeLib::ensureWrapError("experience:text"; typeLib::ensureString) | $experience | typeLib::ensureKey("experience"; "creationDate") | .creationDate | typeLib::ensureWrapError("experience:creationDate"; typeLib::ensureNumber) | $experience | typeLib::ensureKey("experience"; "sortDate") | .sortDate | typeLib::ensureWrapError("experience:sortDate"; typeLib::ensureNumber) | $experience | typeLib::ensureKey("experience"; "isFavorite") | .isFavorite | typeLib::ensureWrapError("experience:isFavorite"; typeLib::ensureBool) ; def ensureExportData: . as $exportData | if typeLib::typecheckingEnabled then typeLib::ensureObject | typeLib::ensureKey("exportData"; "customSubstances") | typeLib::ensureKey("exportData"; "customUnits") | typeLib::ensureKey("exportData"; "experiences") | typeLib::ensureKey("exportData"; "substanceCompanions") | (reduce .experiences[] as $experience (null; $experience | ensureExperience)) end;