Knowledge Base/How to remove orphaned/unused compositions
How to remove orphaned/unused compositions
how-toDeveloperCanvasMaintenance
How to find compositions not attached to project map nodes using UI#
Sometimes you may have compositions in the project, which are no longer used anywhere, i.e. not attached to any project map node. Unless these are used directly in code, it is safe to delete them. There is a way to see which ones are not attached to a proect map node. When you create a new project map node, you can select an option to see existing compositions:
However, when you use the composition search, you can only search by fields and types. You can locate these composition by name and removed as needed.
How to find and remove compositions not attached to project map nodes#
If there is a big list or not obvious how to find those, please find a code example below. Here are the steps how you can get a list of compositions for a project and remove them:
Get the bearer token to be able to access the Uniform API directly. To do that, open the https://uniform.app/cli-login in the browser and press copy. Alternativly, you can also use Uniform API key, be specifying it as x-api-key header
Create a file like this under a project where you have .env defined with the needed Uniform project ID. Make sure to replace the Authorization header with the copied value like ‘Bearer <value>’
Please proceed with caution. This code removes the compositions without confirmation. It is highly recomended to make a backup of the project
Example TS code which can be executed as npx ts-node file.ts