How to use the @accordproject/ergo-compiler.APModelManager function in @accordproject/ergo-compiler

To help you get started, we’ve selected a few @accordproject/ergo-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github accordproject / template-studio-v2 / src / sagas / modelSaga.js View on Github external
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;