Skip to main content

Generated JavaScript API

Modules

concerto-core

Concerto core module. Concerto is a framework for defining domain specific models.

concerto-cto

Concerto CTO concrete syntax module. Concerto is a framework for defining domain specific models.

concerto-metamodel

Concerto metamodel management. Concerto is a framework for defining domain specific models.

concerto-tools

Concerto Tools module.

concerto-util

Concerto utility module. Concerto is a framework for defining domain specific models.

concerto-vocabulary

Concerto vocabulary module. Concerto is a framework for defining domain specific models.

Classes

AbstractPlugin

Simple plug-in class for code-generation. This lists functions that can be passed to extend the default code-generation behavior.

EmptyPlugin

Simple plug-in class for code-generation. This lists functions that can be passed to extend the default code-generation behavior.

Constants

rootModelAst : unknown
metaModelCto

The metamodel itself, as a CTO string

metaModelAst : unknown

The metamodel itself, as an AST.

MetaModelNamespace

The namespace for the metamodel

metaModelCto

The metamodel itself, as a CTO string

levels : Object

Default levels for the npm configuration.

colorMap : Object

Default levels for the npm configuration.

Functions

setCurrentTime([currentTime], [utcOffset])object

Ensures there is a proper current time

newMetaModelManager()ModelManager

Create a metamodel manager (for validation against the metamodel)

validateMetaModel(input)object

Validate metamodel instance against the metamodel

modelManagerFromMetaModel(metaModel, [validate])ModelManager

Import metamodel to a model manager

getRootModel(versioned)object

Gets the root 'concerto' model

randomNumberInRangeWithPrecision(userMin, userMax, precision, systemMin, systemMax)number

Generate a random number within a given range with a prescribed precision and inside a global range

updateModels(models, newModel)*

Update models with a new model

resolveExternal(models, [options], [fileDownloader])Promise

Downloads all ModelFiles that are external dependencies and adds or updates them in this ModelManager.

parse(cto, [fileName], [options])object

Create a metamodel instance (i.e. JSON AST) object from a CTO string

parseModels(files, [options])*

Parses an array of model files

decoratorArgFromMetaModel(mm)string

Create decorator argument string from a metamodel

decoratorFromMetaModel(mm)string

Create decorator string from a metamodel

decoratorsFromMetaModel(mm, prefix)string

Create decorators string from a metamodel

typeFromMetaModel(mm)string

Create type string from a metamodel

modifiersFromMetaModel(mm)string

Create modifiers string from a metamodel

propertyFromMetaModel(mm)string

Create a property string from a metamodel

declFromMetaModel(mm)string

Create a declaration string from a metamodel

toCTO(metaModel)string

Create a model string from a metamodel

findNamespace(priorModels, namespace)*

Find the model for a given namespace

findDeclaration(thisModel, name)*

Find a declaration for a given name in a model

createNameTable(priorModels, metaModel)object

Create a name resolution table

resolveName(name, table)string

Resolve a name using the name table

resolveTypeNames(metaModel, table)object

Name resolution for metamodel

resolveLocalNames(priorModels, metaModel)object

Resolve the namespace for names in the metamodel

resolveLocalNamesForAll(allModels)object

Resolve the namespace for names in the metamodel

inferModelFile(defaultNamespace, defaultType, schema, options)string

Infers a Concerto model from a JSON Schema.

capitalizeFirstLetter(string)string

Capitalize the first letter of a string

hashCode(value)number

Computes an integer hashcode value for a string

isObject(val)Boolean

Returns true if val is an object

isBoolean(val)Boolean

Returns true if val is a boolean

isNull(val)Boolean

Returns true if val is null

isArray(val)Boolean

Returns true if val is an array

isString(val)Boolean

Returns true if val is a string

isDateTime(val)Boolean

Returns true if val is a date time

isInteger(val)Boolean

Returns true if val is an integer

isDouble(val)Boolean

Returns true if val is an integer

getType(input)string

Get the primitive Concerto type for an input

handleArray(typeName, context, input)object

Handles an array

handleType(name, context, input)object

Handles an input type

removeDuplicateTypes(context)

Detect duplicate types and remove them

inferModel(namespace, rootTypeName, input)string

Infers a Concerto model from a JSON instance.

main()

Generate TypeScript files from the metamodel.

labelToSentence(labelName)string

Inserts correct spacing and capitalization to a camelCase label

sentenceToLabel(sentence)string

Create a camelCase label from a sentence

writeModelsToFileSystem(files, path, options)

Writes a set of model files to disk

camelCaseToSentence(text)string

Converts a camel case string to a sentence

Typedefs

ParseNamespaceResult

concerto-core

Concerto core module. Concerto is a framework for defining domain specific models.

concerto-core.AstModelManager

Manages the Concerto model files in AST format.

The structure of Resources (Assets, Transactions, Participants) is modelled in a set of Concerto files. The contents of these files are managed by the 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 addModelFile method to register the Concerto file(s) with the ModelManager.

Kind: static class of concerto-core

new AstModelManager([options])

Create the ModelManager.

ParamTypeDescription
[options]objectSerializer options

concerto-core.BaseModelManager

Manages the Concerto model files.

The structure of Resources (Assets, Transactions, Participants) is modelled in a set of Concerto files. The contents of these files are managed by the 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 addModelFile method to register the Concerto file(s) with the ModelManager.

Use the Concerto class to validate instances.

Kind: static class of concerto-core

new BaseModelManager([options], [processFile])

Create the ModelManager.

ParamTypeDescription
[options]objectModelManager options, also passed to Serializer
[options.strict]booleanrequire versioned namespaces and imports
[options.regExp]ObjectAn alternative regular expression engine.
[processFile]*how to obtain a concerto AST from an input to the model manager

baseModelManager.isModelManager() ⇒ boolean

Returns true

Kind: instance method of BaseModelManager
Returns: boolean - true

baseModelManager.isStrict() ⇒ boolean

Returns the value of the strict option

Kind: instance method of BaseModelManager
Returns: boolean - true if the strict has been set

baseModelManager.accept(visitor, parameters) ⇒ Object

Visitor design pattern

Kind: instance method of BaseModelManager
Returns: Object - the result of visiting or null

ParamTypeDescription
visitorObjectthe visitor
parametersObjectthe parameter

baseModelManager.validateModelFile(modelFile, [fileName])

Validates a Concerto file (as a string) to the ModelManager. Concerto files have a single namespace.

Note that if there are dependencies between multiple files the files must be added in dependency order, or the addModelFiles method can be used to add a set of files irrespective of dependencies.

Kind: instance method of BaseModelManager
Throws:

  • IllegalModelException
ParamTypeDescription
modelFilestring | ModelFileThe Concerto file as a string
[fileName]stringa file name to associate with the model file

baseModelManager.addModelFile(modelFile, [cto], [fileName], [disableValidation]) ⇒ Object

Adds a Concerto file (as an AST) to the ModelManager. Concerto files have a single namespace. If a Concerto file with the same namespace has already been added to the ModelManager then it will be replaced. Note that if there are dependencies between multiple files the files must be added in dependency order, or the addModelFiles method can be used to add a set of files irrespective of dependencies.

Kind: instance method of BaseModelManager
Returns: Object - The newly added model file (internal).
Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFileModel as a ModelFile object
[cto]stringan optional cto string
[fileName]stringan optional file name to associate with the model file
[disableValidation]booleanIf true then the model files are not validated

baseModelManager.addModel(modelInput, [cto], [fileName], [disableValidation]) ⇒ ModelFile

Adds a model to the ModelManager. Concerto files have a single namespace. If a Concerto file with the same namespace has already been added to the ModelManager then it will be replaced. Note that if there are dependencies between multiple files the files must be added in dependency order, or the addModel method can be used to add a set of files irrespective of dependencies.

Kind: instance method of BaseModelManager
Returns: ModelFile - The newly added model file (internal).
Throws:

  • IllegalModelException
ParamTypeDescription
modelInput*Model (as a string or object)
[cto]stringan optional cto string
[fileName]stringan optional file name to associate with the model file
[disableValidation]booleanIf true then the model files are not validated

baseModelManager.updateModelFile(modelFile, [fileName], [disableValidation]) ⇒ Object

Updates a Concerto file (as a string) on the ModelManager. Concerto files have a single namespace. If a Concerto file with the same namespace has already been added to the ModelManager then it will be replaced.

Kind: instance method of BaseModelManager
Returns: Object - The newly added model file (internal).
Throws:

  • IllegalModelException
ParamTypeDescription
modelFilestring | ModelFileModel as a string or object
[fileName]stringa file name to associate with the model file
[disableValidation]booleanIf true then the model files are not validated

baseModelManager.deleteModelFile(namespace)

Remove the Concerto file for a given namespace

Kind: instance method of BaseModelManager

ParamTypeDescription
namespacestringThe namespace of the model file to delete.

baseModelManager.addModelFiles(modelFiles, [fileNames], [disableValidation]) ⇒ Array.<Object>

Add a set of Concerto files to the model manager.

Kind: instance method of BaseModelManager
Returns: Array.<Object> - The newly added model files (internal).

ParamTypeDescription
modelFilesArray.<string> | Array.<ModelFile>An array of models as strings or ModelFile objects.
[fileNames]Array.<string>A array of file names to associate with the model files
[disableValidation]booleanIf true then the model files are not validated

baseModelManager.validateModelFiles()

Validates all models files in this model manager

Kind: instance method of BaseModelManager

baseModelManager.updateExternalModels([options], [fileDownloader]) ⇒ Promise

Downloads all ModelFiles that are external dependencies and adds or updates them in this ModelManager.

Kind: instance method of BaseModelManager
Returns: Promise - a promise when the download and update operation is completed.
Throws:

  • IllegalModelException if the models fail validation
ParamTypeDescription
[options]ObjectOptions object passed to ModelFileLoaders
[fileDownloader]FileDownloaderan optional FileDownloader

baseModelManager.writeModelsToFileSystem(path, [options])

Write all models in this model manager to the specified path in the file system

Kind: instance method of BaseModelManager

ParamTypeDescription
pathstringto a local directory
[options]ObjectOptions object
options.includeExternalModelsbooleanIf true, external models are written to the file system. Defaults to true

baseModelManager.getModels([options]) ⇒ Array.<{name:string, content:string}>

Gets all the Concerto models

Kind: instance method of BaseModelManager
Returns: Array.<{name:string, content:string}> - the name and content of each CTO file

ParamTypeDescription
[options]ObjectOptions object
options.includeExternalModelsbooleanIf true, external models are written to the file system. Defaults to true

baseModelManager.clearModelFiles()

Remove all registered Concerto files

Kind: instance method of BaseModelManager

