-
-
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
Open
Ayush1404
wants to merge
3
commits into
accordproject:main
Choose a base branch
from
Ayush1404:ayush/i943/missing-dcs-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'); | ||
sanketshevkar 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')); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
47 changes: 47 additions & 0 deletions
47
packages/concerto-types/src/generated/unions/[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 .