-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix : Modify code generation script to include DCS Concerto model types #952
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,14 @@ | |
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'); | ||
mttrbrts marked this conversation as resolved.
Show resolved
Hide resolved
Ayush1404 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Generate TypeScript files from the metamodel. | ||
*/ | ||
async function main() { | ||
const modelManager = new ModelManager({addMetamodel:true, strict: true}); | ||
modelManager.addCTOModel(DCS_MODEL, '[email protected]'); | ||
sanketshevkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const visitor = new TypescriptVisitor(); | ||
|
||
const fileWriter = new FileWriter(path.resolve(__dirname, '..', 'src', 'generated')); | ||
|
@@ -20,6 +22,6 @@ | |
} | ||
|
||
main().catch(error => { | ||
console.error(error); | ||
Check warning on line 25 in packages/concerto-types/scripts/codegen.js GitHub Actions / Unit Tests (18.x, windows-latest)
Check warning on line 25 in packages/concerto-types/scripts/codegen.js GitHub Actions / Unit Tests (18.x, macos-latest)
Check warning on line 25 in packages/concerto-types/scripts/codegen.js GitHub Actions / Unit Tests (18.x, ubuntu-latest)
Check warning on line 25 in packages/concerto-types/scripts/codegen.js GitHub Actions / Unit Tests (20.x, windows-latest)
Check warning on line 25 in packages/concerto-types/scripts/codegen.js GitHub Actions / Unit Tests (20.x, macos-latest)
|
||
process.exit(1); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,14 @@ import type { | |
IModel, | ||
IModels | ||
} from './[email protected]'; | ||
import type { | ||
sanketshevkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
IDecoratorCommandSetReference, | ||
CommandType, | ||
ICommandTarget, | ||
MapElement, | ||
ICommand, | ||
IDecoratorCommandSet | ||
} from './[email protected]'; | ||
|
||
// interfaces | ||
export interface IConcept { | ||
|
@@ -51,7 +59,11 @@ ILongDomainValidator | | |
IAliasedType | | ||
IImport | | ||
IModel | | ||
IModels; | ||
IModels | | ||
sanketshevkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
IDecoratorCommandSetReference | | ||
ICommandTarget | | ||
ICommand | | ||
IDecoratorCommandSet; | ||
|
||
export interface IAsset extends IConcept { | ||
$identifier: string; | ||
|
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[]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please export this using the index.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But doing so will give an error as tests expect DecoratorManager to be exported as default , we can re-export it in the index.js but we have to keep the default export for tests to succeed .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I'm wondering we could just fix the tests with imports, but could this could break for someone whose not importing through
index.js
. Let me discuss this during today's WG call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just discussed, we decided to move
DCS_MODEL
toconcerto-metamodel
package. I'll raise a PR and cut a release and update it here to be used.Can you please wait until I move things there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanketshevkar yeah sure , no problem . I would like to contribute , could you direct me to something where i could ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Ayush1404 , you'll have to move the DCS model in this repo and import it in core and types package in concerto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanketshevkar , okay do i do it here in this PR or open a separate issue for it ? Also i meant to ask where else could i contribute to concerto or accord project in general .