Different parts of the Repertoire toolset expose different objects and functions that you can interact with. For example, a Report script can utilise the Renderer object, to query the mime-type and interact with the RawReport object. However, it is an error to reference these objects when executing an Ensemble script (e.g. a Composite DataSource script), because these objects are not available in the Ensemble context. You need to be aware when creating a reusable JavaScript file what context it will be running in so that you can ensure you are accessing the appropriate objects.