baseModelManager.getModelFile(namespace) ⇒ ModelFile

Get the ModelFile associated with a namespace

Kind: instance method of BaseModelManager
Returns: ModelFile - registered ModelFile for the namespace or null

ParamTypeDescription
namespacestringthe namespace containing the ModelFile

baseModelManager.getNamespaces() ⇒ Array.<string>

Get the namespaces registered with the ModelManager.

Kind: instance method of BaseModelManager
Returns: Array.<string> - namespaces - the namespaces that have been registered.

baseModelManager.getType(qualifiedName) ⇒ ClassDeclaration

Look up a type in all registered namespaces.

Kind: instance method of BaseModelManager
Returns: ClassDeclaration - - the class declaration for the specified type.
Throws:

  • TypeNotFoundException - if the type cannot be found or is a primitive type.
ParamTypeDescription
qualifiedNamestringfully qualified type name.

baseModelManager.getAssetDeclarations() ⇒ Array.<AssetDeclaration>

Get the AssetDeclarations defined in this model manager

Kind: instance method of BaseModelManager
Returns: Array.<AssetDeclaration> - the AssetDeclarations defined in the model manager

baseModelManager.getTransactionDeclarations() ⇒ Array.<TransactionDeclaration>

Get the TransactionDeclarations defined in this model manager

Kind: instance method of BaseModelManager
Returns: Array.<TransactionDeclaration> - the TransactionDeclarations defined in the model manager

baseModelManager.getEventDeclarations() ⇒ Array.<EventDeclaration>

Get the EventDeclarations defined in this model manager

Kind: instance method of BaseModelManager
Returns: Array.<EventDeclaration> - the EventDeclaration defined in the model manager

baseModelManager.getParticipantDeclarations() ⇒ Array.<ParticipantDeclaration>

Get the ParticipantDeclarations defined in this model manager

Kind: instance method of BaseModelManager
Returns: Array.<ParticipantDeclaration> - the ParticipantDeclaration defined in the model manager

baseModelManager.getEnumDeclarations() ⇒ Array.<EnumDeclaration>

Get the EnumDeclarations defined in this model manager

Kind: instance method of BaseModelManager
Returns: Array.<EnumDeclaration> - the EnumDeclaration defined in the model manager

baseModelManager.getConceptDeclarations() ⇒ Array.<ConceptDeclaration>

Get the Concepts defined in this model manager

Kind: instance method of BaseModelManager
Returns: Array.<ConceptDeclaration> - the ConceptDeclaration defined in the model manager

baseModelManager.getFactory() ⇒ Factory

Get a factory for creating new instances of types defined in this model manager.

Kind: instance method of BaseModelManager
Returns: Factory - A factory for creating new instances of types defined in this model manager.

baseModelManager.getSerializer() ⇒ Serializer

Get a serializer for serializing instances of types defined in this model manager.

Kind: instance method of BaseModelManager
Returns: Serializer - A serializer for serializing instances of types defined in this model manager.

baseModelManager.getDecoratorFactories() ⇒ Array.<DecoratorFactory>

Get the decorator factories for this model manager.

Kind: instance method of BaseModelManager
Returns: Array.<DecoratorFactory> - The decorator factories for this model manager.

baseModelManager.addDecoratorFactory(factory)

Add a decorator factory to this model manager.

Kind: instance method of BaseModelManager

ParamTypeDescription
factoryDecoratorFactoryThe decorator factory to add to this model manager.

baseModelManager.derivesFrom(fqt1, fqt2) ⇒ boolean

Checks if this fully qualified type name is derived from another.

Kind: instance method of BaseModelManager
Returns: boolean - True if this instance is an instance of the specified fully qualified type name, false otherwise.

ParamTypeDescription
fqt1stringThe fully qualified type name to check.
fqt2stringThe fully qualified type name it is may be derived from.

baseModelManager.resolveMetaModel(metaModel) ⇒ object

Resolve the namespace for names in the metamodel

Kind: instance method of BaseModelManager
Returns: object - the resolved metamodel

ParamTypeDescription
metaModelobjectthe MetaModel

baseModelManager.fromAst(ast)

Populates the model manager from a models metamodel AST

Kind: instance method of BaseModelManager

ParamTypeDescription
ast*the metamodel

baseModelManager.getAst([resolve]) ⇒ *

Get the full ast (metamodel instances) for a modelmanager

Kind: instance method of BaseModelManager
Returns: * - the metamodel

ParamTypeDescription
[resolve]booleanwhether to resolve names

concerto-core.Concerto

Runtime API for Concerto.

Kind: static class of concerto-core

new Concerto(modelManager)

Create a Concerto instance.

ParamTypeDescription
modelManagerModelManagerThe this.modelManager to use for validation etc.

concerto.validate(obj, [options])

Validates the instance against its model.

Kind: instance method of Concerto
Throws:

  • Error - if the instance if invalid with respect to the model
ParamTypeDescription
obj*the input object
[options]*the validation options

concerto.getModelManager() ⇒ ModelManager

Returns the model manager

Kind: instance method of Concerto
Returns: ModelManager - the model manager associated with this Concerto class

concerto.isObject(obj) ⇒ boolean

Returns true if the input object is a Concerto object

Kind: instance method of Concerto
Returns: boolean - true if the object has a $class attribute

ParamTypeDescription
obj*the input object

concerto.getTypeDeclaration(obj) ⇒ *

Returns the ClassDeclaration for an object, or throws an exception

Kind: instance method of Concerto
Returns: * - the ClassDeclaration for the type
Throw: Error an error if the object does not have a $class attribute

ParamTypeDescription
obj*the input object

concerto.getIdentifier(obj) ⇒ string

Gets the identifier for an object

Kind: instance method of Concerto
Returns: string - The identifier for this object

ParamTypeDescription
obj*the input object

concerto.isIdentifiable(obj) ⇒ boolean

Returns true if the object has an identifier

Kind: instance method of Concerto
Returns: boolean - is the object has been defined with an identifier in the model

ParamTypeDescription
obj*the input object

concerto.isRelationship(obj) ⇒ boolean

Returns true if the object is a relationship. Relationships are strings of the form: 'resource:org.accordproject.Order#001' (a relationship) to the 'Order' identifiable, with the id 001.

Kind: instance method of Concerto
Returns: boolean - true if the object is a relationship

ParamTypeDescription
obj*the input object

concerto.setIdentifier(obj, id) ⇒ *

Set the identifier for an object. This method does not mutate the input object, use the return object.

Kind: instance method of Concerto
Returns: * - the input object with the identifier set

ParamTypeDescription
obj*the input object
idstringthe new identifier

concerto.getFullyQualifiedIdentifier(obj) ⇒ string

Returns the fully qualified identifier for an object

Kind: instance method of Concerto
Returns: string - the fully qualified identifier

ParamTypeDescription
obj*the input object

concerto.toURI(obj) ⇒ string

Returns a URI for an object

Kind: instance method of Concerto
Returns: string - the URI for the object

ParamTypeDescription
obj*the input object

concerto.fromURI(uri) ⇒ *

Parses a resource URI into typeDeclaration and id components.

Kind: instance method of Concerto
Returns: * - an object with typeDeclaration and id attributes
Throws:

  • Error if the URI is invalid or the type does not exist in the model manager
ParamTypeDescription
uristringthe input URI

concerto.getType(obj) ⇒ string

Returns the short type name

Kind: instance method of Concerto
Returns: string - the short type name

ParamTypeDescription
obj*the input object

concerto.getNamespace(obj) ⇒ string

Returns the namespace for the object

Kind: instance method of Concerto
Returns: string - the namespace

ParamTypeDescription
obj*the input object

concerto-core.DecoratorManager

Utility functions to work with DecoratorCommandSet

Kind: static class of concerto-core

DecoratorManager.decorateModels(modelManager, decoratorCommandSet) ⇒ ModelManager

Applies all the decorator commands from the DecoratorCommandSet to the ModelManager.

Kind: static method of DecoratorManager
Returns: ModelManager - a new model manager with the decorations applied

ParamTypeDescription
modelManagerModelManagerthe input model manager
decoratorCommandSet*the DecoratorCommandSet object

DecoratorManager.falsyOrEqual(test, value) ⇒ Boolean

Compares two values. If the first argument is falsy the function returns true.

Kind: static method of DecoratorManager
Returns: Boolean - true if the lhs is falsy or test === value

ParamTypeDescription
teststring | nullthe value to test (lhs)
valuestringthe value to compare (rhs)

DecoratorManager.applyDecorator(decorated, type, newDecorator)

Applies a decorator to a decorated model element.

Kind: static method of DecoratorManager

ParamTypeDescription
decorated*the type to apply the decorator to
typestringthe command type
newDecorator*the decorator to add

DecoratorManager.executeCommand(namespace, declaration, command)

Executes a Command against a ClassDeclaration, adding decorators to the ClassDeclaration, or its properties, as required.

Kind: static method of DecoratorManager

ParamTypeDescription
namespacestringthe namespace for the declaration
declaration*the class declaration
command*the Command object from the org.accordproject.decoratorcommands model

concerto-core.Factory

Use the Factory to create instances of Resource: transactions, participants and assets.

Kind: static class of concerto-core

new Factory(modelManager)

Create the factory.

ParamTypeDescription
modelManagerModelManagerThe ModelManager to use for this registry

factory.newResource(ns, type, [id], [options]) ⇒ Resource

Create a new Resource with a given namespace, type name and id

Kind: instance method of Factory
Returns: Resource - the new instance
Throws:

  • TypeNotFoundException if the type is not registered with the ModelManager
ParamTypeDescription
nsStringthe namespace of the Resource
typeStringthe type of the Resource
[id]Stringan optional string identifier
[options]Objectan optional set of options
[options.disableValidation]booleanpass true if you want the factory to return a Resource instead of a ValidatedResource. Defaults to false.
[options.generate]StringPass one of:
sample
return a resource instance with generated sample data.
empty
return a resource instance with empty property values.
[options.includeOptionalFields]booleanif options.generate is specified, whether optional fields should be generated.

factory.newConcept(ns, type, [id], [options]) ⇒ Resource

Create a new Concept with a given namespace and type name

Kind: instance method of Factory
Returns: Resource - the new instance
Throws:

  • TypeNotFoundException if the type is not registered with the ModelManager
ParamTypeDescription
nsStringthe namespace of the Concept
typeStringthe type of the Concept
[id]Stringan optional string identifier
[options]Objectan optional set of options
[options.disableValidation]booleanpass true if you want the factory to return a Concept instead of a ValidatedConcept. Defaults to false.
[options.generate]StringPass one of:
sample
return a resource instance with generated sample data.
empty
return a resource instance with empty property values.
[options.includeOptionalFields]booleanif options.generate is specified, whether optional fields should be generated.

