Wizzi API

To use the Wizzi API you need to install the wizzi package locally in your project folder.

Install the wizzi package
npm i wizzi

All Wizzi Actions require an instance of the WizziFactory class.

Create a WizziFactory instance
import wizzi;
var wizziFactory = wizzi.createFactory({
    repo: {
        storeKind: 'filesystem'
    }, 
    plugins: {
        pluginsBaseFolder: __dirname,
        items: [
            'wizzi-core', 
            'wizzi-js', 
            'wizzi-web' 
        ] 
    }, 
    globalContext: {
        author: 'Stefano'
    } 
}, function(err, wizziFactory) {
    if (err) {
        throw new Error(err.message);
    } 
    // call wizziFactory methods
}); 

Creation options cannot be modified. If you need to change the options you have to create a new istance.

Execute a Load mTree action
wizziFactory.loadMTree (
    path.join (__dirname, 'ittf', 'mysource.myschema.ittf'),
    myContextObject, 
    function (err, loadedMTree) {
        if (err) {
            throw new Error(err.message);
        } 
        // ... use the loadedMTree object
    }); 

Usually you don't need to load an mTree, the Wizzi Model Loader does it for you. But, if needed, you can load and modify an mTree and then pass it to the Wizzi Model Loader instead of the path to the source ITTF Document.

Execute a Load mTree buildup script action
wizziFactory.loadMTreeBuildUpScript (
    path.join (__dirname, 'ittf', 'mysource.myschema.ittf'),
    myContextObject, 
    function (err, loadedMTreeBuildUpScript) {
        if (err) {
            throw new Error(err.message);
        } 
        // ... use the loadedMTreeBuildUpScript object
    }); 

You execute this action for debugging purposes. An mTree Debug Info contains the source of the mTree build up script generated by the ITTF Process.

Execute a Load Wizzi Model Instance action
wizziFactory.loadModel (
    'myschema', // schema name
    path.join (__dirname, 'ittf', 'mysource.myschema.ittf'),
    { 
        mTreeBuildUpContext: myContextObject,
        formatOptions: {}
    }, 
    function (err, loadedModel) {
        if (err) {
            throw new Error(err.message);
        } 
        // ... use the loadedModel object
    }); 

With this action you load a Wizzi Model Instance that will be used as a context object in following actions.

Execute a Model Transformation action
wizziFactory.transformModel (
    myLoadedModel, // Wizzi Model Instance
    'myschema/mytransformer', // transformer name
    myContextObject, 
    function (err, transformedModel) {
        if (err) {
            throw new Error(err.message);
        } 
        // ... use the transformedModel object
    }); 

With this action you can extract from a Wizzi Model Instance a modified instance or a POJO object to use as a context object in following actions.

Execute an Artifact Generation action
wizziFactory.generateArtifact (
    artifactModel, // Wizzi Model Instance or POJO, the main generation context
    path.join (__dirname, 'ittf', 'mysource.myschema.ittf'),
    'myschema/myartifact', // artifact name
    myContextObject, 
    function (err, artifactText) {
        if (err) {
            throw new Error(err.message);
        } 
        // ... save or use the artifactText
    }); 
Wizzi API