Skip to content

Commit

Permalink
(feat) add support for OData transform (#427)
Browse files Browse the repository at this point in the history
* (feat) add support for OData transform

Signed-off-by: Dan Selman <[email protected]>

* (test) lots of lovely code coverage

Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman authored May 16, 2022
1 parent 3d64a99 commit 7ebf036
Show file tree
Hide file tree
Showing 15 changed files with 7,804 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/concerto-cli/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const TypescriptVisitor = CodeGen.TypescriptVisitor;
const XmlSchemaVisitor = CodeGen.XmlSchemaVisitor;
const GraphQLVisitor = CodeGen.GraphQLVisitor;
const CSharpVisitor = CodeGen.CSharpVisitor;
const ODataVisitor = CodeGen.ODataVisitor;

/**
* Utility class that implements the commands exposed by the CLI.
Expand Down Expand Up @@ -169,6 +170,9 @@ class Commands {
case 'CSharp':
visitor = new CSharpVisitor();
break;
case 'OData':
visitor = new ODataVisitor();
break;
}

if(visitor) {
Expand Down
6 changes: 6 additions & 0 deletions packages/concerto-cli/test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ describe('cicero-cli', () => {
fs.readdirSync(dir.path).length.should.be.above(0);
dir.cleanup();
});
it('should compile to an OData model', async () => {
const dir = await tmp.dir({ unsafeCleanup: true });
await Commands.compile('OData', models, dir.path, {offline:false});
fs.readdirSync(dir.path).length.should.be.above(0);
dir.cleanup();
});
it('should not compile to an unknown model', async () => {
const dir = await tmp.dir({ unsafeCleanup: true });
await Commands.compile('BLAH', models, dir.path, {offline:false});
Expand Down
1 change: 1 addition & 0 deletions packages/concerto-core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class Decorator {
+ void getParent()
+ string getName()
+ object[] getArguments()
+ boolean isDecorator()
}
class DecoratorFactory {
+ Decorator newDecorator(ClassDeclaration|Property,Object)
Expand Down
3 changes: 3 additions & 0 deletions packages/concerto-core/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# Note that the latest public API is documented using JSDocs and is available in api.txt.
#

Version 2.0.1 {f5d85447683b22d6f4072f9cd7f8986e} 22-05-13
- Add Decorator.isDecorator for use in visitor

Version 2.0.1 {62a8de0d35789bbe523269e4e29cd8e6} 2022-04-25
- Correct type for Concerto.getModelManager()

Expand Down
11 changes: 10 additions & 1 deletion packages/concerto-core/lib/introspect/decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Decorator {
* @throws {IllegalModelException}
* @private
*/
validate() {}
validate() { }

/**
* Returns the name of a decorator
Expand All @@ -111,6 +111,15 @@ class Decorator {
getArguments() {
return this.arguments;
}

/**
* Returns true if this class is the definition of a decorator.
*
* @return {boolean} true if the class is a decorator
*/
isDecorator() {
return true;
}
}

module.exports = Decorator;
2 changes: 1 addition & 1 deletion packages/concerto-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"check-coverage": true,
"statements": 98,
"branches": 97,
"functions": 98,
"functions": 97,
"lines": 98
}
}
6 changes: 6 additions & 0 deletions packages/concerto-core/types/lib/introspect/decorator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ declare class Decorator {
* @return {object[]} the arguments for this decorator
*/
getArguments(): object[];
/**
* Returns true if this class is the definition of a decorator.
*
* @return {boolean} true if the class is a decorator
*/
isDecorator(): boolean;
}
import Property = require("./property");
import ClassDeclaration = require("./classdeclaration");
4 changes: 3 additions & 1 deletion packages/concerto-tools/lib/codegen/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const TypescriptVisitor = require('./fromcto/typescript/typescriptvisitor');
const JavaVisitor = require('./fromcto/java/javavisitor');
const GraphQLVisitor = require('./fromcto/graphql/graphqlvisitor');
const CSharpVisitor = require('./fromcto/csharp/csharpvisitor');
const ODataVisitor = require('./fromcto/odata/odatavisitor');

module.exports = {
AbstractPlugin,
Expand All @@ -34,5 +35,6 @@ module.exports = {
TypescriptVisitor,
JavaVisitor,
GraphQLVisitor,
CSharpVisitor
CSharpVisitor,
ODataVisitor
};
Loading

0 comments on commit 7ebf036

Please sign in to comment.