factory.newRelationship(ns, type, id) ⇒ Relationship

Create a new Relationship with a given namespace, type and identifier. A relationship is a typed pointer to an instance. I.e the relationship with namespace = 'org.example', type = 'Vehicle' and id = 'ABC' creates a pointer that points at an instance of org.example.Vehicle with the id ABC.

Kind: instance method of Factory
Returns: Relationship - - the new relationship instance
Throws:

  • TypeNotFoundException if the type is not registered with the ModelManager
ParamTypeDescription
nsStringthe namespace of the Resource
typeStringthe type of the Resource
idStringthe identifier

factory.newTransaction(ns, type, [id], [options]) ⇒ Resource

Create a new transaction object. The identifier of the transaction is set to a UUID.

Kind: instance method of Factory
Returns: Resource - A resource for the new transaction.

ParamTypeDescription
nsStringthe namespace of the transaction.
typeStringthe type of the transaction.
[id]Stringan optional string identifier
[options]Objectan optional set of options
[options.generate]StringPass one of:
sample
return a resource instance with generated sample data.
empty
return a resource instance with empty property values.
[options.includeOptionalFields]booleanif options.generate is specified, whether optional fields should be generated.

factory.newEvent(ns, type, [id], [options]) ⇒ Resource

Create a new event object. The identifier of the event is set to a UUID.

Kind: instance method of Factory
Returns: Resource - A resource for the new event.

ParamTypeDescription
nsStringthe namespace of the event.
typeStringthe type of the event.
[id]Stringan optional string identifier
[options]Objectan optional set of options
[options.generate]StringPass one of:
sample
return a resource instance with generated sample data.
empty
return a resource instance with empty property values.
[options.includeOptionalFields]booleanif options.generate is specified, whether optional fields should be generated.

Factory.newId() ⇒ string

Create a new ID for an object.

Kind: static method of Factory
Returns: string - a new ID

concerto-core.AssetDeclaration ⇐ ClassDeclaration

AssetDeclaration defines the schema (aka model or class) for an Asset. It extends ClassDeclaration which manages a set of fields, a super-type and the specification of an identifying field.

Kind: static class of concerto-core
Extends: ClassDeclaration
See: See ClassDeclaration

new AssetDeclaration(modelFile, ast)

Create an AssetDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

assetDeclaration.declarationKind() ⇒ string

Returns the kind of declaration

Kind: instance method of AssetDeclaration
Returns: string - what kind of declaration this is

concerto-core.ClassDeclaration

ClassDeclaration defines the structure (model/schema) of composite data. It is composed of a set of Properties, may have an identifying field, and may have a super-type. A ClassDeclaration is conceptually owned by a ModelFile which defines all the classes that are part of a namespace.

Kind: static abstract class of concerto-core

new ClassDeclaration(modelFile, ast)

Create a ClassDeclaration from an Abstract Syntax Tree. The AST is the result of parsing.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectthe AST created by the parser

classDeclaration.getModelFile() ⇒ ModelFile

Returns the ModelFile that defines this class.

Kind: instance method of ClassDeclaration
Returns: ModelFile - the owning ModelFile
Access: public

classDeclaration._resolveSuperType() ⇒ ClassDeclaration

Resolve the super type on this class and store it as an internal property.

Kind: instance method of ClassDeclaration
Returns: ClassDeclaration - The super type, or null if non specified.

classDeclaration.validate()

Semantic validation of the structure of this class. Subclasses should override this method to impose additional semantic constraints on the contents/relations of fields.

Kind: instance method of ClassDeclaration
Throws:

  • IllegalModelException

Access: protected

classDeclaration.isAbstract() ⇒ boolean

Returns true if this class is declared as abstract in the model file

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is abstract

classDeclaration.getName() ⇒ string

Returns the short name of a class. This name does not include the namespace from the owning ModelFile.

Kind: instance method of ClassDeclaration
Returns: string - the short name of this class

classDeclaration.getNamespace() ⇒ string

Return the namespace of this class.

Kind: instance method of ClassDeclaration
Returns: string - namespace - a namespace.

classDeclaration.getFullyQualifiedName() ⇒ string

Returns the fully qualified name of this class. The name will include the namespace if present.

Kind: instance method of ClassDeclaration
Returns: string - the fully-qualified name of this class

classDeclaration.isIdentified() ⇒ Boolean

Returns true if this class declaration declares an identifying field (system or explicit)

Kind: instance method of ClassDeclaration
Returns: Boolean - true if the class declaration includes an identifier

classDeclaration.isSystemIdentified() ⇒ Boolean

Returns true if this class declaration declares a system identifier $identifier

Kind: instance method of ClassDeclaration
Returns: Boolean - true if the class declaration includes a system identifier

classDeclaration.isExplicitlyIdentified() ⇒ Boolean

Returns true if this class declaration declares an explicit identifier

Kind: instance method of ClassDeclaration
Returns: Boolean - true if the class declaration includes an explicit identifier

classDeclaration.getIdentifierFieldName() ⇒ string

Returns the name of the identifying field for this class. Note that the identifying field may come from a super type.

Kind: instance method of ClassDeclaration
Returns: string - the name of the id field for this class or null if it does not exist

classDeclaration.getOwnProperty(name) ⇒ Property

Returns the field with a given name or null if it does not exist. The field must be directly owned by this class -- the super-type is not introspected.

Kind: instance method of ClassDeclaration
Returns: Property - the field definition or null if it does not exist

ParamTypeDescription
namestringthe name of the field

classDeclaration.getOwnProperties() ⇒ Array.<Property>

Returns the fields directly defined by this class.

Kind: instance method of ClassDeclaration
Returns: Array.<Property> - the array of fields

classDeclaration.getSuperType() ⇒ string

Returns the FQN of the super type for this class or null if this class does not have a super type.

Kind: instance method of ClassDeclaration
Returns: string - the FQN name of the super type or null

classDeclaration.getSuperTypeDeclaration() ⇒ ClassDeclaration

Get the super type class declaration for this class.

Kind: instance method of ClassDeclaration
Returns: ClassDeclaration - the super type declaration, or null if there is no super type.

classDeclaration.getAssignableClassDeclarations() ⇒ Array.<ClassDeclaration>

Get the class declarations for all subclasses of this class, including this class.

Kind: instance method of ClassDeclaration
Returns: Array.<ClassDeclaration> - subclass declarations.

classDeclaration.getDirectSubclasses() ⇒ Array.<ClassDeclaration>

Get the class declarations for just the direct subclasses of this class, excluding this class.

Kind: instance method of ClassDeclaration
Returns: Array.<ClassDeclaration> - direct subclass declarations.

classDeclaration.getAllSuperTypeDeclarations() ⇒ Array.<ClassDeclaration>

Get all the super-type declarations for this type.

Kind: instance method of ClassDeclaration
Returns: Array.<ClassDeclaration> - super-type declarations.

classDeclaration.getProperty(name) ⇒ Property

Returns the property with a given name or null if it does not exist. Fields defined in super-types are also introspected.

Kind: instance method of ClassDeclaration
Returns: Property - the field, or null if it does not exist

ParamTypeDescription
namestringthe name of the field

classDeclaration.getProperties() ⇒ Array.<Property>

Returns the properties defined in this class and all super classes.

Kind: instance method of ClassDeclaration
Returns: Array.<Property> - the array of fields

classDeclaration.getNestedProperty(propertyPath) ⇒ Property

Get a nested property using a dotted property path

Kind: instance method of ClassDeclaration
Returns: Property - the property
Throws:

  • IllegalModelException if the property path is invalid or the property does not exist
ParamTypeDescription
propertyPathstringThe property name or name with nested structure e.g a.b.c

classDeclaration.toString() ⇒ String

Returns the string representation of this class

Kind: instance method of ClassDeclaration
Returns: String - the string representation of the class

classDeclaration.isAsset() ⇒ boolean

Returns true if this class is the definition of an asset.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

classDeclaration.isParticipant() ⇒ boolean

Returns true if this class is the definition of a participant.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

classDeclaration.isTransaction() ⇒ boolean

Returns true if this class is the definition of a transaction.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

classDeclaration.isEvent() ⇒ boolean

Returns true if this class is the definition of an event.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

classDeclaration.isConcept() ⇒ boolean

Returns true if this class is the definition of a concept.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

classDeclaration.isEnum() ⇒ boolean

Returns true if this class is the definition of a enum.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

classDeclaration.isClassDeclaration() ⇒ boolean

Returns true if this class is the definition of a enum.

Kind: instance method of ClassDeclaration
Returns: boolean - true if the class is an asset

concerto-core.ConceptDeclaration ⇐ ClassDeclaration

ConceptDeclaration defines the schema (aka model or class) for an Concept. It extends ClassDeclaration which manages a set of fields, a super-type and the specification of an identifying field.

Kind: static class of concerto-core
Extends: ClassDeclaration
See: ClassDeclaration

new ConceptDeclaration(modelFile, ast)

Create a ConceptDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

conceptDeclaration.declarationKind() ⇒ string

Returns the kind of declaration

Kind: instance method of ConceptDeclaration
Returns: string - what kind of declaration this is

concerto-core.Decorator

Decorator encapsulates a decorator (annotation) on a class or property.

Kind: static class of concerto-core

new Decorator(parent, ast)

Create a Decorator.

Throws:

  • IllegalModelException
ParamTypeDescription
parentClassDeclaration | Propertythe owner of this property
astObjectThe AST created by the parser

decorator.getParent() ⇒ ClassDeclaration | Property

Returns the owner of this property

Kind: instance method of Decorator
Returns: ClassDeclaration | Property - the parent class or property declaration

decorator.getName() ⇒ string

Returns the name of a decorator

Kind: instance method of Decorator
Returns: string - the name of this decorator

decorator.getArguments() ⇒ Array.<object>

Returns the arguments for this decorator

Kind: instance method of Decorator
Returns: Array.<object> - the arguments for this decorator

decorator.isDecorator() ⇒ boolean

Returns true if this class is the definition of a decorator.

Kind: instance method of Decorator
Returns: boolean - true if the class is a decorator

concerto-core.DecoratorFactory

An interface for a class that processes a decorator and returns a specific implementation class for that decorator.

Kind: static class of concerto-core

decoratorFactory.newDecorator(parent, ast) ⇒ Decorator

Process the decorator, and return a specific implementation class for that decorator, or return null if this decorator is not handled by this processor.

Kind: instance abstract method of DecoratorFactory
Returns: Decorator - The decorator.

ParamTypeDescription
parentClassDeclaration | Propertythe owner of this property
astObjectThe AST created by the parser

concerto-core.EnumDeclaration ⇐ ClassDeclaration

EnumDeclaration defines an enumeration of static values.

Kind: static class of concerto-core
Extends: ClassDeclaration
See: See ClassDeclaration

new EnumDeclaration(modelFile, ast)

Create an EnumDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

enumDeclaration.toString() ⇒ String

Returns the string representation of this class

Kind: instance method of EnumDeclaration
Returns: String - the string representation of the class

enumDeclaration.declarationKind() ⇒ string

Returns the kind of declaration

Kind: instance method of EnumDeclaration
Returns: string - what kind of declaration this is

concerto-core.EnumValueDeclaration ⇐ Property

Class representing a value from a set of enumerated values

Kind: static class of concerto-core
Extends: Property
See: See Property

new EnumValueDeclaration(parent, ast)

Create a EnumValueDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
parentClassDeclarationThe owner of this property
astObjectThe AST created by the parser

enumValueDeclaration.isEnumValue() ⇒ boolean

Returns true if this class is the definition of a enum value.

Kind: instance method of EnumValueDeclaration
Returns: boolean - true if the class is an enum value

concerto-core.EventDeclaration ⇐ ClassDeclaration

Class representing the definition of an Event.

Kind: static class of concerto-core
Extends: ClassDeclaration
See: See ClassDeclaration

new EventDeclaration(modelFile, ast)

Create an EventDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

eventDeclaration.declarationKind() ⇒ string

Returns the kind of declaration

Kind: instance method of EventDeclaration
Returns: string - what kind of declaration this is

concerto-core.IdentifiedDeclaration ⇐ ClassDeclaration

IdentifiedDeclaration

Kind: static abstract class of concerto-core
Extends: ClassDeclaration
See: See ClassDeclaration

new IdentifiedDeclaration(modelFile, ast)

Create an IdentifiedDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

concerto-core.IllegalModelException ⇐ BaseFileException

Exception throws when a composer file is semantically invalid

Kind: static class of concerto-core
Extends: BaseFileException
See: See BaseFileException

new IllegalModelException(message, [modelFile], [fileLocation], [component])

Create an IllegalModelException.

ParamTypeDescription
messagestringthe message for the exception
[modelFile]ModelFilethe modelfile associated with the exception
[fileLocation]Objectlocation details of the error within the model file.
fileLocation.start.linenumberstart line of the error location.
fileLocation.start.columnnumberstart column of the error location.
fileLocation.end.linenumberend line of the error location.
fileLocation.end.columnnumberend column of the error location.
[component]stringthe component which throws this error

concerto-core.Introspector

Provides access to the structure of transactions, assets and participants.

Kind: static class of concerto-core

new Introspector(modelManager)

Create the Introspector.

ParamTypeDescription
modelManagerModelManagerthe ModelManager that backs this Introspector

introspector.getClassDeclarations() ⇒ Array.<ClassDeclaration>

Returns all the class declarations for the business network.

Kind: instance method of Introspector
Returns: Array.<ClassDeclaration> - the array of class declarations

introspector.getClassDeclaration(fullyQualifiedTypeName) ⇒ ClassDeclaration

Returns the class declaration with the given fully qualified name. Throws an error if the class declaration does not exist.

Kind: instance method of Introspector
Returns: ClassDeclaration - the class declaration
Throws:

  • Error if the class declaration does not exist
ParamTypeDescription
fullyQualifiedTypeNameStringthe fully qualified name of the type

concerto-core.ModelFile

Class representing a Model File. A Model File contains a single namespace and a set of model elements: assets, transactions etc.

Kind: static class of concerto-core

new ModelFile(modelManager, ast, [definitions], [fileName])

Create a ModelFile. This should only be called by framework code. Use the ModelManager to manage ModelFiles.

Throws:

  • IllegalModelException
ParamTypeDescription
modelManagerModelManagerthe ModelManager that manages this ModelFile
astobjectThe abstract syntax tree of the model as a JSON object.
[definitions]stringThe optional CTO model as a string.
[fileName]stringThe optional filename for this modelfile

modelFile.getModelFile() ⇒ ModelFile

Returns the ModelFile that defines this class.

Kind: instance method of ModelFile
Returns: ModelFile - the owning ModelFile
Access: protected

modelFile.isModelFile() ⇒ boolean

Returns true

Kind: instance method of ModelFile
Returns: boolean - true

modelFile.getVersion() ⇒ string

Returns the semantic version

Kind: instance method of ModelFile
Returns: string - the semantic version or null if the namespace for the model file is unversioned

modelFile.isSystemModelFile() ⇒ Boolean

Returns true if the ModelFile is a system namespace

Kind: instance method of ModelFile
Returns: Boolean - true if this is a system model file

modelFile.isExternal() ⇒ boolean

Returns true if this ModelFile was downloaded from an external URI.

Kind: instance method of ModelFile
Returns: boolean - true iff this ModelFile was downloaded from an external URI

modelFile.getModelManager() ⇒ ModelManager

Returns the ModelManager associated with this ModelFile

Kind: instance method of ModelFile
Returns: ModelManager - The ModelManager for this ModelFile

modelFile.getImports() ⇒ Array.<string>

Returns the types that have been imported into this ModelFile.

Kind: instance method of ModelFile
Returns: Array.<string> - The array of imports for this ModelFile

modelFile.validate()

Validates the ModelFile.

Kind: instance method of ModelFile
Throws:

  • IllegalModelException if the model is invalid

Access: protected

modelFile.isDefined(type) ⇒ boolean

Returns true if the type is defined in the model file

Kind: instance method of ModelFile
Returns: boolean - true if the type (asset or transaction) is defined

ParamTypeDescription
typestringthe name of the type

modelFile.getLocalType(type) ⇒ ClassDeclaration

Returns the type with the specified name or null

Kind: instance method of ModelFile
Returns: ClassDeclaration - the ClassDeclaration, or null if the type does not exist

ParamTypeDescription
typestringthe short OR FQN name of the type

modelFile.getAssetDeclaration(name) ⇒ AssetDeclaration

Get the AssetDeclarations defined in this ModelFile or null

Kind: instance method of ModelFile
Returns: AssetDeclaration - the AssetDeclaration with the given short name

ParamTypeDescription
namestringthe name of the type

modelFile.getTransactionDeclaration(name) ⇒ TransactionDeclaration

Get the TransactionDeclaration defined in this ModelFile or null

Kind: instance method of ModelFile
Returns: TransactionDeclaration - the TransactionDeclaration with the given short name

ParamTypeDescription
namestringthe name of the type

modelFile.getEventDeclaration(name) ⇒ EventDeclaration

Get the EventDeclaration defined in this ModelFile or null

Kind: instance method of ModelFile
Returns: EventDeclaration - the EventDeclaration with the given short name

ParamTypeDescription
namestringthe name of the type

modelFile.getParticipantDeclaration(name) ⇒ ParticipantDeclaration

Get the ParticipantDeclaration defined in this ModelFile or null

Kind: instance method of ModelFile
Returns: ParticipantDeclaration - the ParticipantDeclaration with the given short name

ParamTypeDescription
namestringthe name of the type

modelFile.getNamespace() ⇒ string

Get the Namespace for this model file.

Kind: instance method of ModelFile
Returns: string - The Namespace for this model file

modelFile.getName() ⇒ string

Get the filename for this model file. Note that this may be null.

Kind: instance method of ModelFile
Returns: string - The filename for this model file

modelFile.getAssetDeclarations() ⇒ Array.<AssetDeclaration>

Get the AssetDeclarations defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<AssetDeclaration> - the AssetDeclarations defined in the model file

modelFile.getTransactionDeclarations() ⇒ Array.<TransactionDeclaration>

Get the TransactionDeclarations defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<TransactionDeclaration> - the TransactionDeclarations defined in the model file

modelFile.getEventDeclarations() ⇒ Array.<EventDeclaration>

Get the EventDeclarations defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<EventDeclaration> - the EventDeclarations defined in the model file

modelFile.getParticipantDeclarations() ⇒ Array.<ParticipantDeclaration>

Get the ParticipantDeclarations defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<ParticipantDeclaration> - the ParticipantDeclaration defined in the model file

modelFile.getConceptDeclarations() ⇒ Array.<ConceptDeclaration>

Get the ConceptDeclarations defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<ConceptDeclaration> - the ParticipantDeclaration defined in the model file

modelFile.getEnumDeclarations() ⇒ Array.<EnumDeclaration>

Get the EnumDeclarations defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<EnumDeclaration> - the EnumDeclaration defined in the model file

modelFile.getScalarDeclarations() ⇒ Array.<ScalarDeclaration>

Get the ScalarDeclaration defined in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<ScalarDeclaration> - the ScalarDeclaration defined in the model file

modelFile.getDeclarations(type) ⇒ Array.<Object>

Get the instances of a given type in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<Object> - the ClassDeclaration defined in the model file

ParamTypeDescription
typefunctionthe type of the declaration

modelFile.getAllDeclarations() ⇒ Array.<ClassDeclaration>

Get all declarations in this ModelFile

Kind: instance method of ModelFile
Returns: Array.<ClassDeclaration> - the ClassDeclarations defined in the model file

modelFile.getDefinitions() ⇒ string

Get the definitions for this model.

Kind: instance method of ModelFile
Returns: string - The definitions for this model.

modelFile.getAst() ⇒ object

Get the ast for this model.

Kind: instance method of ModelFile
Returns: object - The definitions for this model.

modelFile.getConcertoVersion() ⇒ string

Get the expected concerto version

Kind: instance method of ModelFile
Returns: string - The semver range for compatible concerto versions

modelFile.isCompatibleVersion()

Check whether this modelfile is compatible with the concerto version

Kind: instance method of ModelFile

modelFile.enforceImportVersioning(imp)

Verifies that an import is versioned if the strict option has been set on the Model Manager

Kind: instance method of ModelFile

ParamTypeDescription
imp*the import to validate

concerto-core.ParticipantDeclaration ⇐ ClassDeclaration

Class representing the definition of a Participant.

Kind: static class of concerto-core
Extends: ClassDeclaration
See: See ClassDeclaration

new ParticipantDeclaration(modelFile, ast)

Create an ParticipantDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

participantDeclaration.declarationKind() ⇒ string

Returns the kind of declaration

Kind: instance method of ParticipantDeclaration
Returns: string - what kind of declaration this is

concerto-core.Property

Property representing an attribute of a class declaration, either a Field or a Relationship.

Kind: static class of concerto-core

new Property(parent, ast)

Create a Property.

Throws:

  • IllegalModelException
ParamTypeDescription
parentClassDeclarationthe owner of this property
astObjectThe AST created by the parser

property.getModelFile() ⇒ ModelFile

Returns the ModelFile that defines this class.

Kind: instance method of Property
Returns: ModelFile - the owning ModelFile
Access: public

property.getParent() ⇒ ClassDeclaration

Returns the owner of this property

Kind: instance method of Property
Returns: ClassDeclaration - the parent class declaration

property.validate(classDecl)

Validate the property

Kind: instance method of Property
Throws:

  • IllegalModelException

Access: protected

ParamTypeDescription
classDeclClassDeclarationthe class declaration of the property

property.getName() ⇒ string

Returns the name of a property

Kind: instance method of Property
Returns: string - the name of this field

property.getType() ⇒ string

Returns the type of a property

Kind: instance method of Property
Returns: string - the type of this field

property.isOptional() ⇒ boolean

Returns true if the field is optional

Kind: instance method of Property
Returns: boolean - true if the field is optional

property.getFullyQualifiedTypeName() ⇒ string

Returns the fully qualified type name of a property

Kind: instance method of Property
Returns: string - the fully qualified type of this property

property.getFullyQualifiedName() ⇒ string

Returns the fully name of a property (ns + class name + property name)

Kind: instance method of Property
Returns: string - the fully qualified name of this property

property.getNamespace() ⇒ string

Returns the namespace of the parent of this property

Kind: instance method of Property
Returns: string - the namespace of the parent of this property

property.isArray() ⇒ boolean

Returns true if the field is declared as an array type

Kind: instance method of Property
Returns: boolean - true if the property is an array type

property.isTypeEnum() ⇒ boolean

Returns true if the field is declared as an enumerated value

Kind: instance method of Property
Returns: boolean - true if the property is an enumerated value

property.isPrimitive() ⇒ boolean

Returns true if this property is a primitive type.

Kind: instance method of Property
Returns: boolean - true if the property is a primitive type.

concerto-core.RelationshipDeclaration ⇐ Property

Class representing a relationship between model elements

Kind: static class of concerto-core
Extends: Property
See: See Property

new RelationshipDeclaration(parent, ast)

Create a Relationship.

Throws:

  • IllegalModelException
ParamTypeDescription
parentClassDeclarationThe owner of this property
astObjectThe AST created by the parser

relationshipDeclaration.validate(classDecl)

Validate the property

Kind: instance method of RelationshipDeclaration
Throws:

  • IllegalModelException

Access: protected

ParamTypeDescription
classDeclClassDeclarationthe class declaration of the property

relationshipDeclaration.toString() ⇒ String

Returns a string representation of this property

Kind: instance method of RelationshipDeclaration
Returns: String - the string version of the property.

relationshipDeclaration.isRelationship() ⇒ boolean

Returns true if this class is the definition of a relationship.

Kind: instance method of RelationshipDeclaration
Returns: boolean - true if the class is a relationship

concerto-core.ScalarDeclaration

ScalarDeclaration defines the structure (model/schema) of composite data. It is composed of a set of Properties, may have an identifying field, and may have a super-type. A ScalarDeclaration is conceptually owned by a ModelFile which defines all the classes that are part of a namespace.

Kind: static abstract class of concerto-core

new ScalarDeclaration(modelFile, ast)

Create a ScalarDeclaration from an Abstract Syntax Tree. The AST is the result of parsing.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectthe AST created by the parser

scalarDeclaration.getModelFile() ⇒ ModelFile

Returns the ModelFile that defines this class.

Kind: instance method of ScalarDeclaration
Returns: ModelFile - the owning ModelFile
Access: public

scalarDeclaration.validate()

Semantic validation of the structure of this class. Subclasses should override this method to impose additional semantic constraints on the contents/relations of fields.

Kind: instance method of ScalarDeclaration
Throws:

  • IllegalModelException

Access: protected

scalarDeclaration.getName() ⇒ string

Returns the short name of a class. This name does not include the namespace from the owning ModelFile.

Kind: instance method of ScalarDeclaration
Returns: string - the short name of this class

scalarDeclaration.getNamespace() ⇒ string

Return the namespace of this class.

Kind: instance method of ScalarDeclaration
Returns: string - namespace - a namespace.

scalarDeclaration.getFullyQualifiedName() ⇒ string

Returns the fully qualified name of this class. The name will include the namespace if present.

Kind: instance method of ScalarDeclaration
Returns: string - the fully-qualified name of this class

scalarDeclaration.isIdentified() ⇒ Boolean

Returns false as scalars are never identified.

Kind: instance method of ScalarDeclaration
Returns: Boolean - false as scalars are never identified

scalarDeclaration.isSystemIdentified() ⇒ Boolean

Returns false as scalars are never identified.

Kind: instance method of ScalarDeclaration
Returns: Boolean - false as scalars are never identified

scalarDeclaration.getIdentifierFieldName() ⇒ null

Returns null as scalars are never identified.

Kind: instance method of ScalarDeclaration
Returns: null - null, as scalars are never identified

scalarDeclaration.getType() ⇒ string

Returns the FQN of the super type for this class or null if this class does not have a super type.

Kind: instance method of ScalarDeclaration
Returns: string - the FQN name of the super type or null

scalarDeclaration.getSuperType()

Throws an error as scalars do not have supertypes.

Kind: instance method of ScalarDeclaration

scalarDeclaration.getSuperTypeDeclaration() ⇒ ScalarDeclaration | null

Get the super type class declaration for this class.

Kind: instance method of ScalarDeclaration
Returns: ScalarDeclaration | null - the super type declaration, or null if there is no super type.

scalarDeclaration.getValidator() ⇒ Validator

Returns the validator string for this scalar definition

Kind: instance method of ScalarDeclaration
Returns: Validator - the validator for the field or null

scalarDeclaration.getDefaultValue() ⇒ string | number | null

Returns the default value for the field or null

Kind: instance method of ScalarDeclaration
Returns: string | number | null - the default value for the field or null

scalarDeclaration.toString() ⇒ String

Returns the string representation of this class

Kind: instance method of ScalarDeclaration
Returns: String - the string representation of the class

scalarDeclaration.isAbstract() ⇒ boolean

Returns true if this class is abstract.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is abstract

scalarDeclaration.isAsset() ⇒ boolean

Returns true if this class is the definition of an asset.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is an asset

scalarDeclaration.isParticipant() ⇒ boolean

Returns true if this class is the definition of a participant.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is a participant

scalarDeclaration.isTransaction() ⇒ boolean

Returns true if this class is the definition of a transaction.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is a transaction

scalarDeclaration.isEvent() ⇒ boolean

Returns true if this class is the definition of an event.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is an event

scalarDeclaration.isConcept() ⇒ boolean

Returns true if this class is the definition of a concept.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is a concept

scalarDeclaration.isEnum() ⇒ boolean

Returns true if this class is the definition of an enum.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is an enum

scalarDeclaration.isClassDeclaration() ⇒ boolean

Returns true if this class is the definition of a class declaration.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is a class

scalarDeclaration.isScalarDeclaration() ⇒ boolean

Returns true if this class is the definition of a scalar declaration.

Kind: instance method of ScalarDeclaration
Returns: boolean - true if the class is a scalar

concerto-core.TransactionDeclaration ⇐ ClassDeclaration

Class representing the definition of an Transaction.

Kind: static class of concerto-core
Extends: ClassDeclaration
See: See ClassDeclaration

new TransactionDeclaration(modelFile, ast)

Create an TransactionDeclaration.

Throws:

  • IllegalModelException
ParamTypeDescription
modelFileModelFilethe ModelFile for this class
astObjectThe AST created by the parser

transactionDeclaration.declarationKind() ⇒ string

Returns the kind of declaration

Kind: instance method of TransactionDeclaration
Returns: string - what kind of declaration this is

concerto-core.Identifiable ⇐ Typed

Identifiable is an entity with a namespace, type and an identifier. Applications should retrieve instances from Factory This class is abstract.

Kind: static abstract class of concerto-core
Extends: Typed
Access: protected

new Identifiable(modelManager, classDeclaration, ns, type, id, timestamp)

Create an instance.

Note: Only to be called by framework code. Applications should retrieve instances from [Factory](Factory)

ParamTypeDescription
modelManagerModelManagerThe ModelManager for this instance
classDeclarationClassDeclarationThe class declaration for this instance.
nsstringThe namespace this instance.
typestringThe type this instance.
idstringThe identifier of this instance.
timestampstringThe timestamp of this instance

identifiable.getTimestamp() ⇒ string

Get the timestamp of this instance

Kind: instance method of Identifiable
Returns: string - The timestamp for this object

identifiable.getIdentifier() ⇒ string

Get the identifier of this instance

Kind: instance method of Identifiable
Returns: string - The identifier for this object

identifiable.setIdentifier(id)

Set the identifier of this instance

Kind: instance method of Identifiable

ParamTypeDescription
idstringthe new identifier for this object

identifiable.getFullyQualifiedIdentifier() ⇒ string

Get the fully qualified identifier of this instance. (namespace '.' type '#' identifier).

Kind: instance method of Identifiable
Returns: string - the fully qualified identifier of this instance

identifiable.toString() ⇒ String

Returns the string representation of this class

Kind: instance method of Identifiable
Returns: String - the string representation of the class

identifiable.isRelationship() ⇒ boolean

Determine if this identifiable is a relationship.

Kind: instance method of Identifiable
Returns: boolean - True if this identifiable is a relationship, false if not.

identifiable.isResource() ⇒ boolean

Determine if this identifiable is a resource.

Kind: instance method of Identifiable
Returns: boolean - True if this identifiable is a resource, false if not.

identifiable.toURI() ⇒ String

Returns a URI representation of a reference to this identifiable

Kind: instance method of Identifiable
Returns: String - the URI for the identifiable

concerto-core.Resource ⇐ Identifiable

Resource is an instance that has a type. The type of the resource specifies a set of properites (which themselves have types).

Type information in Concerto is used to validate the structure of Resource instances and for serialization.

Resources are used in Concerto to represent Assets, Participants, Transactions and other domain classes that can be serialized for long-term persistent storage.

Kind: static class of concerto-core
Extends: Identifiable
Access: public
See: See Resource

new Resource(modelManager, classDeclaration, ns, type, id, timestamp)

This constructor should not be called directly.

Note: Only to be called by framework code. Applications should retrieve instances from [Factory](Factory)

ParamTypeDescription
modelManagerModelManagerThe ModelManager for this instance
classDeclarationClassDeclarationThe class declaration for this instance.
nsstringThe namespace this instance.
typestringThe type this instance.
idstringThe identifier of this instance.
timestampstringThe timestamp of this instance

