Refactoring: de-duplicate the json_by_id/path/type code
bag.js, collection.js and datacite.js have the same (or slightly different) versions of the code to build three index dicts of a graph's contents - this should probably be moved to a utility function