Skip to content

Commit

Permalink
fix : Modify code generation script to include DCS Concerto model types
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush1404 <[email protected]>
  • Loading branch information
Ayush1404 committed Dec 2, 2024
1 parent ce4462c commit d5fcd46
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/concerto-core/lib/decoratormanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,4 +812,4 @@ class DecoratorManager {
}
}

module.exports = DecoratorManager;
module.exports = {DecoratorManager,DCS_MODEL};
2 changes: 2 additions & 0 deletions packages/concerto-types/scripts/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const { ModelManager } = require('@accordproject/concerto-core');
const { CodeGen: { TypescriptVisitor }} = require('@accordproject/concerto-codegen');
const { FileWriter } = require('@accordproject/concerto-util');
const path = require('path');
const {DCS_MODEL }= require('@accordproject/concerto-core/lib/decoratormanager');

/**
* Generate TypeScript files from the metamodel.
*/
async function main() {
const modelManager = new ModelManager({addMetamodel:true, strict: true});
modelManager.addCTOModel(DCS_MODEL, '[email protected]');
const visitor = new TypescriptVisitor();

const fileWriter = new FileWriter(path.resolve(__dirname, '..', 'src', 'generated'));
Expand Down
14 changes: 13 additions & 1 deletion packages/concerto-types/src/generated/unions/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ import type {
IModel,
IModels
} from './[email protected]';
import type {
IDecoratorCommandSetReference,
CommandType,
ICommandTarget,
MapElement,
ICommand,
IDecoratorCommandSet
} from './[email protected]';

// interfaces
export interface IConcept {
Expand All @@ -51,7 +59,11 @@ ILongDomainValidator |
IAliasedType |
IImport |
IModel |
IModels;
IModels |
IDecoratorCommandSetReference |
ICommandTarget |
ICommand |
IDecoratorCommandSet;

export interface IAsset extends IConcept {
$identifier: string;
Expand Down
47 changes: 47 additions & 0 deletions packages/concerto-types/src/generated/unions/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
// Generated code for namespace: [email protected]

// imports
import {IDecorator} from './[email protected]';
import {IConcept} from './[email protected]';

// interfaces
export interface IDecoratorCommandSetReference extends IConcept {
name: string;
version: string;
}

export enum CommandType {
UPSERT = 'UPSERT',
APPEND = 'APPEND',
}

export interface ICommandTarget extends IConcept {
namespace?: string;
declaration?: string;
property?: string;
properties?: string[];
type?: string;
mapElement?: MapElement;
}

export enum MapElement {
KEY = 'KEY',
VALUE = 'VALUE',
KEY_VALUE = 'KEY_VALUE',
}

export interface ICommand extends IConcept {
target: ICommandTarget;
decorator: IDecorator;
type: CommandType;
decoratorNamespace?: string;
}

export interface IDecoratorCommandSet extends IConcept {
name: string;
version: string;
includes?: IDecoratorCommandSetReference[];
commands: ICommand[];
}

0 comments on commit d5fcd46

Please sign in to comment.