3.7.0-alpha.0 • Published 1 month ago

roomle-content-tool-api v3.7.0-alpha.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

content-tool-api

Roomle Component Tool API

Example usage - API for Tools

  1. npm install roomle-content-tool-api

  2. instantiate API

import { RoomleToolApi } from 'roomle-content-tool-api/lib/roomletoolapi';

// initialize the API instance
const api: RoomleToolApi = new RoomleToolApi((message: string, type: CallbackMessageType, showInUi: boolean) => {
    console.log(message);
    if (showInUi) {
        // send it to your user interface message box
    }
});
  1. get the data payload, either from file or from string
const payloadText = api.payloadFromText('{"id":"catalog:component","onUpdate":""}', false);
const payloadFile = api.payloadFromFile(path.resolve('../catalog/components/my.json'), false);
  1. prepare processing of the payload (this will unsecape and generate a valid JSON)
api.preparePayloadForProcessing(payload, false);
  1. get the component definition as a valid JSON in payload.componentJson or apply modifier functions
api.formatPayload(payload, false); 
api.normalizePayload(payload, false);
api.squash(payload, false);
api.deformat(payload, false);
api.rescript(payload, false);
  1. run finishProcessing
api.finishProcessing(payload.false)

This will make ready document available for further use or export in payload.processedDocument: string and payload.processedDocumentAsLines: string[]. Note: payload.documentHasActuallyChanged is true if input and processed document are equal

  1. if you need, you can run analyses
api.feedPayloadOutlineEntries(payload, showMessagesInUi); // will analyse and feed code outline entries (= level 1 JSON keys, #tag, #region, custom code markers, TODOs/FIXMEs) in payload.outlineEntries and also returns them
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

Example usage: component import/export

npm install roomle-content-tool-api

import { RoomleToolApi } from 'roomle-content-tool-api/lib/roomletoolapi';

// initialize the API instance
const api = new RoomleToolApi();

const payload = api.importComponentDefinition('./component.json', false);

// do stuff with component
payload.componentJson.parameters.push({key:'test'});

api.exportComponentDefintion(payload, false); // overwrites original file

api.exportComponentDefintionAs('./modified/component.json', payload, false); // saves as new file
3.7.0-alpha.0

1 month ago

3.6.3-alpha.0

3 months ago

3.6.1

3 months ago

3.6.2-alpha.0

3 months ago

3.6.0

3 months ago

3.6.1-alpha.0

3 months ago

3.6.0-alpha.1

4 months ago

3.6.0-alpha.0

4 months ago

3.5.2

4 months ago

3.5.2-alpha.0

5 months ago

3.5.2-alpha.1

5 months ago

3.5.1-alpha.0

5 months ago

3.4.0

6 months ago

3.2.0

6 months ago

3.3.0

6 months ago

3.5.0

6 months ago

3.0.3

8 months ago

3.1.1

7 months ago

3.1.0

7 months ago

2.1.2

10 months ago

2.2.0

10 months ago

2.1.1

10 months ago

2.1.0

10 months ago

2.0.0

11 months ago

3.0.2

9 months ago

3.0.1

9 months ago

3.0.0

9 months ago

1.11.0

11 months ago

1.10.0

12 months ago

1.8.2

1 year ago

1.9.0

12 months ago

1.8.0

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.0.2

2 years ago

1.1.0

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago