diff --git a/packages/concerto-core/api.txt b/packages/concerto-core/api.txt index 3c29ea022f..c6ce9e8ea6 100644 --- a/packages/concerto-core/api.txt +++ b/packages/concerto-core/api.txt @@ -1,3 +1,6 @@ +class AstModelManager extends BaseModelManager { + + void constructor(object?) +} class BaseModelManager { + void constructor(object?,processFile?) + boolean isModelManager() @@ -223,7 +226,7 @@ class ModelLoader { + object loadModelManagerFromModelFiles(object[],string[],object,boolean?,number?) } class ModelManager extends BaseModelManager { - + void constructor(object?,processFile?) + + void constructor(object?) + Object addCTOModel(string,string,boolean?) throws IllegalModelException } class SecurityException extends BaseException { diff --git a/packages/concerto-core/changelog.txt b/packages/concerto-core/changelog.txt index 7c67d2d22a..e6e2e106f5 100644 --- a/packages/concerto-core/changelog.txt +++ b/packages/concerto-core/changelog.txt @@ -24,7 +24,7 @@ # Note that the latest public API is documented using JSDocs and is available in api.txt. # -Version 1.2.2 {a92fdef435d8588901b0c5f4b7b7cff1} 2021-11-24 +Version 1.2.2 {0bd210dc69b3813e8724353b1c355efc} 2021-11-24 - Remove custom instanceof and add methods to check runtime type - Remove support for Node 12 - Generate Typescript definitions from JSDoc diff --git a/packages/concerto-core/lib/astmodelmanager.js b/packages/concerto-core/lib/astmodelmanager.js new file mode 100644 index 0000000000..983ef6ffce --- /dev/null +++ b/packages/concerto-core/lib/astmodelmanager.js @@ -0,0 +1,52 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +const BaseModelManager = require('./basemodelmanager'); + +// How to create a modelfile from a cto file +const astProcessFile = (name, data) => { + return { + ast: data, + definitions: null, + fileName: name, + }; +}; + +/** + * Manages the Concerto model files in AST format. + * + * The structure of {@link Resource}s (Assets, Transactions, Participants) is modelled + * in a set of Concerto files. The contents of these files are managed + * by the {@link ModelManager}. Each Concerto file has a single namespace and contains + * a set of asset, transaction and participant type definitions. + * + * Concerto applications load their Concerto files and then call the {@link ModelManager#addModelFile addModelFile} + * method to register the Concerto file(s) with the ModelManager. + * + * @memberof module:concerto-core + */ +class AstModelManager extends BaseModelManager { + /** + * Create the ModelManager. + * @constructor + * @param {object} [options] - Serializer options + */ + constructor(options) { + super(options, astProcessFile); + } +} + +module.exports = AstModelManager; diff --git a/packages/concerto-core/lib/modelmanager.js b/packages/concerto-core/lib/modelmanager.js index 0d8eb12da5..d495d15431 100644 --- a/packages/concerto-core/lib/modelmanager.js +++ b/packages/concerto-core/lib/modelmanager.js @@ -47,7 +47,6 @@ class ModelManager extends BaseModelManager { * Create the ModelManager. * @constructor * @param {object} [options] - Serializer options - * @param {*} [processFile] - how to obtain a concerto AST from an input to the model manager */ constructor(options) { super(options, ctoProcessFile); diff --git a/packages/concerto-core/test/astmodelmanager.js b/packages/concerto-core/test/astmodelmanager.js new file mode 100644 index 0000000000..9f85d98f42 --- /dev/null +++ b/packages/concerto-core/test/astmodelmanager.js @@ -0,0 +1,44 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +const AstModelManager = require('../lib/astmodelmanager'); + +const chai = require('chai'); +chai.should(); +chai.use(require('chai-things')); +chai.use(require('chai-as-promised')); +const sinon = require('sinon'); + +describe('AstModelManager', () => { + let sandbox; + let modelManager; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + modelManager = new AstModelManager(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('#isModelManager', () => { + it('should return true', () => { + modelManager.isModelManager().should.be.true; + }); + }); + +});