# content-tool-api

Roomle Component Tool API

Example usage - API for Tools

1. `npm install roomle-content-tool-api`

2. use the API in your tool


````typescript
import * as API from 'roomle-content-tool-api';

// handles cached content files
const projectFileService = new API.ProjectFileService('/path/to/project/root');

// get component payload
const payload = projectFileService.getPayloadById('my:component');

// modfiy component definition
payload.componentJson.onUpdate += '// inserted code\n';

// store the payload to disk
projectFileService.storeComponentPayload(payload);
````

3. if you need, you can run analyses
````javascript
await api.runScriptAnalyzer(payload, showMessagesInUi); // runs script analyzer from roomle-core-hsc
api.feedPayloadAutocompleteEntries(payload, false); // will analyse component definition and scripts to fetch autocomplete entries
````
