Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): Distinguish Model Manager on CTO or AST, revise addModel operations #397

Merged
merged 8 commits into from
Mar 16, 2022
77 changes: 40 additions & 37 deletions packages/concerto-core/api.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
class AstModelManager extends BaseModelManager {
+ void constructor(object?)
}
class BaseModelManager {
+ void constructor(object?,processFile?)
+ boolean isModelManager()
+ Object accept(Object,Object)
+ void validateModelFile(string|ModelFile,string?) throws IllegalModelException
+ Object addModelFile(ModelFile,string?,string?,boolean?) throws IllegalModelException
+ Object addModel(modelInput,string?,string?,boolean?) throws IllegalModelException
+ Object updateModelFile(string|ModelFile,string?,boolean?) throws IllegalModelException
+ void deleteModelFile(string)
+ Object[] addModelFiles(|,string[],boolean?)
+ void validateModelFiles()
+ Promise updateExternalModels(Object?,FileDownloader?) throws IllegalModelException
+ void writeModelsToFileSystem(string,Object?,boolean)
+ Object[] getModels(Object?,boolean)
+ void clearModelFiles()
+ ModelFile getModelFile(string)
+ string[] getNamespaces()
+ ClassDeclaration getType(string) throws TypeNotFoundException
+ AssetDeclaration[] getAssetDeclarations()
+ TransactionDeclaration[] getTransactionDeclarations()
+ EventDeclaration[] getEventDeclarations()
+ ParticipantDeclaration[] getParticipantDeclarations()
+ EnumDeclaration[] getEnumDeclarations()
+ ConceptDeclaration[] getConceptDeclarations()
+ Factory getFactory()
+ Serializer getSerializer()
+ DecoratorFactory[] getDecoratorFactories()
+ void addDecoratorFactory(DecoratorFactory)
+ boolean derivesFrom(string,string)
+ object resolveMetaModel(object)
+ void getAst(boolean?)
}
class Concerto {
+ void constructor(modelManager)
+ void validate(obj,options?) throws Error
Expand Down Expand Up @@ -94,15 +129,9 @@ class Introspector {
+ ClassDeclaration[] getClassDeclarations()
+ ClassDeclaration getClassDeclaration(String) throws Error
}
class MetaModel {
+ string getMetaModelCto()
+ void createMetaModelManager()
+ object validateMetaModel(object)
+ object resolveMetaModel(object,object,boolean?)
+ object modelFileToMetaModel(object,boolean?)
+ object modelManagerToMetaModel(object,boolean?,boolean?)
+ object modelManagerFromMetaModel(object,boolean?)
}
+ void newMetaModelManager()
+ object validateMetaModel()
+ object modelManagerFromMetaModel()
class ModelFile {
+ void constructor(ModelManager,object,string?,string?) throws IllegalModelException
+ boolean isModelFile()
Expand Down Expand Up @@ -196,35 +225,9 @@ class ModelLoader {
+ object loadModelManager(string[],object,boolean?,number?)
+ object loadModelManagerFromModelFiles(object[],string[],object,boolean?,number?)
}
class ModelManager {
class ModelManager extends BaseModelManager {
+ void constructor(object?)
+ boolean isModelManager()
+ Object accept(Object,Object)
+ void validateModelFile(string|ModelFile,string?) throws IllegalModelException
+ Object addModelFile(string|ModelFile,string,boolean?) throws IllegalModelException
+ Object updateModelFile(string|ModelFile,string?,boolean?) throws IllegalModelException
+ void deleteModelFile(string)
+ Object[] addModelFiles(|,string[],boolean?)
+ void validateModelFiles()
+ Promise updateExternalModels(Object?,FileDownloader?) throws IllegalModelException
+ void writeModelsToFileSystem(string,Object?,boolean)
+ Object[] getModels(Object?,boolean)
+ void clearModelFiles()
+ ModelFile getModelFile(string)
+ string[] getNamespaces()
+ ClassDeclaration getType(string) throws TypeNotFoundException
+ AssetDeclaration[] getAssetDeclarations()
+ TransactionDeclaration[] getTransactionDeclarations()
+ EventDeclaration[] getEventDeclarations()
+ ParticipantDeclaration[] getParticipantDeclarations()
+ EnumDeclaration[] getEnumDeclarations()
+ ConceptDeclaration[] getConceptDeclarations()
+ Factory getFactory()
+ Serializer getSerializer()
+ DecoratorFactory[] getDecoratorFactories()
+ void addDecoratorFactory(DecoratorFactory)
+ boolean derivesFrom(string,string)
+ void getAst()
+ Object addCTOModel(string,string?,boolean?) throws IllegalModelException
}
class SecurityException extends BaseException {
+ void constructor(string)
Expand Down
7 changes: 5 additions & 2 deletions packages/concerto-core/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
# Note that the latest public API is documented using JSDocs and is available in api.txt.
#

Version 1.2.2 {971ab49db13d87551db109316e5b59eb} 2021-11-24
Version 1.2.2 {ee5fa0479fe2720d720ac500b1b3ead8} 2021-11-24
- Remove custom instanceof and add methods to check runtime type
- Remove support for Node 12
- Generate Typescript definitions from JSDoc
- Parser directly constructs metamodel instance
- Convert MetaModel to a class for Typescript + Webpack compatability
- Update Acorn to latest and refactor the JavaScript parser so we can use static class members
- New packages for parsing and metamodel, distinct from core
- Revisions to model manager API to support various inputs (e.g., CTO or AST)
- New vocabulary package for handling model vocabularies

Version 1.2.2 {b19318bb094e5da7bdff192cf9a3b4f2} 2021-08-12
Version 1.2.1 {b19318bb094e5da7bdff192cf9a3b4f2} 2021-08-12
- Fixes to metamodel, including terminology changes
- Ability to roundtrip model manager to metamodel
- Expose name resolution to MetaModel API
Expand Down
52 changes: 52 additions & 0 deletions packages/concerto-core/lib/astmodelmanager.js
Original file line number Diff line number Diff line change
@@ -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;
Loading