UNPKG

@accordproject/concerto-core

Version:

Core Implementation for the Concerto Modeling Language

307 lines (306 loc) • 11.7 kB
declare const Decorated: any; /** * Class representing a Model File. A Model File contains a single namespace * and a set of model elements: assets, transactions etc. * * @class * @memberof module:concerto-core */ declare class ModelFile extends Decorated { modelManager: any; ast: any; definitions: any; fileName: any; /** * Create a ModelFile. This should only be called by framework code. * Use the ModelManager to manage ModelFiles. * @param {ModelManager} modelManager - the ModelManager that manages this * ModelFile * @param {object} ast - The abstract syntax tree of the model as a JSON object. * @param {string} [definitions] - The optional CTO model as a string. * @param {string} [fileName] - The optional filename for this modelfile * @throws {IllegalModelException} */ constructor(modelManager: any, ast: any, definitions?: any, fileName?: any); /** * Returns the ModelFile that defines this class. * * @protected * @return {ModelFile} the owning ModelFile */ getModelFile(): this; /** * Returns true * @returns {boolean} true */ isModelFile(): boolean; /** * Returns the semantic version * @returns {string} the semantic version or null if the namespace for the model file is * unversioned */ getVersion(): any; /** * Returns true if the ModelFile is a system namespace * @returns {Boolean} true if this is a system model file */ isSystemModelFile(): any; /** * Returns true if this ModelFile was downloaded from an external URI. * @return {boolean} true iff this ModelFile was downloaded from an external URI */ isExternal(): any; /** * Returns the URI for an import, or null if the namespace was not associated with a URI. * @param {string} namespace - the namespace for the import * @return {string} the URI or null if the namespace was not associated with a URI. * @private */ getImportURI(namespace: any): any; /** * Returns an object that maps from the import declarations to the URIs specified * @return {Object} keys are import declarations, values are URIs * @private */ getExternalImports(): any; /** * Visitor design pattern * @param {Object} visitor - the visitor * @param {Object} parameters - the parameter * @return {Object} the result of visiting or null */ accept(visitor: any, parameters: any): any; /** * Returns the ModelManager associated with this ModelFile * * @return {ModelManager} The ModelManager for this ModelFile */ getModelManager(): any; /** * Returns the types that have been imported into this ModelFile. * * @return {string[]} The array of fully-qualified names for types imported by * this ModelFile */ getImports(): never[]; /** * Validates the ModelFile. * * @throws {IllegalModelException} if the model is invalid * @protected */ validate(): void; /** * Check that the type is valid. * @param {string} context - error reporting context * @param {string} type - a short type name * @param {Object} [fileLocation] - location details of the error within the model file. * @param {String} fileLocation.start.line - start line of the error location. * @param {String} fileLocation.start.column - start column of the error location. * @param {String} fileLocation.end.line - end line of the error location. * @param {String} fileLocation.end.column - end column of the error location. * @throws {IllegalModelException} - if the type is not defined * @private */ resolveType(context: any, type: any, fileLocation?: any): void; /** * Returns true if the type is defined in this namespace. * @param {string} type - the short name of the type * @return {boolean} - true if the type is defined in this ModelFile * @private */ isLocalType(type: any): any; /** * Returns true if the type is imported from another namespace * @param {string} type - the short name of the type * @return {boolean} - true if the type is imported from another namespace * @private */ isImportedType(type: any): any; /** * Returns the FQN for a type that is imported from another namespace * @param {string} type - the short name of the type * @return {string} - the FQN of the resolved import * @throws {Error} - if the type is not imported * @private */ resolveImport(type: any): any; /** * Returns the actual imported name from another namespace * @param {string} type - the short name of the type * @returns {string} - the actual imported name. If not aliased then returns the same string */ getImportedType(type: any): any; /** * Returns true if the type is defined in the model file * @param {string} type the name of the type * @return {boolean} true if the type (asset or transaction) is defined */ isDefined(type: any): any; /** * Returns the FQN of the type or null if the type could not be resolved. * For primitive types the type name is returned. * @param {string} type - a FQN or short type name * @return {string | ClassDeclaration} the class declaration for the type or null. * @private */ getType(type: any): any; /** * Returns the FQN of the type or null if the type could not be resolved. * For primitive types the short type name is returned. * @param {string} type - a FQN or short type name * @return {string} the FQN type name or null * @private */ getFullyQualifiedTypeName(type: any): any; /** * Returns the type with the specified name or null * @param {string} type the short OR FQN name of the type * @return {ClassDeclaration} the ClassDeclaration, or null if the type does not exist */ getLocalType(type: any): any; /** * Get the AssetDeclarations defined in this ModelFile or null * @param {string} name the name of the type * @return {AssetDeclaration} the AssetDeclaration with the given short name */ getAssetDeclaration(name: any): any; /** * Get the TransactionDeclaration defined in this ModelFile or null * @param {string} name the name of the type * @return {TransactionDeclaration} the TransactionDeclaration with the given short name */ getTransactionDeclaration(name: any): any; /** * Get the EventDeclaration defined in this ModelFile or null * @param {string} name the name of the type * @return {EventDeclaration} the EventDeclaration with the given short name */ getEventDeclaration(name: any): any; /** * Get the ParticipantDeclaration defined in this ModelFile or null * @param {string} name the name of the type * @return {ParticipantDeclaration} the ParticipantDeclaration with the given short name */ getParticipantDeclaration(name: any): any; /** * Get the Namespace for this model file. * @return {string} The Namespace for this model file */ getNamespace(): any; /** * Get the filename for this model file. Note that this may be null. * @return {string} The filename for this model file */ getName(): any; /** * Get the AssetDeclarations defined in this ModelFile * @return {AssetDeclaration[]} the AssetDeclarations defined in the model file */ getAssetDeclarations(): any[]; /** * Get the TransactionDeclarations defined in this ModelFile * @return {TransactionDeclaration[]} the TransactionDeclarations defined in the model file */ getTransactionDeclarations(): any[]; /** * Get the EventDeclarations defined in this ModelFile * @return {EventDeclaration[]} the EventDeclarations defined in the model file */ getEventDeclarations(): any[]; /** * Get the ParticipantDeclarations defined in this ModelFile * @return {ParticipantDeclaration[]} the ParticipantDeclaration defined in the model file */ getParticipantDeclarations(): any[]; /** * Get the ClassDeclarations defined in this ModelFile * @return {ClassDeclaration[]} the ClassDeclarations defined in the model file */ getClassDeclarations(): any[]; /** * Get the ConceptDeclarations defined in this ModelFile * @return {ConceptDeclaration[]} the ParticipantDeclaration defined in the model file */ getConceptDeclarations(): any[]; /** * Get the EnumDeclarations defined in this ModelFile * @return {EnumDeclaration[]} the EnumDeclaration defined in the model file */ getEnumDeclarations(): any[]; /** * Get the MapDeclarations defined in this ModelFile * @return {MapDeclaration[]} the MapDeclarations defined in the model file */ getMapDeclarations(): any[]; /** * Get the ScalarDeclaration defined in this ModelFile * @return {ScalarDeclaration[]} the ScalarDeclaration defined in the model file */ getScalarDeclarations(): any[]; /** * Get the instances of a given type in this ModelFile * @param {Function} type - the type of the declaration * @return {Object[]} the ClassDeclaration defined in the model file */ getDeclarations(type: any): any[]; /** * Get all declarations in this ModelFile * @return {ClassDeclaration[]} the ClassDeclarations defined in the model file */ getAllDeclarations(): any; /** * Get the definitions for this model. * @return {string} The definitions for this model. */ getDefinitions(): any; /** * Get the ast for this model. * @return {object} The definitions for this model. */ getAst(): any; /** * Get the expected concerto version * @return {string} The semver range for compatible concerto versions */ getConcertoVersion(): any; /** * Check whether this modelfile is compatible with the concerto version. * Models targeting an older major version are considered backward-compatible * with newer runtimes (e.g. a model declaring "^3.0.0" loads under v4). */ isCompatibleVersion(): void; /** * Verifies that an import is versioned if the strict * option has been set on the Model Manager * @param {*} imp - the import to validate * @private */ enforceImportVersioning(imp: any): void; /** * Populate from an AST * @param {object} ast - the AST obtained from the parser * @private */ fromAst(ast: any): void; /** * A function type definition for use as an argument to the filter function * @callback FilterFunction * @param {Declaration} declaration * @returns {boolean} true, if the declaration satisfies the filter function */ /** * Returns a new ModelFile with only the types for which the * filter function returns true. * * Will return null if the filtered ModelFile doesn't contain any declarations. * * @param {FilterFunction} predicate - the filter function over a Declaration object * @param {ModelManager} modelManager - the target ModelManager for the filtered ModelFile * @param {string[]} removedDeclarations - an array that will be populated with the FQN of removed declarations * @returns {ModelFile?} - the filtered ModelFile * @private */ filter(predicate: any, modelManager: any, removedDeclarations: any): ModelFile | null; } export = ModelFile;