include "dropins"; import "lib/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 ensureIngestion: . as $ingestion | typeLib::ensureObject | $ingestion | typeLib::ensureKey("ingestion"; "substanceName") | .substanceName | typeLib::ensureWrapError("experience:substanceName"; typeLib::ensureString); def ensureTimedNote: . as $timedNote | if typeLib::typecheckingEnabled then $timedNote | typeLib::ensureObject | $timedNote | typeLib::ensureKey("timedNote"; "color") | $timedNote.color | typeLib::ensureWrapError("timedNote:color"; typeLib::ensureString) | $timedNote | typeLib::ensureKey("timedNote"; "creationDate") | $timedNote.creationDate | typeLib::ensureWrapError("timedNote:creationDate"; typeLib::ensureNumber) | $timedNote | typeLib::ensureKey("timedNote"; "isPartOfTimeline") | $timedNote.isPartOfTimeline | typeLib::ensureWrapError("timedNote:isPartOfTimeline"; typeLib::ensureBool) | $timedNote | typeLib::ensureKey("timedNote"; "note") | $timedNote.note | typeLib::ensureWrapError("timedNote:note"; typeLib::ensureString) | $timedNote | typeLib::ensureKey("timedNote"; "time") | $timedNote.time | typeLib::ensureWrapError("timedNote:time"; typeLib::ensureNumber) end; def ensureExperience: . as $experience | if typeLib::typecheckingEnabled then $experience | typeLib::ensureObject | $experience | typeLib::ensureKey("experience"; "title") | $experience.title | typeLib::ensureWrapError("experience:title"; typeLib::ensureString) | $experience | typeLib::ensureKey("experience"; "text") | $experience.text | typeLib::ensureWrapError("experience:text"; typeLib::ensureString) | $experience | typeLib::ensureKey("experience"; "creationDate") | $experience.creationDate | typeLib::ensureWrapError("experience:creationDate"; typeLib::ensureNumber) | $experience | typeLib::ensureKey("experience"; "sortDate") | $experience.sortDate | typeLib::ensureWrapError("experience:sortDate"; typeLib::ensureNumber) | $experience | typeLib::ensureKey("experience"; "isFavorite") | $experience.isFavorite | typeLib::ensureWrapError("experience:isFavorite"; typeLib::ensureBool) | $experience | typeLib::ensureKey("experience"; "timedNotes") | $experience.timedNotes | typeLib::ensureWrapError("experience:timedNotes"; typeLib::ensureArray) | (reduce $experience.timedNotes[] as $timedNote (null; $timedNote | ensureTimedNote)) | $experience | typeLib::ensureKey("experience"; "ingestions") | $experience.ingestions | typeLib::ensureWrapError("experience:ingestions"; typeLib::ensureArray) | (reduce $experience.ingestions[] as $ingestion (null; $ingestion | ensureIngestion)) end; 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;