resource.toString() ⇒ String

Returns the string representation of this class

Kind: instance method of Resource
Returns: String - the string representation of the class

resource.isResource() ⇒ boolean

Determine if this identifiable is a resource.

Kind: instance method of Resource
Returns: boolean - True if this identifiable is a resource, false if not.

resource.isConcept() ⇒ boolean

Determine if this identifiable is a concept.

Kind: instance method of Resource
Returns: boolean - True if this identifiable is a concept, false if not.

resource.isIdentifiable() ⇒ boolean

Determine if this object is identifiable.

Kind: instance method of Resource
Returns: boolean - True if this object has an identifiying field false if not.

resource.toJSON() ⇒ Object

Serialize this resource into a JavaScript object suitable for serialization to JSON, using the default options for the serializer. If you need to set additional options for the serializer, use the Serializer#toJSON method instead.

Kind: instance method of Resource
Returns: Object - A JavaScript object suitable for serialization to JSON.

concerto-core.Typed

Object is an instance with a namespace and a type.

This class is abstract.

Kind: static abstract class of concerto-core
Access: protected

new Typed(modelManager, classDeclaration, ns, type)

Create an instance.

Note: Only to be called by framework code. Applications should retrieve instances from [Factory](Factory)

ParamTypeDescription
modelManagerModelManagerThe ModelManager for this instance
classDeclarationClassDeclarationThe class declaration for this instance.
nsstringThe namespace this instance.
typestringThe type this instance.

typed.getType() ⇒ string

Get the type of the instance (a short name, not including namespace).

Kind: instance method of Typed
Returns: string - The type of this object

typed.getFullyQualifiedType() ⇒ string

Get the fully-qualified type name of the instance (including namespace).

Kind: instance method of Typed
Returns: string - The fully-qualified type name of this object

typed.getNamespace() ⇒ string

Get the namespace of the instance.

Kind: instance method of Typed
Returns: string - The namespace of this object

typed.setPropertyValue(propName, value)

Sets a property on this Resource

Kind: instance method of Typed

ParamTypeDescription
propNamestringthe name of the field
valuestringthe value of the property

typed.addArrayValue(propName, value)

Adds a value to an array property on this Resource

Kind: instance method of Typed

ParamTypeDescription
propNamestringthe name of the field
valuestringthe value of the property

typed.instanceOf(fqt) ⇒ boolean

Check to see if this instance is an instance of the specified fully qualified type name.

Kind: instance method of Typed
Returns: boolean - True if this instance is an instance of the specified fully qualified type name, false otherwise.

ParamTypeDescription
fqtStringThe fully qualified type name.

typed.toJSON()

Overriden to prevent people accidentally converting a resource to JSON without using the Serializer.

Kind: instance method of Typed
Access: protected

concerto-core.ModelLoader

Create a ModelManager from model files, with an optional system model.

If a ctoFile is not provided, the Accord Project system model is used.

Kind: static class of concerto-core

ModelLoader.loadModelManager(ctoFiles, options) ⇒ Promise.<ModelManager>

Load models in a new model manager

Kind: static method of ModelLoader
Returns: Promise.<ModelManager> - the model manager

ParamTypeDescription
ctoFilesArray.<string>the CTO files (can be local file paths or URLs)
optionsobjectoptional parameters
[options.offline]booleando not resolve external models
[options.strict]booleandisallow unversioned namespaces
[options.utcOffset]numberUTC Offset for this execution

ModelLoader.loadModelManagerFromModelFiles(modelFiles, [fileNames], options) ⇒ Promise.<ModelManager>

Load system and models in a new model manager from model files objects

Kind: static method of ModelLoader
Returns: Promise.<ModelManager> - the model manager

ParamTypeDescription
modelFilesArray.<object>An array of Concerto files as strings or ModelFile objects.
[fileNames]Array.<string>An optional array of file names to associate with the model files
optionsobjectoptional parameters
[options.offline]booleando not resolve external models
[options.strict]booleandisallow unversioned namespaces
[options.utcOffset]numberUTC Offset for this execution

concerto-core.ModelManager

Manages the Concerto model files in CTO format.

The structure of Resources (Assets, Transactions, Participants) is modelled in a set of Concerto files. The contents of these files are managed by the 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 addModelFile method to register the Concerto file(s) with the ModelManager.

Kind: static class of concerto-core

new ModelManager([options])

Create the ModelManager.

ParamTypeDescription
[options]objectModelManager options, also passed to Serializer
[options.strict]booleanrequire versioned namespaces and imports
[options.regExp]ObjectAn alternative regular expression engine.

modelManager.addCTOModel(cto, [fileName], [disableValidation]) ⇒ ModelFile

Adds a model in CTO format to the ModelManager. This is a convenience function equivalent to addModel but useful since it avoids having to copy the input CTO.

Kind: instance method of ModelManager
Returns: ModelFile - The newly added model file (internal).
Throws:

  • IllegalModelException
ParamTypeDescription
ctostringa cto string
[fileName]stringan optional file name to associate with the model file
[disableValidation]booleanIf true then the model files are not validated

concerto-core.SecurityException ⇐ BaseException

Class representing a security exception

Kind: static class of concerto-core
Extends: BaseException
See: See BaseException

new SecurityException(message)

Create the SecurityException.

ParamTypeDescription
messagestringThe exception message.

concerto-core.Serializer

Serialize Resources instances to/from various formats for long-term storage (e.g. on the blockchain).

Kind: static class of concerto-core

new Serializer(factory, modelManager, [options])

Create a Serializer.

ParamTypeDescription
factoryFactoryThe Factory to use to create instances
modelManagerModelManagerThe ModelManager to use for validation etc.
[options]objectSerializer options

serializer.setDefaultOptions(newDefaultOptions)

Set the default options for the serializer.

Kind: instance method of Serializer

ParamTypeDescription
newDefaultOptionsObjectThe new default options for the serializer.

serializer.toJSON(resource, [options]) ⇒ Object

Convert a [Resource](Resource) to a JavaScript object suitable for long-term peristent storage.

Kind: instance method of Serializer
Returns: Object - - The Javascript Object that represents the resource
Throws:

  • Error - throws an exception if resource is not an instance of Resource or fails validation.
ParamTypeDescription
resourceResourceThe instance to convert to JSON
[options]Objectthe optional serialization options.
[options.validate]booleanvalidate the structure of the Resource with its model prior to serialization (default to true)
[options.convertResourcesToRelationships]booleanConvert resources that are specified for relationship fields into relationships, false by default.
[options.permitResourcesForRelationships]booleanPermit resources in the place of relationships (serializing them as resources), false by default.
[options.deduplicateResources]booleanGenerate $id for resources and if a resources appears multiple times in the object graph only the first instance is serialized in full, subsequent instances are replaced with a reference to the $id
[options.convertResourcesToId]booleanConvert resources that are specified for relationship fields into their id, false by default.
[options.utcOffset]numberUTC Offset for DateTime values.

serializer.fromJSON(jsonObject, [options]) ⇒ Resource

Create a Resource from a JavaScript Object representation. The JavaScript Object should have been created by calling the toJSON API.

The Resource is populated based on the JavaScript object.

Kind: instance method of Serializer
Returns: Resource - The new populated resource

ParamTypeDescription
jsonObjectObjectThe JavaScript Object for a Resource
[options]Objectthe optional serialization options
options.acceptResourcesForRelationshipsbooleanhandle JSON objects in the place of strings for relationships, defaults to false.
options.validatebooleanvalidate the structure of the Resource with its model prior to serialization (default to true)
[options.utcOffset]numberUTC Offset for DateTime values.

concerto-core.TypeNotFoundException ⇐ BaseException

Error thrown when a Concerto type does not exist.

Kind: static class of concerto-core
Extends: BaseException
See: see BaseException

new TypeNotFoundException(typeName, message, component)

Constructor. If the optional 'message' argument is not supplied, it will be set to a default value that includes the type name.

ParamTypeDescription
typeNamestringfully qualified type name.
messagestring | undefinederror message.
componentstringthe optional component which throws this error

typeNotFoundException.getTypeName() ⇒ string

Get the name of the type that was not found.

Kind: instance method of TypeNotFoundException
Returns: string - fully qualified type name.

concerto-core.BaseException ⇐ Error

A base class for all Concerto exceptions

Kind: static class of concerto-core
Extends: Error

new BaseException(message, component)

Create the BaseException.

ParamTypeDescription
messagestringThe exception message.
componentstringThe optional component which throws this error.

concerto-core.BaseFileException ⇐ BaseException

Exception throws when a Concerto file is semantically invalid

Kind: static class of concerto-core
Extends: BaseException
See: BaseException

new BaseFileException(message, fileLocation, fullMessage, [fileName], [component])

Create an BaseFileException

ParamTypeDescription
messagestringthe message for the exception
fileLocationstringthe optional file location associated with the exception
fullMessagestringthe optional full message text
[fileName]stringthe file name
[component]stringthe component which throws this error

baseFileException.getFileLocation() ⇒ string

Returns the file location associated with the exception or null

Kind: instance method of BaseFileException
Returns: string - the optional location associated with the exception

baseFileException.getShortMessage() ⇒ string

Returns the error message without the location of the error

Kind: instance method of BaseFileException
Returns: string - the error message

baseFileException.getFileName() ⇒ string

Returns the fileName for the error

Kind: instance method of BaseFileException
Returns: string - the file name or null

concerto-core.FileDownloader

Downloads the transitive closure of a set of model files.

Kind: static class of concerto-core

new FileDownloader(fileLoader, getExternalImports, concurrency)

Create a FileDownloader and bind to a FileLoader.

ParamTypeDefaultDescription
fileLoader*the loader to use to download model files
getExternalImports*a function taking a file and returning new files
concurrencyNumber10the number of model files to download concurrently

fileDownloader.downloadExternalDependencies(files, [options]) ⇒ Promise

Download all external dependencies for an array of model files

Kind: instance method of FileDownloader
Returns: Promise - a promise that resolves to Files[] for the external model files

ParamTypeDescription
filesArray.<File>the model files
[options]ObjectOptions object passed to FileLoaders

fileDownloader.runJob(job, fileLoader) ⇒ Promise

Execute a Job

Kind: instance method of FileDownloader
Returns: Promise - a promise to the job results

ParamTypeDescription
jobObjectthe job to execute
fileLoaderObjectthe loader to use to download model files.

concerto-core.TypedStack

Tracks a stack of typed instances. The type information is used to detect overflow / underflow bugs by the caller. It also performs basic sanity checking on push/pop to make detecting bugs easier.

Kind: static class of concerto-core

new TypedStack(resource)

