Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function* validateClauseModelFiles(action) {
const { clauseTemplateId } = action;
// get all the model files for a template
const clauseTemplates = yield select(clauseTemplateSelectors.clauseTemplates);
const modelFiles = clauseTemplates[clauseTemplateId].model;
try {
// create a new ModelManager with the template's concerto files
const modelManager = new APModelManager();
modelFiles.forEach((file) => {
modelManager.addModelFile(file.content, file.name, true);
});
// download external dependencies
yield modelManager.updateExternalModels();
// validate the model manager
modelManager.validateModelFiles();
yield put(actions.updateModelManagerSuccess(modelManager));
yield put(actions.updateModelManagerError(null, clauseTemplateId));
} catch (err) {
err.type = 'Model';
err.fileName = action.fileName;