
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@accordproject/concertino
Advanced tools
Concertino is a lightweight variant of the Concerto metamodel format, optimized for client applications that need to programmatically introspect declarations without taking a dependency on the full Concerto SDK.
The Concertino format provides several advantages:
Flatter structure: By denormalizing the inheritance hierarchy, consumers don't need to traverse the hierarchy to understand a definition.
More explicit metadata: Additional metadata makes it clearer how properties should be interpreted.
Ready for consumption: The transformation prepares the data for easier consumption by tools and renderers, without requiring additional processing.
Concerto (Metamodel) → Concertino → Concerto (Metamodel)
npm install @accordproject/concertino
const { ModelManager } = require('@accordproject/concerto-core');
const { ConcertinoConverter } = require('@accordproject/concertino');
// Prepare the Concerto model
const mm = new ModelManager();
mm.addModel(MODEL_FILE_CONTENTS);
const model = mm.getModelFile(MODEL_FILE_NAMESPACE).getAst();
// Initialize Concertino
const converter = new ConcertinoConverter();
const models = { models: [model] };
// Convert from Concerto metamodel to Concertino
const concertino = converter.fromConcertoMetamodel(models);
console.log('#### Concertino:')
console.log(JSON.stringify(concertino, null, 2));
console.log();
// Convert from Concertino back to Concerto metamodel
const metamodel = converter.toConcertoMetamodel(concertino);
console.log('#### Concerto AST (Full Metamodel Instance):')
console.log(JSON.stringify(metamodel, null, 2));
Despite the denormalization of metadata, the JSON serialization of Concertino models are often smaller in size than their Concerto AST equivalents due to a flatter, dictionary-like design and the removal of type-discriminators (i.e. $class properties).
It is expected that models that make heavy use of inheritance would be larger than their equivalent Concerto AST.
Note that when converting models, the namespaces in the source Concerto model should be fully resolved (including for local type references).
Below is an example of how a simple Concerto model is represented in the Concertino format:
{
"declarations": {
"readme@1.0.0.Address": {
"properties": {
"city": {
"name": "city",
"type": "String",
"vocabulary": {
"label": "City/Town",
},
},
"country": {
"name": "country",
"type": "String",
},
"street": {
"name": "street",
"type": "String",
"vocabulary": {
"label": "Street Address",
},
},
"zipCode": {
"name": "zipCode",
"type": "String",
},
},
"type": "ConceptDeclaration",
"vocabulary": {
"label": "Physical Address",
},
},
"readme@1.0.0.Email": {
"regex": "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/",
"type": "StringScalar",
},
"readme@1.0.0.Person": {
"properties": {
"address": {
"isOptional": true,
"name": "address",
"type": "readme@1.0.0.Address",
"vocabulary": {
"label": "Mailing Address",
},
},
"age": {
"isOptional": true,
"name": "age",
"range": [
0,
null,
],
"type": "Integer",
},
"email": {
"isOptional": true,
"metadata": {
"sensitive": null,
},
"name": "email",
"regex": "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/",
"scalarType": "readme@1.0.0.Email",
"type": "String",
},
"firstName": {
"name": "firstName",
"type": "String",
"vocabulary": {
"label": "Given Name",
},
},
"lastName": {
"name": "lastName",
"type": "String",
"vocabulary": {
"label": "Family Name",
},
},
},
"type": "ConceptDeclaration",
"vocabulary": {
"additionalTerms": {
"plural": "People",
},
"label": "Individual",
},
},
},
"metadata": {
"concertinoVersion": "1.0.0-alpha.7",
"models": {
"org.example.models@1.0.0": {
"concertoVersion": "1.0.0",
"sourceUri": "org/example/models.cto",
"decorators": [
{
"name": "license",
"arguments": ["Apache-2.0"]
}
]
}
}
}
}
The equivalent Concerto CTO file would be:
@license("Apache-2.0")
namespace org.example.models@1.0.0
scalar Email extends String regex=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
@Term("Individual")
@Term_plural("People")
concept Person {
@Term("Given Name")
o String firstName
@Term("Family Name")
o String lastName
o Integer age optional range=[0, ]
@sensitive
o Email email optional
@Term("Mailing Address")
o Address address optional
}
@Term("Physical Address")
concept Address {
@Term("Street Address")
o String street
@Term("City/Town")
o String city
o String zipCode
o String country
}
FAQs
Object-centric serialization of Concerto models
We found that @accordproject/concertino demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.