Create the Stack with the resource at the head.

ParamTypeDescription
resourceObjectthe resource to be put at the head of the stack

typedStack.push(obj, expectedType)

Push a new object.

Kind: instance method of TypedStack

ParamTypeDescription
objObjectthe object being visited
expectedTypeObjectthe expected type of the object being pushed

typedStack.pop(expectedType) ⇒ Object

Push a new object.

Kind: instance method of TypedStack
Returns: Object - the result of pop

ParamTypeDescription
expectedTypeObjectthe type that should be the result of pop

typedStack.peek(expectedType) ⇒ Object

Peek the top of the stack

Kind: instance method of TypedStack
Returns: Object - the result of peek

ParamTypeDescription
expectedTypeObjectthe type that should be the result of pop

typedStack.clear()

Clears the stack

Kind: instance method of TypedStack

concerto-core~version : Object

Kind: inner constant of concerto-core

concerto-cto

Concerto CTO concrete syntax module. Concerto is a framework for defining domain specific models.

concerto-metamodel

Concerto metamodel management. Concerto is a framework for defining domain specific models.

concerto-tools

Concerto Tools module.

concerto-util

Concerto utility module. Concerto is a framework for defining domain specific models.

concerto-vocabulary

Concerto vocabulary module. Concerto is a framework for defining domain specific models.

concerto-vocabulary.Vocabulary

A vocabulary for a concerto model

Kind: static class of concerto-vocabulary

new Vocabulary(vocabularyManager, voc)

Create the Vocabulary

ParamTypeDescription
vocabularyManagerVocabularyManagerthe manager for this vocabulary
vocobjectthe JSON representation of the vocabulary

vocabulary.getNamespace() ⇒ string

Returns the namespace for the vocabulary

Kind: instance method of Vocabulary
Returns: string - the namespace for this vocabulary

vocabulary.getLocale() ⇒ string

Returns the locale for the vocabulary

Kind: instance method of Vocabulary
Returns: string - the locale for this vocabulary

vocabulary.getIdentifier() ⇒ string

Returns the identifier for the vocabulary, composed of the namespace plus the locale

Kind: instance method of Vocabulary
Returns: string - the identifier for this vocabulary

vocabulary.getTerms() ⇒ Array

Returns all the declarations for this vocabulary

Kind: instance method of Vocabulary
Returns: Array - an array of objects

vocabulary.getTerm(declarationName, [propertyName]) ⇒ string

Gets the term for a concept, enum or property

Kind: instance method of Vocabulary
Returns: string - the term or null if it does not exist

ParamTypeDescription
declarationNamestringthe name of a concept or enum
[propertyName]stringthe name of a property (optional)

vocabulary.validate(modelFile) ⇒ *

Validates a vocabulary against a ModelFile, returning errors for missing and additional terms.

Kind: instance method of Vocabulary
Returns: * - an object with missingTerms and additionalTerms properties

ParamTypeDescription
modelFileModelFilethe model file for this vocabulary

vocabulary.toJSON() ⇒ *

Converts the object to JSON

Kind: instance method of Vocabulary
Returns: * - the contens of this vocabulary

concerto-vocabulary.VocabularyManager

A vocabulary manager for concerto models. The vocabulary manager stores and provides API access to a set of vocabulary files, where each file is associated with a BCP-47 language tag and a Concerto namespace.

Kind: static class of concerto-vocabulary
See: https://datatracker.ietf.org/doc/html/rfc5646#section-2

new VocabularyManager([options])

Create the VocabularyManager

ParamTypeDescription
[options]*options to configure vocabulary lookup
[options.missingTermGenerator]*A function to call for missing terms. The function should accept namespace, locale, declarationName, propertyName as arguments

vocabularyManager.clear()

Removes all vocabularies

Kind: instance method of VocabularyManager

vocabularyManager.removeVocabulary(namespace, locale)

Removes a vocabulary from the vocabulary manager

Kind: instance method of VocabularyManager

ParamTypeDescription
namespacestringthe namespace for the vocabulary
localestringthe BCP-47 locale identifier

vocabularyManager.addVocabulary(contents) ⇒ Vocabulary

Adds a vocabulary to the vocabulary manager

Kind: instance method of VocabularyManager
Returns: Vocabulary - the vocabulary the was added

ParamTypeDescription
contentsstringthe YAML string for the vocabulary

vocabularyManager.getVocabulary(namespace, locale, [options]) ⇒ Vocabulary

Gets a vocabulary for a given namespace plus locale

Kind: instance method of VocabularyManager
Returns: Vocabulary - the vocabulary or null if no vocabulary exists for the locale

ParamTypeDescription
namespacestringthe namespace for the vocabulary
localestringthe BCP-47 locale identifier
[options]*options to configure vocabulary lookup
[options.localeMatcher]*Pass 'lookup' to find a general vocabulary, if available

vocabularyManager.getVocabulariesForNamespace(namespace) ⇒ Array.<Vocabulary>

Gets all the vocabulary files for a given namespace

Kind: instance method of VocabularyManager
Returns: Array.<Vocabulary> - the array of vocabularies

ParamTypeDescription
namespacestringthe namespace

vocabularyManager.getVocabulariesForLocale(locale) ⇒ Array.<Vocabulary>

Gets all the vocabulary files for a given locale

Kind: instance method of VocabularyManager
Returns: Array.<Vocabulary> - the array of vocabularies

ParamTypeDescription
localestringthe BCP-47 locale identifier

vocabularyManager.resolveTerm(modelManager, namespace, locale, declarationName, [propertyName]) ⇒ string

Resolve the term for a property, looking up terms from a more general vocabulary if required, and resolving properties using an object manager, allowing terms defined on super types to be automatically resolved.

Kind: instance method of VocabularyManager
Returns: string - the term or null if it does not exist

ParamTypeDescription
modelManagerModelManagerthe model manager
namespacestringthe namespace
localestringthe BCP-47 locale identifier
declarationNamestringthe name of a concept or enum
[propertyName]stringthe name of a property (optional)

vocabularyManager.getTerm(namespace, locale, declarationName, [propertyName]) ⇒ string

Gets the term for a concept, enum or property, looking up terms from a more general vocabulary if required

Kind: instance method of VocabularyManager
Returns: string - the term or null if it does not exist

ParamTypeDescription
namespacestringthe namespace
localestringthe BCP-47 locale identifier
declarationNamestringthe name of a concept or enum
[propertyName]stringthe name of a property (optional)

vocabularyManager.generateDecoratorCommands(modelManager, locale) ⇒ *

Creates a DecoractorCommandSet with @Term decorators to decorate all model elements based on the vocabulary for a locale. Pass the return value to the DecoratorManager.decorateModel to apply the decorators to a ModelManager.

Kind: instance method of VocabularyManager
Returns: * - the decorator command set used to decorate the model.

ParamTypeDescription
modelManagerModelManagerthe Model Manager
localestringthe BCP-47 locale identifier

vocabularyManager.validate(modelManager, locale) ⇒ *

Validates the terms in the vocabulary against the namespaces and declarations within a ModelManager

Kind: instance method of VocabularyManager
Returns: * - the result of validation

ParamTypeDescription
modelManagerModelManagerthe Model Manager
localestringthe BCP-47 locale identifier

VocabularyManager.englishMissingTermGenerator(namespace, locale, declarationName, [propertyName]) ⇒ string

Computes a term in English based on declaration and property name.

Kind: static method of VocabularyManager
Returns: string - the term or null if it does not exist

ParamTypeDescription
namespacestringthe namespace
localestringthe BCP-47 locale identifier
declarationNamestringthe name of a concept or enum
[propertyName]stringthe name of a property (optional)

VocabularyManager.findVocabulary(requestedLocale, vocabularies, [options]) ⇒ Vocabulary

Finds the vocabulary for a requested locale, removing language identifiers from the locale until the locale matches, or if no vocabulary is found, null is returned

Kind: static method of VocabularyManager
Returns: Vocabulary - the most specific vocabulary, or null

ParamTypeDescription
requestedLocalestringthe BCP-47 locale identifier
vocabulariesArray.<Vocabulary>the vocabularies to match against
[options]*options to configure vocabulary lookup
[options.localeMatcher]*Pass 'lookup' to find a general vocabulary, if available

AbstractPlugin

Simple plug-in class for code-generation. This lists functions that can be passed to extend the default code-generation behavior.

Kind: global class

abstractPlugin.addClassImports(clazz, parameters, options)

Additional imports to generate in classes

Kind: instance method of AbstractPlugin

ParamTypeDescription
clazzClassDeclarationthe clazz being visited
parametersObjectthe parameter
optionsObjectthe visitor options

abstractPlugin.addClassAnnotations(clazz, parameters, options)

Additional annotations to generate in classes

Kind: instance method of AbstractPlugin

ParamTypeDescription
clazzClassDeclarationthe clazz being visited
parametersObjectthe parameter
optionsObjectthe visitor options

abstractPlugin.addClassMethods(clazz, parameters, options)

Additional methods to generate in classes

Kind: instance method of AbstractPlugin

ParamTypeDescription
clazzClassDeclarationthe clazz being visited
parametersObjectthe parameter
optionsObjectthe visitor options

abstractPlugin.addEnumAnnotations(enumDecl, parameters, options)

Additional annotations to generate in enums

Kind: instance method of AbstractPlugin

ParamTypeDescription
enumDeclEnumDeclarationthe enum being visited
parametersObjectthe parameter
optionsObjectthe visitor options

EmptyPlugin

Simple plug-in class for code-generation. This lists functions that can be passed to extend the default code-generation behavior.

Kind: global class

emptyPlugin.addClassImports(clazz, parameters)

Additional imports to generate in classes

Kind: instance method of EmptyPlugin

ParamTypeDescription
clazzClassDeclarationthe clazz being visited
parametersObjectthe parameter

emptyPlugin.addClassAnnotations(clazz, parameters)

Additional annotations to generate in classes

Kind: instance method of EmptyPlugin

ParamTypeDescription
clazzClassDeclarationthe clazz being visited
parametersObjectthe parameter

emptyPlugin.addClassMethods(clazz, parameters)

Additional methods to generate in classes

Kind: instance method of EmptyPlugin

ParamTypeDescription
clazzClassDeclarationthe clazz being visited
parametersObjectthe parameter

emptyPlugin.addEnumAnnotations(enumDecl, parameters)

Additional annotations to generate in enums

Kind: instance method of EmptyPlugin

ParamTypeDescription
enumDeclEnumDeclarationthe enum being visited
parametersObjectthe parameter

rootModelAst : unknown

Kind: global constant

metaModelCto

The metamodel itself, as a CTO string

Kind: global constant

metaModelAst : unknown

