const updateToV7 = function()

in parsers/LU/JS/packages/lu/src/parser/utils/helpers.js [210:261]


const updateToV7 = function(finalLUISJSON) {
    let v7DefFound = false;
    v7DefFound = (finalLUISJSON.entities || []).find(i => i.children || i.features) ||
        (finalLUISJSON.intents || []).find(i => i.features) ||
        (finalLUISJSON.composites || []).find(i => i.features) ||
        (finalLUISJSON.luis_schema_version === '6.0.0' || 
        (finalLUISJSON.luis_schema_version === '7.0.0'));
    if (v7DefFound) {
        finalLUISJSON.luis_schema_version = "7.0.0";
        if (finalLUISJSON.hasOwnProperty("model_features")) {
            if (finalLUISJSON.model_features !== undefined) {
                finalLUISJSON.phraselists = finalLUISJSON.phraselists || [];
                finalLUISJSON.model_features.forEach(item => {
                    if (item.enabledForAllModels === undefined)
                        item.enabledForAllModels = true;
                    finalLUISJSON.phraselists.push(Object.assign({}, item));
                });
            }
            delete finalLUISJSON.model_features;
        }
        (finalLUISJSON.composites || []).forEach(composite => {
            let children = composite.children;
            composite.children = [];
            children.forEach(c => {
                if (c.name === undefined) {
                    composite.children.push({ name: c });
                }
                else {
                    composite.children.push(c);
                }
            });
        });
        (finalLUISJSON.entities || []).forEach(entity => transformAllEntityConstraintsToFeatures(entity));
        (finalLUISJSON.intents || []).forEach(intent => addIsRequiredProperty(intent));
        // do we have nDepthEntities?
        let nDepthEntityExists = (finalLUISJSON.entities || []).find(x => x.children !== undefined && Array.isArray(x.children) && x.children.length !== 0);
        if (nDepthEntityExists !== undefined) {
            // Remove dead ML entity definitions. 
            removeDeadMLEntityDefinitions(finalLUISJSON);
            let entityParentTree = {};
            const curPath = ["$root$"];
            constructEntityParentTree(finalLUISJSON.entities, entityParentTree, curPath);
            updateEntityParentTreeWithAllEntityTypes(finalLUISJSON, entityParentTree);
            
            // Verify that all parents of a child entity are labelled.
            updateModelBasedOnNDepthEntities(finalLUISJSON.utterances, entityParentTree);
            
            transformUtterancesWithNDepthEntities(finalLUISJSON, entityParentTree)
            verifyPatternsDoNotHaveChildEntityReferences(finalLUISJSON, entityParentTree)    
        }
    }
}