The metamodel itself, as an AST.

Kind: global constant

MetaModelNamespace

The namespace for the metamodel

Kind: global constant

metaModelCto

The metamodel itself, as a CTO string

Kind: global constant

levels : Object

Default levels for the npm configuration.

Kind: global constant

colorMap : Object

Default levels for the npm configuration.

Kind: global constant

setCurrentTime([currentTime], [utcOffset]) ⇒ object

Ensures there is a proper current time

Kind: global function
Returns: object - if valid, the dayjs object for the current time

ParamTypeDescription
[currentTime]stringthe definition of 'now'
[utcOffset]numberUTC Offset for this execution

newMetaModelManager() ⇒ ModelManager

Create a metamodel manager (for validation against the metamodel)

Kind: global function
Returns: ModelManager - the metamodel manager

validateMetaModel(input) ⇒ object

Validate metamodel instance against the metamodel

Kind: global function
Returns: object - the validated metamodel instance in JSON

ParamTypeDescription
inputobjectthe metamodel instance in JSON

modelManagerFromMetaModel(metaModel, [validate]) ⇒ ModelManager

Import metamodel to a model manager

Kind: global function
Returns: ModelManager - the metamodel for this model manager

ParamTypeDefaultDescription
metaModelobjectthe metamodel
[validate]booleantruewhether to perform validation

getRootModel(versioned) ⇒ object

Gets the root 'concerto' model

Kind: global function
Returns: object - rootModelFile, rootModelCto and rootModelAst

ParamTypeDescription
versionedbooleanif true the concerto namespace is versioned

randomNumberInRangeWithPrecision(userMin, userMax, precision, systemMin, systemMax) ⇒ number

Generate a random number within a given range with a prescribed precision and inside a global range

Kind: global function
Returns: number - a number

ParamTypeDescription
userMin*Lower bound on the range, inclusive. Defaults to systemMin
userMax*Upper bound on the range, inclusive. Defaults to systemMax
precision*The precision of values returned, e.g. a value of 1 returns only whole numbers
systemMin*Global minimum on the range, takes precidence over the userMin
systemMax*Global maximum on the range, takes precidence over the userMax

updateModels(models, newModel) ⇒ *

Update models with a new model

Kind: global function
Returns: * - the updated models

ParamTypeDescription
models*existing models
newModel*new model

resolveExternal(models, [options], [fileDownloader]) ⇒ Promise

Downloads all ModelFiles that are external dependencies and adds or updates them in this ModelManager.

Kind: global function
Returns: Promise - a promise when the download and update operation is completed.
Throws:

  • IllegalModelException if the models fail validation
ParamTypeDescription
models*the AST for all the known models
[options]ObjectOptions object passed to ModelFileLoaders
[fileDownloader]FileDownloaderan optional FileDownloader

parse(cto, [fileName], [options]) ⇒ object

Create a metamodel instance (i.e. JSON AST) object from a CTO string

Kind: global function
Returns: object - the metamodel instance for the cto argument

ParamTypeDescription
ctostringthe Concerto string
[fileName]stringan optional file name
[options]Objectan optional options parameter or filename
[options.skipLocationNodes]booleanwhen true location nodes will be skipped in the metamodel AST

parseModels(files, [options]) ⇒ *

Parses an array of model files

Kind: global function
Returns: * - the AST / metamodel

ParamTypeDescription
filesArray.<string>array of cto files
[options]Objectan optional options parameter
[options.skipLocationNodes]stringwhen true location nodes will be skipped in the metamodel AST

decoratorArgFromMetaModel(mm) ⇒ string

Create decorator argument string from a metamodel

Kind: global function
Returns: string - the string for the decorator argument

ParamTypeDescription
mmobjectthe metamodel

decoratorFromMetaModel(mm) ⇒ string

Create decorator string from a metamodel

Kind: global function
Returns: string - the string for the decorator

ParamTypeDescription
mmobjectthe metamodel

decoratorsFromMetaModel(mm, prefix) ⇒ string

Create decorators string from a metamodel

Kind: global function
Returns: string - the string for the decorators

ParamTypeDescription
mmobjectthe metamodel
prefixstringindentation

typeFromMetaModel(mm) ⇒ string

Create type string from a metamodel

Kind: global function
Returns: string - the string for the type

ParamTypeDescription
mmobjectthe metamodel

modifiersFromMetaModel(mm) ⇒ string

Create modifiers string from a metamodel

Kind: global function
Returns: string - the string for the modifiers

ParamTypeDescription
mmobjectthe metamodel

propertyFromMetaModel(mm) ⇒ string

Create a property string from a metamodel

Kind: global function
Returns: string - the string for that property

ParamTypeDescription
mmobjectthe metamodel

declFromMetaModel(mm) ⇒ string

Create a declaration string from a metamodel

Kind: global function
Returns: string - the string for that declaration

ParamTypeDescription
mmobjectthe metamodel

toCTO(metaModel) ⇒ string

Create a model string from a metamodel

Kind: global function
Returns: string - the string for that model

ParamTypeDescription
metaModelobjectthe metamodel

findNamespace(priorModels, namespace) ⇒ *

Find the model for a given namespace

Kind: global function
Returns: * - the model

ParamTypeDescription
priorModels*known models
namespacestringthe namespace

findDeclaration(thisModel, name) ⇒ *

Find a declaration for a given name in a model

Kind: global function
Returns: * - the declaration

ParamTypeDescription
thisModel*the model
namestringthe declaration name

createNameTable(priorModels, metaModel) ⇒ object

Create a name resolution table

Kind: global function
Returns: object - mapping from a name to its namespace

ParamTypeDescription
priorModels*known models
metaModelobjectthe metamodel (JSON)

resolveName(name, table) ⇒ string

Resolve a name using the name table

Kind: global function
Returns: string - the namespace for that name

ParamTypeDescription
namestringthe name of the type to resolve
tableobjectthe name table

resolveTypeNames(metaModel, table) ⇒ object

Name resolution for metamodel

Kind: global function
Returns: object - the metamodel with fully qualified names

ParamTypeDescription
metaModelobjectthe metamodel (JSON)
tableobjectthe name table

resolveLocalNames(priorModels, metaModel) ⇒ object

Resolve the namespace for names in the metamodel

Kind: global function
Returns: object - the resolved metamodel

ParamTypeDescription
priorModels*known models
metaModelobjectthe MetaModel

resolveLocalNamesForAll(allModels) ⇒ object

Resolve the namespace for names in the metamodel

Kind: global function
Returns: object - the resolved metamodel

ParamTypeDescription
allModels*known models

inferModelFile(defaultNamespace, defaultType, schema, options) ⇒ string

Infers a Concerto model from a JSON Schema.

Kind: global function
Returns: string - the Concerto model

ParamTypeDescription
defaultNamespacestringa fallback namespace to use for the model if it can't be infered
defaultTypestringa fallback name for the root concept if it can't be infered
schemaobjectthe input json object
optionsobjectprocessing options for inference

capitalizeFirstLetter(string) ⇒ string

Capitalize the first letter of a string

Kind: global function
Returns: string - input with first letter capitalized

ParamTypeDescription
stringstringthe input string

hashCode(value) ⇒ number

Computes an integer hashcode value for a string

Kind: global function
Returns: number - the hashcode

ParamTypeDescription
valuestringthe input string

isObject(val) ⇒ Boolean

Returns true if val is an object

Kind: global function
Returns: Boolean - true if val is an object

ParamTypeDescription
val*the value to test

isBoolean(val) ⇒ Boolean

Returns true if val is a boolean

Kind: global function
Returns: Boolean - true if val is a boolean

ParamTypeDescription
val*the value to test

isNull(val) ⇒ Boolean

Returns true if val is null

Kind: global function
Returns: Boolean - true if val is null

ParamTypeDescription
val*the value to test

isArray(val) ⇒ Boolean

Returns true if val is an array

Kind: global function
Returns: Boolean - true if val is an array

ParamTypeDescription
val*the value to test

isString(val) ⇒ Boolean

Returns true if val is a string

Kind: global function
Returns: Boolean - true if val is a string

ParamTypeDescription
val*the value to test

isDateTime(val) ⇒ Boolean

Returns true if val is a date time

Kind: global function
Returns: Boolean - true if val is a string

ParamTypeDescription
val*the value to test

isInteger(val) ⇒ Boolean

Returns true if val is an integer

Kind: global function
Returns: Boolean - true if val is a string

ParamTypeDescription
val*the value to test

isDouble(val) ⇒ Boolean

Returns true if val is an integer

Kind: global function
Returns: Boolean - true if val is a string

ParamTypeDescription
val*the value to test

getType(input) ⇒ string

Get the primitive Concerto type for an input

Kind: global function
Returns: string - the Concerto type

ParamTypeDescription
input*the input object

handleArray(typeName, context, input) ⇒ object

Handles an array

Kind: global function
Returns: object - the type for the array

ParamTypeDescription
typeName*the name of the type being processed
context*the processing context
input*the input object

handleType(name, context, input) ⇒ object

Handles an input type

Kind: global function
Returns: object - an object for the type

ParamTypeDescription
name*the name of the type being processed
context*the processing context
input*the input object

removeDuplicateTypes(context)

Detect duplicate types and remove them

Kind: global function

ParamTypeDescription
context*the context

inferModel(namespace, rootTypeName, input) ⇒ string

Infers a Concerto model from a JSON instance.

Kind: global function
Returns: string - the Concerto model

ParamTypeDescription
namespacestringthe namespace to use for the model
rootTypeName*the name for the root concept
input*the input json object

main()

Generate TypeScript files from the metamodel.

Kind: global function

labelToSentence(labelName) ⇒ string

Inserts correct spacing and capitalization to a camelCase label

Kind: global function
Returns: string - - The label text formatted for rendering

ParamTypeDescription
labelNamestringthe label text to be transformed

sentenceToLabel(sentence) ⇒ string

Create a camelCase label from a sentence

Kind: global function
Returns: string - - The camelCase label

ParamTypeDescription
sentencestringthe sentence

writeModelsToFileSystem(files, path, options)

Writes a set of model files to disk

Kind: global function

ParamTypeDescription
files*the set of files to write, with names and whether they are external
pathstringa path to the directory where to write the files
options*a set of options

camelCaseToSentence(text) ⇒ string

Converts a camel case string to a sentence

Kind: global function
Returns: string - modified string

ParamTypeDescription
textstringinput

ParseNamespaceResult

Kind: global typedef
Properties

NameTypeDescription
namestringthe name of the namespace
escapedNamespacestringthe escaped namespace
versionstringthe version of the namespace
versionParsedobjectthe parsed semantic version of the namespace