From 19919c840a9ee2564b9a410d99fb41a95e961535 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 10 Oct 2023 13:13:11 +0100 Subject: [PATCH 01/22] feat(map): add map for javavisitor Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/java/javavisitor.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index cda5e914..06993ffc 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -278,7 +278,12 @@ class JavaVisitor { parameters.fileWriter.writeLine(1, '}'); break; default: - parameters.fileWriter.writeLine(1, 'private ' + fieldType + ' ' + fieldName + ';' ); + if (this.isMap(field)) { + const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name); + parameters.fileWriter.writeLine(1, `private Map<${this.toJavaType(decl.getKey().getType())}, ${this.toJavaType(decl.getValue().getType())}> ${field.getName()} = new HashMap<>();`); + } else { + parameters.fileWriter.writeLine(1, 'private ' + fieldType + ' ' + fieldName + ';' ); + } } } else { parameters.fileWriter.writeLine(1, 'private ' + fieldType + ' ' + fieldName + ';' ); @@ -374,6 +379,16 @@ class JavaVisitor { capitalizeFirstLetter(s) { return s.charAt(0).toUpperCase() + s.slice(1); } + + /** + * Check if field is a Map Declaration + * @param {Field} field - the field being visited + * @return {boolean} true if field is a Map Declaration + * @private + */ + isMap(field) { + return (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) ? true : false; + } } module.exports = JavaVisitor; From d9a482b235cb594f0a4dce04df9f48ceff1ce6c2 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 10 Oct 2023 13:13:25 +0100 Subject: [PATCH 02/22] feat(map): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index b761ade7..4f77a558 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -905,12 +905,12 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map1 dictionary1; - private Map2 dictionary2; - private Map3 dictionary3; - private Map4 dictionary4; - private Map5 dictionary5; - private Map6 dictionary6; + private Map dictionary1 = new HashMap<>(); + private Map dictionary2 = new HashMap<>(); + private Map dictionary3 = new HashMap<>(); + private Map dictionary4 = new HashMap<>(); + private Map dictionary5 = new HashMap<>(); + private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } @@ -6037,12 +6037,12 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map1 dictionary1; - private Map2 dictionary2; - private Map3 dictionary3; - private Map4 dictionary4; - private Map5 dictionary5; - private Map6 dictionary6; + private Map dictionary1 = new HashMap<>(); + private Map dictionary2 = new HashMap<>(); + private Map dictionary3 = new HashMap<>(); + private Map dictionary4 = new HashMap<>(); + private Map dictionary5 = new HashMap<>(); + private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } From a561e7a281044c132278654961d6a88805a29b78 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 10 Oct 2023 17:32:23 +0100 Subject: [PATCH 03/22] feat(map): add test cases Signed-off-by: Jonathan Casey --- test/codegen/fromcto/java/javavisitor.js | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/codegen/fromcto/java/javavisitor.js b/test/codegen/fromcto/java/javavisitor.js index a7bca99d..f284f450 100644 --- a/test/codegen/fromcto/java/javavisitor.js +++ b/test/codegen/fromcto/java/javavisitor.js @@ -21,6 +21,8 @@ const sinon = require('sinon'); const JavaVisitor = require('../../../../lib/codegen/fromcto/java/javavisitor.js'); const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; +const MapDeclaration = require('@accordproject/concerto-core').MapDeclaration; +const ModelUtil = require('@accordproject/concerto-core').ModelUtil; const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration; const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration; const Field = require('@accordproject/concerto-core').Field; @@ -29,6 +31,8 @@ const ModelManager = require('@accordproject/concerto-core').ModelManager; const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; +let sandbox = sinon.createSandbox(); + describe('JavaVisitor', function () { let javaVisit; let mockFileWriter; @@ -413,6 +417,47 @@ describe('JavaVisitor', function () { param.fileWriter.writeLine.withArgs(1, 'private JavaType[] Bob;').calledOnce.should.be.ok; }); + it('should write a line with a HashMap', () => { + let param = { + fileWriter: mockFileWriter, + mode: 'field' + }; + + sandbox.restore(); + sandbox.stub(ModelUtil, 'isMap').callsFake(() => { + return true; + }); + + const mockField = sinon.createStubInstance(Field); + const getAllDeclarations = sinon.stub(); + + mockField.dummy = 'Dummy Value'; + mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const findStub = sinon.stub(); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + mockField.getName.returns('Bob'); + mockField.getType.returns('SpecialType'); + + getAllDeclarations.returns({ find: findStub }); + findStub.returns(mockMapDeclaration); + getKeyType.returns('String'); + getValueType.returns('String'); + mockField.getName.returns('Map1'); + mockMapDeclaration.getName.returns('Map1'); + mockMapDeclaration.isMapDeclaration.returns(true); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + javaVisit.visitField(mockField,param); + + param.fileWriter.writeLine.withArgs(1, 'private Map Map1 = new HashMap<>();').calledOnce.should.be.ok; + sandbox.reset(); + }); + it('should write a line defining a field', () => { let mockField = sinon.createStubInstance(Field); mockField.isField.returns(true); From 2fdb63589664f85ee0f76647f2b6e2a82469f7e4 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Wed, 11 Oct 2023 13:47:38 +0100 Subject: [PATCH 04/22] remove redundant ternary expression Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/java/javavisitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index 06993ffc..08be9154 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -387,7 +387,7 @@ class JavaVisitor { * @private */ isMap(field) { - return (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) ? true : false; + return (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)); } } From d49ab1c8201b3bf3334ccd95dba24d7dcbf95f51 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Sat, 21 Oct 2023 07:57:19 +0100 Subject: [PATCH 05/22] feat(map): get type from ModelFile Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/java/javavisitor.js | 2 +- test/codegen/fromcto/java/javavisitor.js | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index 08be9154..dc0c390e 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -279,7 +279,7 @@ class JavaVisitor { break; default: if (this.isMap(field)) { - const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name); + const decl = field.getModelFile().getType(field.ast.type.name); parameters.fileWriter.writeLine(1, `private Map<${this.toJavaType(decl.getKey().getType())}, ${this.toJavaType(decl.getValue().getType())}> ${field.getName()} = new HashMap<>();`); } else { parameters.fileWriter.writeLine(1, 'private ' + fieldType + ' ' + fieldName + ';' ); diff --git a/test/codegen/fromcto/java/javavisitor.js b/test/codegen/fromcto/java/javavisitor.js index f284f450..e063c489 100644 --- a/test/codegen/fromcto/java/javavisitor.js +++ b/test/codegen/fromcto/java/javavisitor.js @@ -429,21 +429,19 @@ describe('JavaVisitor', function () { }); const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); - mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.ast = { type: { name: 'Dummy Value'} }; + mockField.getModelFile.returns({ getType: getType }); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); mockField.getName.returns('Bob'); mockField.getType.returns('SpecialType'); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('String'); mockField.getName.returns('Map1'); @@ -718,4 +716,4 @@ describe('JavaVisitor', function () { javaVisit.toJavaType('Penguin').should.deep.equal('Penguin'); }); }); -}); \ No newline at end of file +}); From f34f96b67980af8a5d04b1ec83cdf66add55d6e7 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Sat, 21 Oct 2023 07:57:56 +0100 Subject: [PATCH 06/22] chore(deps): upgrade concerto Signed-off-by: Jonathan Casey --- package-lock.json | 118 +++++++++++++++++++++++++++++++++------------- package.json | 8 ++-- 2 files changed, 90 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 639a1cbd..b1dc43be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "3.16.0", "license": "Apache-2.0", "dependencies": { - "@accordproject/concerto-core": "3.12.3", - "@accordproject/concerto-util": "3.12.3", - "@accordproject/concerto-vocabulary": "3.12.3", + "@accordproject/concerto-core": "3.14.0", + "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-vocabulary": "3.14.0", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", @@ -22,7 +22,7 @@ "pluralize": "8.0.0" }, "devDependencies": { - "@accordproject/concerto-cto": "3.12.3", + "@accordproject/concerto-cto": "3.14.0", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -60,34 +60,62 @@ } }, "node_modules/@accordproject/concerto-core": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.12.3.tgz", - "integrity": "sha512-xFCzM3xwV8Th719sUp4htElqiHWAIwOCqukSaYZ2OxrrXmIBvoj0aWCkGiWYHlMujVegXQrP7R8G+8O+QuGxUg==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.0.tgz", + "integrity": "sha512-JOLG9ISzlowDUsrD0Lbks0ft08JiQZV6oPbBai0tBOy5x+CPd4JLoGmjfy/x6+6HsFWdk1aXV2tQJww6Gw+3Tw==", "dependencies": { - "@accordproject/concerto-cto": "3.12.3", + "@accordproject/concerto-cto": "3.14.0", "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.12.3", - "dayjs": "1.10.8", - "debug": "4.3.1", - "lorem-ipsum": "2.0.3", + "@accordproject/concerto-util": "3.14.0", + "dayjs": "1.11.10", + "debug": "4.3.4", + "lorem-ipsum": "2.0.8", "randexp": "0.5.3", "semver": "7.5.4", "slash": "3.0.0", "urijs": "1.19.11", - "uuid": "8.3.2" + "uuid": "9.0.1" }, "engines": { "node": ">=16", "npm": ">=8" } }, + "node_modules/@accordproject/concerto-core/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@accordproject/concerto-core/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@accordproject/concerto-cto": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.12.3.tgz", - "integrity": "sha512-iR8IL4/bbCrwoHijCtJVmYa02JygoZI+ODG5TmsYE4Ryl+Rqz4B6oYgISdy1j5ZSDGXSjy2I1bj9K130OtKBbA==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.0.tgz", + "integrity": "sha512-6Uf0fe5BZpgiBUONNAGxOrDdXvDK+6qMuWdcqN+aPddtFPLZ/2ldFarQaSkXHq71+yrM7B/Dh7Y/0KSvs1Tteg==", "dependencies": { "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.12.3", + "@accordproject/concerto-util": "3.14.0", "path-browserify": "1.0.1" }, "engines": { @@ -133,14 +161,14 @@ } }, "node_modules/@accordproject/concerto-util": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.12.3.tgz", - "integrity": "sha512-LWgMWwxL54LcpxzirDVKB/rDoyDTgB1q6//3CiGDNm/b91o/t+U3Q1QIVHcDpSYtUCdcyQxq3V+l14QQjmuJfg==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.0.tgz", + "integrity": "sha512-M32oVsJ9n4l/o10pz0e+AmGEpUmUQ4nwS2ixB4Jz2/kzRgVjeyHoolGKJCgDn6K8LjsGclSkMcmQ6IeF/7mC0g==", "dependencies": { "@supercharge/promise-pool": "1.7.0", "axios": "0.23.0", "colors": "1.4.0", - "debug": "4.3.1", + "debug": "4.3.4", "json-colorizer": "2.2.2", "slash": "3.0.0" }, @@ -157,10 +185,26 @@ "follow-redirects": "^1.14.4" } }, + "node_modules/@accordproject/concerto-util/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/@accordproject/concerto-vocabulary": { - "version": "3.12.3", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.12.3.tgz", - "integrity": "sha512-UDoa75d6jYPbX511Y5qd+/I87OUBt9eHL7bzpR8rvB6kdevVFVTTH4LiZ2m8QgS+IGnE7MviIxGsiumkx/QCtA==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.0.tgz", + "integrity": "sha512-u0JABqvRjw9rE18+jmXlmFgw9xJprn4QT7jEZ+uFke2Gjr8LF2HwpNkzKFI/HQPLhIo/nGdBSm8ucXZ8a+axmw==", "dependencies": { "@accordproject/concerto-metamodel": "3.8.1", "yaml": "2.2.2" @@ -3440,7 +3484,8 @@ "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true }, "node_modules/commondir": { "version": "1.0.1", @@ -3488,9 +3533,9 @@ } }, "node_modules/dayjs": { - "version": "1.10.8", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.8.tgz", - "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==" + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" }, "node_modules/debug": { "version": "4.3.1", @@ -5789,11 +5834,11 @@ } }, "node_modules/lorem-ipsum": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-2.0.3.tgz", - "integrity": "sha512-CX2r84DMWjW/DWiuzicTI9aRaJPAw2cvAGMJYZh/nx12OkTGqloj8y8FU0S8ZkKwOdqhfxEA6Ly8CW2P6Yxjwg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-2.0.8.tgz", + "integrity": "sha512-5RIwHuCb979RASgCJH0VKERn9cQo/+NcAi2BMe9ddj+gp7hujl6BI+qdOG4nVsLDpwWEJwTVYXNKP6BGgbcoGA==", "dependencies": { - "commander": "^2.17.1" + "commander": "^9.3.0" }, "bin": { "lorem-ipsum": "dist/bin/lorem-ipsum.bin.js" @@ -5803,6 +5848,14 @@ "npm": ">= 5.x" } }, + "node_modules/lorem-ipsum/node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/loupe": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", @@ -8026,6 +8079,7 @@ "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, "bin": { "uuid": "dist/bin/uuid" } diff --git a/package.json b/package.json index 56eda0a1..54a320f8 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "author": "accordproject.org", "license": "Apache-2.0", "devDependencies": { - "@accordproject/concerto-cto": "3.12.3", + "@accordproject/concerto-cto": "3.14.0", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -69,9 +69,9 @@ "webpack-cli": "4.9.1" }, "dependencies": { - "@accordproject/concerto-core": "3.12.3", - "@accordproject/concerto-util": "3.12.3", - "@accordproject/concerto-vocabulary": "3.12.3", + "@accordproject/concerto-core": "3.14.0", + "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-vocabulary": "3.14.0", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", From 6d25e39ebd57e423e67e786b9da5e4d7bd004563 Mon Sep 17 00:00:00 2001 From: Ragi Dayananda <124162737+ragi-dayananda@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:59:04 +0530 Subject: [PATCH 07/22] fix(csharp):remove semicolon (;) from map property declaration (#60) fix(csharp):remove ; from map property declaration Signed-off-by: ragi.dayananda@docusign.com Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/csharp/csharpvisitor.js | 2 +- test/codegen/__snapshots__/codegen.js.snap | 36 +++++++------------- test/codegen/fromcto/csharp/csharpvisitor.js | 6 ++-- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/codegen/fromcto/csharp/csharpvisitor.js b/lib/codegen/fromcto/csharp/csharpvisitor.js index 6a4c090d..753544e7 100644 --- a/lib/codegen/fromcto/csharp/csharpvisitor.js +++ b/lib/codegen/fromcto/csharp/csharpvisitor.js @@ -316,7 +316,7 @@ class CSharpVisitor { // write Map field if ( Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) { const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name); - parameters.fileWriter.writeLine(0, `public Dictionary ${field.getName()} { get; set; };\n`); + parameters.fileWriter.writeLine(1, `public Dictionary ${field.getName()} { get; set; }`); return null; } diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 4f77a558..b994039e 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -327,18 +327,12 @@ public class Address : Concept { public State? state { get; set; } public string zipCode { get; set; } public string country { get; set; } -public Dictionary dictionary1 { get; set; }; - -public Dictionary dictionary2 { get; set; }; - -public Dictionary dictionary3 { get; set; }; - -public Dictionary dictionary4 { get; set; }; - -public Dictionary dictionary5 { get; set; }; - -public Dictionary dictionary6 { get; set; }; - + public Dictionary dictionary1 { get; set; } + public Dictionary dictionary2 { get; set; } + public Dictionary dictionary3 { get; set; } + public Dictionary dictionary4 { get; set; } + public Dictionary dictionary5 { get; set; } + public Dictionary dictionary6 { get; set; } } //Dummy implementation of the scalar declaration to avoid compilation errors. class Time_Dummy {} @@ -5459,18 +5453,12 @@ public class Address : Concept { public State? state { get; set; } public string zipCode { get; set; } public string country { get; set; } -public Dictionary dictionary1 { get; set; }; - -public Dictionary dictionary2 { get; set; }; - -public Dictionary dictionary3 { get; set; }; - -public Dictionary dictionary4 { get; set; }; - -public Dictionary dictionary5 { get; set; }; - -public Dictionary dictionary6 { get; set; }; - + public Dictionary dictionary1 { get; set; } + public Dictionary dictionary2 { get; set; } + public Dictionary dictionary3 { get; set; } + public Dictionary dictionary4 { get; set; } + public Dictionary dictionary5 { get; set; } + public Dictionary dictionary6 { get; set; } } //Dummy implementation of the scalar declaration to avoid compilation errors. class Time_Dummy {} diff --git a/test/codegen/fromcto/csharp/csharpvisitor.js b/test/codegen/fromcto/csharp/csharpvisitor.js index 7d434483..91dce556 100644 --- a/test/codegen/fromcto/csharp/csharpvisitor.js +++ b/test/codegen/fromcto/csharp/csharpvisitor.js @@ -1525,7 +1525,7 @@ public class SampleModel : Concept { mockMapDeclaration.getValue.returns({ getType: getValueType }); csharpVisitor.visitField(mockField, param); - param.fileWriter.writeLine.withArgs(0, 'public Dictionary Map1 { get; set; };\n').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'public Dictionary Map1 { get; set; }').calledOnce.should.be.ok; }); it('should write a line for field name and type thats a map of ', () => { @@ -1551,7 +1551,7 @@ public class SampleModel : Concept { mockMapDeclaration.getValue.returns({ getType: getValueType }); csharpVisitor.visitField(mockField, param); - param.fileWriter.writeLine.withArgs(0, 'public Dictionary Map1 { get; set; };\n').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'public Dictionary Map1 { get; set; }').calledOnce.should.be.ok; }); it('should write a line for field name and type thats a map of ', () => { @@ -1577,7 +1577,7 @@ public class SampleModel : Concept { mockMapDeclaration.getValue.returns({ getType: getValueType }); csharpVisitor.visitField(mockField, param); - param.fileWriter.writeLine.withArgs(0, 'public Dictionary Map1 { get; set; };\n').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'public Dictionary Map1 { get; set; }').calledOnce.should.be.ok; }); }); From 0f05e7f5f44499e16dcdebd0ade53691785a9a98 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Wed, 11 Oct 2023 12:38:51 +0100 Subject: [PATCH 08/22] chore: fix package version Signed-off-by: Jonathan Casey --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54a320f8..8510578b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@accordproject/concerto-codegen", - "version": "3.16.0", + "version": "3.16.1", "description": "CodeGen for the Concerto Modeling Language", "homepage": "https://github.com/accordproject/concerto", "engines": { From 99b4e0985bcde6a812fa9328b1f384b0f21d7f50 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 12:46:03 +0100 Subject: [PATCH 09/22] chore(actions): publish v3.16.2 to npm (#61) Signed-off-by: GitHub Signed-off-by: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Co-authored-by: Jonathan-Casey Co-authored-by: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Signed-off-by: Jonathan Casey --- package-lock.json | 4 ++-- package.json | 2 +- types/lib/codegen/fromcto/plantuml/plantumlvisitor.d.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1dc43be..b4c63e2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@accordproject/concerto-codegen", - "version": "3.16.0", + "version": "3.16.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@accordproject/concerto-codegen", - "version": "3.16.0", + "version": "3.16.2", "license": "Apache-2.0", "dependencies": { "@accordproject/concerto-core": "3.14.0", diff --git a/package.json b/package.json index 8510578b..d5fd36b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@accordproject/concerto-codegen", - "version": "3.16.1", + "version": "3.16.2", "description": "CodeGen for the Concerto Modeling Language", "homepage": "https://github.com/accordproject/concerto", "engines": { diff --git a/types/lib/codegen/fromcto/plantuml/plantumlvisitor.d.ts b/types/lib/codegen/fromcto/plantuml/plantumlvisitor.d.ts index c07983c0..0afba334 100644 --- a/types/lib/codegen/fromcto/plantuml/plantumlvisitor.d.ts +++ b/types/lib/codegen/fromcto/plantuml/plantumlvisitor.d.ts @@ -63,7 +63,9 @@ declare class PlantUMLVisitor extends DiagramVisitor { /** * Escape fully qualified names. We preserve the dots in the * package name, remove the '@' symbol because it is invalid - * and remove the dots in the version (because otherwise packages get created) + * and remove the dots in the version (because otherwise packages get created). + * We also replace all '-' characters with '_' because they are invalid in + * PlantUML identifiers as '-' can appear in a semver string. * @param {String} input - the object being visited * @return {String} string - the parameter * @protected From 36e2e7f2eeab46f12fc8b6a75fa87c20111f82df Mon Sep 17 00:00:00 2001 From: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:17:02 +0100 Subject: [PATCH 10/22] feat(map): Codegen for GraphQL Target (#66) * feat(map): add graphqlvisitor Signed-off-by: Jonathan Casey * test(map): update snapshot Signed-off-by: Jonathan Casey * test(map): adds graphqlvisitor Signed-off-by: Jonathan Casey * test(map): restores sandbox Signed-off-by: Jonathan Casey --------- Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/graphql/graphqlvisitor.js | 25 +++++++++- test/codegen/__snapshots__/codegen.js.snap | 48 +++++++++++++++++++ .../codegen/fromcto/graphql/graphqlvisitor.js | 35 ++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/lib/codegen/fromcto/graphql/graphqlvisitor.js b/lib/codegen/fromcto/graphql/graphqlvisitor.js index bb0f2323..a8100b3c 100644 --- a/lib/codegen/fromcto/graphql/graphqlvisitor.js +++ b/lib/codegen/fromcto/graphql/graphqlvisitor.js @@ -15,6 +15,7 @@ 'use strict'; const util = require('util'); +const { ModelUtil } = require('@accordproject/concerto-core'); /** * Convert the contents of a ModelManager to GraphQL types, based on @@ -52,7 +53,7 @@ class GraphQLVisitor { } else if (thing.isField?.()) { return this.visitField(thing, parameters); } else if (thing.isMapDeclaration?.()) { - return; + return this.visitMapDeclaration(thing, parameters); } else if (thing.isRelationship?.()) { return this.visitRelationship(thing, parameters); } else if (thing.isEnumValue?.()) { @@ -171,6 +172,28 @@ class GraphQLVisitor { return null; } + /** + * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + visitMapDeclaration(mapDeclaration, parameters) { + const keyType = mapDeclaration.getKey().getType(); + const valueType = mapDeclaration.getValue().getType(); + + let key = ModelUtil.isPrimitiveType(keyType) ? this.toGraphQLType(keyType) : keyType; + let value = ModelUtil.isPrimitiveType(valueType) ? this.toGraphQLType(valueType) : valueType; + + parameters.fileWriter.writeLine(0, `type ${mapDeclaration.getName()} {`); + parameters.fileWriter.writeLine(1, `key: ${key}`); + parameters.fileWriter.writeLine(1, `value: ${value}`); + parameters.fileWriter.writeLine(0, '}'); + + return null; + } + /** * Visitor design pattern * @param {Relationship} relationship - the object being visited diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index b994039e..c3b0b016 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -632,6 +632,30 @@ type Address { dictionary5: Map5! dictionary6: Map6! } +type Map1 { + key: String + value: String +} +type Map2 { + key: String + value: DateTime +} +type Map3 { + key: String + value: SSN +} +type Map4 { + key: String + value: Concept +} +type Map5 { + key: SSN + value: String +} +type Map6 { + key: SSN + value: Employee +} type Company { name: String! headquarters: Address! @@ -5758,6 +5782,30 @@ type Address { dictionary5: Map5! dictionary6: Map6! } +type Map1 { + key: String + value: String +} +type Map2 { + key: String + value: DateTime +} +type Map3 { + key: String + value: SSN +} +type Map4 { + key: String + value: Concept +} +type Map5 { + key: SSN + value: String +} +type Map6 { + key: SSN + value: Employee +} type Company { name: String! headquarters: Address! diff --git a/test/codegen/fromcto/graphql/graphqlvisitor.js b/test/codegen/fromcto/graphql/graphqlvisitor.js index 1bf7db3a..a944000a 100644 --- a/test/codegen/fromcto/graphql/graphqlvisitor.js +++ b/test/codegen/fromcto/graphql/graphqlvisitor.js @@ -23,10 +23,14 @@ const GraphQLVisitor = require('../../../../lib/codegen/fromcto/graphql/graphqlv const ModelFile = require('@accordproject/concerto-core').ModelFile; const ModelManager = require('@accordproject/concerto-core').ModelManager; const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; +const MapDeclaration = require('@accordproject/concerto-core').MapDeclaration; const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration; const Field = require('@accordproject/concerto-core').Field; const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; +const { ModelUtil } = require('@accordproject/concerto-core'); + +let sandbox = sinon.createSandbox(); const MODEL_WITH_DECORATORS = ` namespace test @@ -339,6 +343,37 @@ describe('GraphQLVisitor', function () { }); }); + describe('visitMapDeclaration', () => { + it('should write a type for a Map', () => { + let param = { + fileWriter: mockFileWriter + }; + + sandbox.stub(ModelUtil, 'isPrimitiveType').callsFake(() => { + return true; + }); + + const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); + const getKeyType = sinon.stub(); + const getValueType = sinon.stub(); + + getKeyType.returns('String'); + getValueType.returns('String'); + mockMapDeclaration.getName.returns('map1'); + mockMapDeclaration.getKey.returns({ getType: getKeyType }); + mockMapDeclaration.getValue.returns({ getType: getValueType }); + + graphQLVisitor.visitMapDeclaration(mockMapDeclaration, param); + + param.fileWriter.writeLine.withArgs(0, 'type map1 {').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'key: String').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(1, 'value: String').calledOnce.should.be.ok; + param.fileWriter.writeLine.withArgs(0, '}').calledOnce.should.be.ok; + + sandbox.restore(); + }); + }); + describe('visitRelationship', () => { it('should write a line for a relationship', () => { let param = { From e4630cd87bb192d351ddb30177e6386768e07022 Mon Sep 17 00:00:00 2001 From: Jonathan-Casey <109082377+Jonathan-Casey@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:17:25 +0100 Subject: [PATCH 11/22] feat!(codegen): remove loopback src (#59) feat(codegen): remove loopback src Signed-off-by: Jonathan Casey --- .../fromcto/loopback/loopbackvisitor.js | 584 ------- .../fromcto/loopback/loopbackvisitor.js | 1367 ----------------- .../loopback/loopbackvisitorcircular.js | 64 - 3 files changed, 2015 deletions(-) delete mode 100644 lib/codegen/fromcto/loopback/loopbackvisitor.js delete mode 100644 test/codegen/fromcto/loopback/loopbackvisitor.js delete mode 100644 test/codegen/fromcto/loopback/loopbackvisitorcircular.js diff --git a/lib/codegen/fromcto/loopback/loopbackvisitor.js b/lib/codegen/fromcto/loopback/loopbackvisitor.js deleted file mode 100644 index 339da9b4..00000000 --- a/lib/codegen/fromcto/loopback/loopbackvisitor.js +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const debug = require('debug')('concerto-core:loopbackvisitor'); -const util = require('util'); - -/** - * Convert a fully qualified type name, for example org.example.mynetwork.MyAsset, - * into a name that is safe for use as a LoopBack model name. - * @private - * @param {String} fqn The fully qualified type name. - * @returns {String} A name that is safe for use as a LoopBack model name. - */ -function loopbackify(fqn) { - return fqn.replace(/\./g, '_'); -} - -/** - * Convert the contents of a {@link ModelManager} instance to a set of LoopBack - * Definition Language model files - one per concrete asset and transaction type. - * Set a fileWriter property (instance of {@link FileWriter}) on the parameters - * object to control where the generated code is written to disk. - * @private - * @class - * @memberof module:concerto-codegen - */ -class LoopbackVisitor { - - /** - * Constructor. - * @param {boolean} [namespaces] - whether or not namespaces should be used. - */ - constructor(namespaces) { - this.namespaces = !!namespaces; - } - - /** - * Visitor design pattern - * @param {Object} thing - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @public - */ - visit(thing, parameters) { - if (thing.isModelManager?.()) { - return this.visitModelManager(thing, parameters); - } else if (thing.isModelFile?.()) { - return this.visitModelFile(thing, parameters); - } else if (thing.isAsset?.()) { - return this.visitAssetDeclaration(thing, parameters); - } else if (thing.isParticipant?.()) { - return this.visitParticipantDeclaration(thing, parameters); - } else if (thing.isConcept?.()) { - return this.visitConceptDeclaration(thing, parameters); - } else if (thing.isMapDeclaration?.()) { - return; - } else if (thing.isTransaction?.()) { - return this.visitTransactionDeclaration(thing, parameters); - } else if (thing.isEvent?.()) { - return this.visitEventDeclaration(thing, parameters); - } else if (thing.isEnum?.()) { - return this.visitEnumDeclaration(thing, parameters); - } else if (thing.isTypeScalar?.()) { - return this.visitField(thing.getScalarField(), parameters); - } else if (thing.isField?.()) { - return this.visitField(thing, parameters); - } else if (thing.isRelationship?.()) { - return this.visitRelationshipDeclaration(thing, parameters); - } else if (thing.isEnumValue?.()) { - return this.visitEnumValueDeclaration(thing, parameters); - } else { - throw new Error('Unrecognised type: ' + typeof thing + ', value: ' + util.inspect(thing, { showHidden: true, depth: 1 })); - } - } - - /** - * Visitor design pattern - * @param {ModelManager} modelManager - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitModelManager(modelManager, parameters) { - debug('entering visitModelManager'); - - // Save the model manager so that we have access to it later. - parameters.modelManager = modelManager; - - // Visit all of the files in the model manager. - let jsonSchemas = []; - modelManager.getModelFiles().forEach((modelFile) => { - jsonSchemas = jsonSchemas.concat(modelFile.accept(this, parameters)); - }); - return jsonSchemas; - - } - - /** - * Visitor design pattern - * @param {ModelFile} modelFile - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitModelFile(modelFile, parameters) { - debug('entering visitModelFile', modelFile.getNamespace()); - - // Save the model file so that we have access to it later. - parameters.modelFile = modelFile; - - // Visit all of the asset and transaction declarations, but ignore the abstract ones. - let jsonSchemas = []; - modelFile.getAssetDeclarations() - .concat(modelFile.getConceptDeclarations()) - .concat(modelFile.getParticipantDeclarations()) - .concat(modelFile.getTransactionDeclarations()) - .forEach((declaration) => { - parameters.first = true; - jsonSchemas.push(declaration.accept(this, parameters)); - }); - return jsonSchemas; - - } - - /** - * Visitor design pattern - * @param {AssetDeclaration} assetDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitAssetDeclaration(assetDeclaration, parameters) { - debug('entering visitAssetDeclaration', assetDeclaration.getName()); - - // If this is the first declaration, then we are building a schema for this asset. - let jsonSchema = {}; - let name = this.namespaces ? assetDeclaration.getFullyQualifiedName() : assetDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `An asset named ${assetDeclaration.getName()}`, - plural: name, - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'asset' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(assetDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {ParticipantDeclaration} participantDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitParticipantDeclaration(participantDeclaration, parameters) { - debug('entering visitParticipantDeclaration', participantDeclaration.getName()); - - // If this is the first declaration, then we are building a schema for this participant. - let jsonSchema = {}; - let name = this.namespaces ? participantDeclaration.getFullyQualifiedName() : participantDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `A participant named ${participantDeclaration.getName()}`, - plural: name, - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'participant' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(participantDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {ConceptDeclaration} conceptDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitConceptDeclaration(conceptDeclaration, parameters) { - debug('entering visitConceptDeclaration', conceptDeclaration.getName()); - - // If this is the top declaration, then we are building a schema for this concept. - let jsonSchema = {}; - let name = this.namespaces ? conceptDeclaration.getFullyQualifiedName() : conceptDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `A concept named ${conceptDeclaration.getName()}`, - plural: name, - // Concepts are not PersistedModel instances as they cannot exist by themselves. - // base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'concept' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(conceptDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {TransactionDeclaration} transactionDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitTransactionDeclaration(transactionDeclaration, parameters) { - debug('entering visitTransactionDeclaration', transactionDeclaration.getName()); - - // If this is the top declaration, then we are building a schema for this transaction. - let jsonSchema = {}; - let name = this.namespaces ? transactionDeclaration.getFullyQualifiedName() : transactionDeclaration.getName(); - if (parameters.first) { - jsonSchema = { - $first: true, - name: loopbackify(name), - description: `A transaction named ${transactionDeclaration.getName()}`, - plural: name, - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'transaction' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - parameters.first = false; - } else { - jsonSchema.type = 'Object'; - } - - // Apply all the common schema elements. - return this.visitClassDeclarationCommon(transactionDeclaration, parameters, jsonSchema); - - } - - /** - * Visitor design pattern - * @param {EventDeclaration} eventDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitEventDeclaration(eventDeclaration, parameters) { - debug('entering visitEventDeclaration', eventDeclaration.getName()); - return null; - } - - /** - * Visitor design pattern - * @param {ClassDeclaration} classDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @param {Object} jsonSchema - the base JSON Schema object to use - * @return {Object} the result of visiting or null - * @private - */ - visitClassDeclarationCommon(classDeclaration, parameters, jsonSchema) { - debug('entering visitClassDeclarationCommon', classDeclaration.getName()); - - // remember that we have visited this fqn - // in case one of our properties is of the same type (issue #2193) - parameters[classDeclaration.getFullyQualifiedName()] = 'visited'; - - // Add information from the class declaration into the composer section. - if (jsonSchema.options && jsonSchema.options.composer) { - Object.assign(jsonSchema.options.composer, { - namespace: classDeclaration.getNamespace(), - name: classDeclaration.getName(), - fqn: classDeclaration.getFullyQualifiedName(), - abstract: classDeclaration.isAbstract() - }); - } - - // Set the required properties into the schema. - Object.assign(jsonSchema, { - properties: {} - }); - - // If no description exists, add it now. - if (!jsonSchema.description) { - jsonSchema.description = `An instance of ${classDeclaration.getName()}`; - } - - // Every class declaration has a $class property. - jsonSchema.properties.$class = { - type: 'string', - default: classDeclaration.getFullyQualifiedName(), - required: false, - description: 'The class identifier for this type' - }; - - // Walk over all of the properties of this class and its super classes. - classDeclaration.getProperties().forEach((property) => { - - // Get the schema for the property - jsonSchema.properties[property.getName()] = property.accept(this, parameters); - }); - - // For transaction declarations, we need to change the model slightly. - if (classDeclaration.getIdentifierFieldName()) { - // The ID field will be supplied at submission time, not by the client. - jsonSchema.forceId = true; - const identifierFieldName = classDeclaration.getIdentifierFieldName(); - jsonSchema.properties[identifierFieldName].generated = true; - jsonSchema.properties[identifierFieldName].required = false; - } - - // If this is a top level schema, now we need to write it to disk. - if (jsonSchema.$first) { - delete jsonSchema.$first; - let fileContents = JSON.stringify(jsonSchema, null, 4); - if (parameters.fileWriter) { - let name = this.namespaces ? classDeclaration.getFullyQualifiedName() : classDeclaration.getName(); - let fileName = `${name}.json`; - parameters.fileWriter.openFile(fileName); - parameters.fileWriter.write(fileContents); - parameters.fileWriter.closeFile(); - } - } - - // Return the created schema. - return jsonSchema; - - } - - /** - * Given a primitive Concerto type returns the corresponding loopback type - * @param {string} type - the concerto primitive type name - * @return {string} the loopback type - * @private - */ - static toLoopbackType(type) { - - let result = 'string'; - - switch (type) { - case 'String': - result = 'string'; - break; - case 'Double': - case 'Integer': - case 'Long': - result= 'number'; - break; - case 'DateTime': - result = 'date'; - break; - case 'Boolean': - result = 'boolean'; - break; - } - - return result; - } - - /** - * Visitor design pattern - * @param {Field} field - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitField(field, parameters) { - debug('entering visitField', field.getName()); - - // Is this a primitive typed property? - let jsonSchema; - if (field.isPrimitive()) { - - // Render the type as JSON Schema. - jsonSchema = {}; - jsonSchema.type = LoopbackVisitor.toLoopbackType(field.getType()); - - // If this field has a default value, add it. - if (field.getDefaultValue()) { - jsonSchema.default = field.getDefaultValue(); - } - - // If this is the identifying field, mark it as such. - if (field.getName() === field.getParent().getIdentifierFieldName()) { - jsonSchema.id = true; - jsonSchema.description = 'The instance identifier for this type'; - } - - // Is this an enumeration? - } else if (field.isTypeEnum()) { - - // Look up the type of the property. - let type = field.getParent().getModelFile().getType(field.getType()); - - // Visit it, and grab the schema. - jsonSchema = type.accept(this, parameters); - - // If this field has a default value, add it. - if (field.getDefaultValue()) { - jsonSchema.default = field.getDefaultValue(); - } - - // Not primitive, so must be a class! - } else { - - // Render the type as JSON Schema. - let typeName = this.namespaces ? field.getFullyQualifiedTypeName() : field.getType(); - jsonSchema = { - type: loopbackify(typeName) - }; - - // Look up the type of the property. - let type = field.getParent().getModelFile().getType(field.getType()); - - // Visit it, but ignore the response. - // We do not visit types that have already been visited to prevent recursion (issue #2193) - if(!parameters[field.getFullyQualifiedTypeName()]) { - type.accept(this, parameters); - } - } - - // Is the type an array? - if (field.isArray()) { - - // Set the type to an array of the already set type from above. - jsonSchema.type = [ jsonSchema.type ]; - - // Array properties have to be optional and have a default value as LoopBack does not cope with - // the difference between a required array property and an empty array property (issue #3438). - jsonSchema.default = []; - jsonSchema.required = false; - - } else { - - // Is the field required? - jsonSchema.required = !field.isOptional(); - - } - - // Return the schema. - return jsonSchema; - - } - - /** - * Visitor design pattern - * @param {EnumDeclaration} enumDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitEnumDeclaration(enumDeclaration, parameters) { - debug('entering visitEnumDeclaration', enumDeclaration.getName()); - - // Create the schema. - let jsonSchema = { - type: 'string' - }; - - // Walk over all of the properties which should just be enum value declarations. - jsonSchema.enum = enumDeclaration.getProperties().map((property) => { - return property.accept(this, parameters); - }); - - // Return the schema. - return jsonSchema; - - } - - /** - * Visitor design pattern - * @param {EnumValueDeclaration} enumValueDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitEnumValueDeclaration(enumValueDeclaration, parameters) { - debug('entering visitEnumValueDeclaration', enumValueDeclaration.getName()); - - // The schema in this case is just the name of the value. - return enumValueDeclaration.getName(); - - } - - /** - * Visitor design pattern - * @param {RelationshipDeclaration} relationshipDeclaration - the object being visited - * @param {Object} parameters - the parameter - * @return {Object} the result of visiting or null - * @private - */ - visitRelationshipDeclaration(relationshipDeclaration, parameters) { - debug('entering visitRelationship', relationshipDeclaration.getName()); - - // Create the schema. - let jsonSchema = { - type: 'any', - description: `The identifier of an instance of ${relationshipDeclaration.getName()}`, - required: !relationshipDeclaration.isOptional() - }; - - // Is the type an array? - if (relationshipDeclaration.isArray()) { - jsonSchema.type = [ jsonSchema.type ]; - } - - // Return the schema. - return jsonSchema; - - } - -} - -module.exports = LoopbackVisitor; diff --git a/test/codegen/fromcto/loopback/loopbackvisitor.js b/test/codegen/fromcto/loopback/loopbackvisitor.js deleted file mode 100644 index 1905efdf..00000000 --- a/test/codegen/fromcto/loopback/loopbackvisitor.js +++ /dev/null @@ -1,1367 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const chai = require('chai'); -const should = chai.should(); -const sinon = require('sinon'); - -let LoopbackVisitor= require('../../../../lib/codegen/fromcto/loopback/loopbackvisitor.js'); - -const AssetDeclaration = require('@accordproject/concerto-core').AssetDeclaration; -const ParticipantDeclaration = require('@accordproject/concerto-core').ParticipantDeclaration; -const EventDeclaration = require('@accordproject/concerto-core').EventDeclaration; -const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; -const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration; -const ConceptDeclaration = require('@accordproject/concerto-core').ConceptDeclaration; -const EnumValueDeclaration = require('@accordproject/concerto-core').EnumValueDeclaration; -const Field = require('@accordproject/concerto-core').Field; -const ModelFile = require('@accordproject/concerto-core').ModelFile; -const ModelManager = require('@accordproject/concerto-core').ModelManager; -const RelationshipDeclaration = require('@accordproject/concerto-core').RelationshipDeclaration; -const TransactionDeclaration = require('@accordproject/concerto-core').TransactionDeclaration; -const FileWriter = require('@accordproject/concerto-util').FileWriter; - -describe('LoopbackVisitor', () => { - let loopbackVisit; - let mockFileWriter; - beforeEach(() => { - loopbackVisit = new LoopbackVisitor(); - mockFileWriter = sinon.createStubInstance(FileWriter); - }); - - describe('visit', () => { - let param; - beforeEach(() => { - param = { - property1: 'value1' - }; - }); - - it('should call visitModelManager for a ModelManager', () => { - let thing = sinon.createStubInstance(ModelManager); - thing.isModelManager.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitModelManager'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitModelFile for a ModelFile', () => { - let thing = sinon.createStubInstance(ModelFile); - thing.isModelFile.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitModelFile'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitAssetDeclaration for a AssetDeclaration', () => { - let thing = sinon.createStubInstance(AssetDeclaration); - thing.isAsset.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitAssetDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitParticipantDeclaration for a ParticipantDeclaration', () => { - let thing = sinon.createStubInstance(ParticipantDeclaration); - thing.isParticipant.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitParticipantDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitConceptDeclaration for a ConceptDeclaration', () => { - let thing = sinon.createStubInstance(ConceptDeclaration); - thing.isConcept.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitConceptDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitTransactionDeclaration for a TransactionDeclaration', () => { - let thing = sinon.createStubInstance(TransactionDeclaration); - thing.isTransaction.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitTransactionDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitEventDeclaration for a EventDeclaration', () => { - let thing = sinon.createStubInstance(EventDeclaration); - thing.isEvent.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitEventDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitEnumDeclaration for a EnumDeclaration', () => { - let thing = sinon.createStubInstance(EnumDeclaration); - thing.isEnum.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitEnumDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitField for a Field', () => { - let thing = sinon.createStubInstance(Field); - thing.isField.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitField'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitRelationshipDeclaration for a RelationshipDeclaration', () => { - let thing = sinon.createStubInstance(RelationshipDeclaration); - thing.isRelationship.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitRelationshipDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should call visitEnumValueDeclaration for a EnumValueDeclaration', () => { - let thing = sinon.createStubInstance(EnumValueDeclaration); - thing.isEnumValue.returns(true); - let mockSpecialVisit = sinon.stub(loopbackVisit, 'visitEnumValueDeclaration'); - mockSpecialVisit.returns('Duck'); - - loopbackVisit.visit(thing, param).should.deep.equal('Duck'); - - mockSpecialVisit.calledWith(thing, param).should.be.ok; - }); - - it('should throw an error when an unrecognised type is supplied', () => { - let thing = 'Something of unrecognised type'; - - (() => { - loopbackVisit.visit(thing, param); - }).should.throw('Unrecognised type: string, value: \'Something of unrecognised type\''); - }); - }); - - describe('visitModelManager', () => { - it('should return a value of the concatenated output of each modelFiles accept', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.accept.returns(['Duck', 'Duck']); - let mockModelFile2 = sinon.createStubInstance(ModelFile); - mockModelFile2.isModelFile.returns(true); - mockModelFile2.accept.returns(['Duck', 'Goose']); - - let mockModelManager = sinon.createStubInstance(ModelManager); - mockModelManager.isModelManager.returns(true); - mockModelManager.getModelFiles.returns([mockModelFile, mockModelFile2]); - - loopbackVisit.visitModelManager(mockModelManager, param).should.deep.equal(['Duck', 'Duck', 'Duck', 'Goose']); - mockModelFile.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - mockModelFile2.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - param.should.deep.equal({ - modelManager: mockModelManager - }); - }); - }); - - describe('visitModelFile', () => { - it('should return an array of each declaration\'s accept', () => { - let param = {}; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.accept.returns('Duck'); - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.accept.returns('Duck'); - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.accept.returns('Duck'); - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.accept.returns('Goose'); - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getNamespace.returns; - mockModelFile.getAssetDeclarations.returns([mockAssetDeclaration]); - mockModelFile.getTransactionDeclarations.returns([mockTransactionDeclaration]); - mockModelFile.getConceptDeclarations.returns([mockConceptDeclaration]); - mockModelFile.getParticipantDeclarations.returns([mockParticipantDeclaration]); - - loopbackVisit.visitModelFile(mockModelFile, param).should.deep.equal(['Duck', 'Duck', 'Duck', 'Goose']); - - param.should.deep.equal({ - first: true, - modelFile: mockModelFile - }); - }); - }); - - describe('visitAssetDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockAssetDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockAssetDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitAssetDeclaration(mockAssetDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockAssetDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'An asset named Bob', - plural: 'Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'asset' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockAssetDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitAssetDeclaration(mockAssetDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration); - mockAssetDeclaration.isAsset.returns(true); - mockAssetDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockAssetDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'An asset named Bob', - plural: 'org.acme.Person.Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'asset' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockAssetDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitAssetDeclaration(mockAssetDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitParticipantDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockParticipantDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockParticipantDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitParticipantDeclaration(mockParticipantDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockParticipantDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'A participant named Bob', - plural: 'Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'participant' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockParticipantDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitParticipantDeclaration(mockParticipantDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration); - mockParticipantDeclaration.isParticipant.returns(true); - mockParticipantDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockParticipantDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'A participant named Bob', - plural: 'org.acme.Person.Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'participant' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockParticipantDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitParticipantDeclaration(mockParticipantDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitConceptDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockConceptDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockConceptDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitConceptDeclaration(mockConceptDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockConceptDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'A concept named Bob', - plural: 'Bob', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'concept' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockConceptDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitConceptDeclaration(mockConceptDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockConceptDeclaration = sinon.createStubInstance(ConceptDeclaration); - mockConceptDeclaration.isConcept.returns(true); - mockConceptDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockConceptDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'A concept named Bob', - plural: 'org.acme.Person.Bob', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'concept' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockConceptDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitConceptDeclaration(mockConceptDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitTransactionDeclaration', () => { - it('should return the value of visitClassDeclarationCommon using a schema with just type', () => { - let param = {}; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockTransactionDeclaration.getName.returns('Bob'); - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockTransactionDeclaration, param, { - type: 'Object' - }).returns('Class Declaration'); - - loopbackVisit.visitTransactionDeclaration(mockTransactionDeclaration, param).should.deep.equal('Class Declaration'); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema', () => { - let param = { - first: true - }; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockTransactionDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'Bob', - description: 'A transaction named Bob', - plural: 'Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'transaction' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockTransactionDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.visitTransactionDeclaration(mockTransactionDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - - it('should return the value of visitClassDeclarationCommon buiulding the schema using the fullyQualifiedName', () => { - let param = { - first: true - }; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person.Bob'); - mockTransactionDeclaration.getName.returns('Bob'); - - let expectedSchema = { - $first: true, - name: 'org_acme_Person_Bob', - description: 'A transaction named Bob', - plural: 'org.acme.Person.Bob', - base: 'PersistedModel', - idInjection: false, - options: { - validateUpsert: true, - composer: { - type: 'transaction' - } - }, - properties: {}, - validations: [], - relations: {}, - acls: [], - methods: [] - }; - - let mockVisitClassDeclarationCommon = sinon.stub(loopbackVisit, 'visitClassDeclarationCommon'); - mockVisitClassDeclarationCommon.withArgs(mockTransactionDeclaration, param, expectedSchema).returns('Class Declaration'); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitTransactionDeclaration(mockTransactionDeclaration, param).should.deep.equal('Class Declaration'); - param.should.have.property('first', false); - }); - }); - - describe('visitEventDeclaration', () => { - it('should return null', () => { - let mockEventDeclaration = sinon.createStubInstance(EventDeclaration); - mockEventDeclaration.isEvent.returns(true); - mockEventDeclaration.getName.returns('Bob'); - - should.equal(loopbackVisit.visitEventDeclaration(mockEventDeclaration, {}), null); - }); - }); - - describe('visitClassDeclarationCommon', () => { - it('should return a created JSONSchema', () => { - let param = {}; - let jsonSchema = { - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal({ - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - description: 'The class identifier for this type', - required: false - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }); - }); - - it('should return a created JSONSchema autogenerating the description', () => { - let param = {}; - let jsonSchema = { - title: 'A schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal({ - title: 'A schema', - description: 'An instance of Person', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - description: 'The class identifier for this type', - required: false - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }); - }); - - it('should return a created JSONSchema adding to the composer options', () => { - let param = {}; - let jsonSchema = { - title: 'A schema', - description: 'A particularly good schema', - options: { - composer: {} - } - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getNamespace.returns('org.acme'); - mockClassDeclaration.isAbstract.returns(true); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal({ - title: 'A schema', - description: 'A particularly good schema', - options: { - composer: { - namespace: 'org.acme', - name: 'Person', - fqn: 'org.acme.Person', - abstract: true - } - }, - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - description: 'The class identifier for this type', - required: false - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }); - }); - - it('should return a created top level JSON Schema and write it to a file with the name of the FQN', () => { - let param = { - fileWriter: mockFileWriter - }; - let jsonSchema = { - $first: true, - $schema: true, - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }; - - loopbackVisit.namespaces = true; - - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - - param.fileWriter.openFile.withArgs('org.acme.Person.json').calledOnce.should.be.ok; - param.fileWriter.write.withArgs(JSON.stringify(expectedResult, null, 4)).calledOnce.should.be.ok; - param.fileWriter.closeFile.calledOnce.should.be.ok; - }); - - it('should return a created top level JSON Schema and write it to a file with the name of the FQN', () => { - let param = { - fileWriter: null - }; - let jsonSchema = { - $first: true, - $schema: true, - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }; - - loopbackVisit.namespaces = true; - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - }); - - it('should return a created top level JSONSchema and write it to a file with the name of the class name', () => { - let param = { - fileWriter: mockFileWriter - }; - let jsonSchema = { - $first: true, - $schema: true, - title: 'A schema', - description: ' A particularly good schema' - }; - - let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); - mockClassDeclaration.isClassDeclaration.returns(true); - mockClassDeclaration.getName.returns('Person'); - mockClassDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockClassDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return 'Guineapig'; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return 'Goldfish'; - } - } - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: 'Guineapig', - Trevor: 'Goldfish' - } - }; - loopbackVisit.visitClassDeclarationCommon(mockClassDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - - param.fileWriter.openFile.withArgs('Person.json').calledOnce.should.be.ok; - param.fileWriter.write.withArgs(JSON.stringify(expectedResult, null, 4)).calledOnce.should.be.ok; - param.fileWriter.closeFile.calledOnce.should.be.ok; - }); - - it('should return a created top level JSONSchema with extra data if a TransactionDeclaration', () => { - let param = {}; - let jsonSchema = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - noseLength: {} - } - }; - - let mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration); - mockTransactionDeclaration.isTransaction.returns(true); - mockTransactionDeclaration.getName.returns('Person'); - mockTransactionDeclaration.getFullyQualifiedName.returns('org.acme.Person'); - mockTransactionDeclaration.getIdentifierFieldName.returns('Bob'); - mockTransactionDeclaration.getProperties.returns([ - { - getName: () => { - return 'Bob'; - }, - isOptional: () => { - return true; - }, - accept: () => { - return { - prop: 'Guineapig' - }; - } - }, - { - getName: () => { - return 'Trevor'; - }, - isOptional: () => { - return false; - }, - accept: () => { - return { - prop: 'Goldfish' - }; - } - }, - ]); - let expectedResult = { - $schema: true, - title: 'A schema', - description: ' A particularly good schema', - properties: { - $class: { - type: 'string', - default: 'org.acme.Person', - required: false, - description: 'The class identifier for this type' - }, - Bob: { - prop: 'Guineapig', - generated: true, - required: false - }, - Trevor: { - prop: 'Goldfish' - }, - }, - forceId: true, - - }; - loopbackVisit.visitClassDeclarationCommon(mockTransactionDeclaration, param, jsonSchema).should.deep.equal(expectedResult); - }); - }); - - describe('toLoopbackType', () => { - it('should return date for DateTime', () => { - LoopbackVisitor.toLoopbackType('DateTime').should.deep.equal('date'); - }); - - it('should return boolean for Boolean', () => { - LoopbackVisitor.toLoopbackType('Boolean').should.deep.equal('boolean'); - }); - - it('should return String for String', () => { - LoopbackVisitor.toLoopbackType('String').should.deep.equal('string'); - }); - - it('should return number for Double', () => { - LoopbackVisitor.toLoopbackType('Double').should.deep.equal('number'); - }); - - it('should return number for Long', () => { - LoopbackVisitor.toLoopbackType('Long').should.deep.equal('number'); - }); - - it('should return number for Integer', () => { - LoopbackVisitor.toLoopbackType('Integer').should.deep.equal('number'); - }); - - it('should return the string as default', () => { - LoopbackVisitor.toLoopbackType('Penguin').should.deep.equal('string'); - }); - }); - - describe('visitField', () => { - it('should return a JSON schema for a primitive', () => { - let param = {}; - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isPrimitive.returns(true); - mockField.getType.returns('String'); - mockField.getParent.returns({ - getIdentifierFieldName: () => { - return 'Farmer'; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'string', - required: true - }); - }); - - it('should return a JSON schema for a primitive with a default value and when it is an identifying field', () => { - let param = {}; - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Farmer'); - mockField.isPrimitive.returns(true); - mockField.getType.returns('String'); - mockField.getParent.returns({ - getIdentifierFieldName: () => { - return 'Farmer'; - } - }); - mockField.getDefaultValue.returns('Ploughed'); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'string', - default: 'Ploughed', - id: true, - description: 'The instance identifier for this type', - required: true - }); - }); - - it('should return a JSON schema for an enumeration', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.accept.withArgs(loopbackVisit, param).returns({ - type: 'Square' - }); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isTypeEnum.returns(true); - mockField.getType.returns('Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Square', - required: true - }); - }); - - it('should return a JSON schema for an enumeration with a default value', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.accept.withArgs(loopbackVisit, param).returns({ - type: 'Square' - }); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isTypeEnum.returns(true); - mockField.getType.returns('Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - mockField.getDefaultValue.returns('Trampled'); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Square', - default: 'Trampled', - required: true - }); - }); - - it('should return a JSON schema for a class using type', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.getType.returns('Acreage'); - mockField.getFullyQualifiedTypeName.returns('org.acme.Horse.Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Acreage', - required: true - }); - - mockModelFile.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - }); - - it('should return a JSON schema for a class using FQN', () => { - let param = {}; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.getType.returns('Acreage'); - mockField.getFullyQualifiedTypeName.returns('org.acme.Horse.Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.namespaces = true; - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'org_acme_Horse_Acreage', - required: true - }); - - mockModelFile.accept.withArgs(loopbackVisit, param).calledOnce.should.be.ok; - }); - - it('should return a JSON schema for a class without calling accept', () => { - let param = { - 'org.acme.Horse.Acreage': 'Something' - }; - - let mockModelFile = sinon.createStubInstance(ModelFile); - mockModelFile.isModelFile.returns(true); - mockModelFile.getType.withArgs('Acreage').returns({ - accept: mockModelFile.accept - }); - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.getType.returns('Acreage'); - mockField.getFullyQualifiedTypeName.returns('org.acme.Horse.Acreage'); - mockField.getParent.returns({ - getModelFile: () => { - return mockModelFile; - } - }); - mockField.isOptional.returns(false); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: 'Acreage', - required: true - }); - - mockModelFile.accept.callCount.should.deep.equal(0); - }); - - it('should return a JSON schema for a primitive that is an array', () => { - let param = {}; - - let mockField = sinon.createStubInstance(Field); - mockField.isField.returns(true); - mockField.getName.returns('Horse'); - mockField.isPrimitive.returns(true); - mockField.getType.returns('String'); - mockField.getParent.returns({ - getIdentifierFieldName: () => { - return 'Farmer'; - } - }); - mockField.isOptional.returns(false); - mockField.isArray.returns(true); - - loopbackVisit.visitField(mockField, param).should.deep.equal({ - type: ['string'], - required: false, - default: [] - }); - }); - }); - - describe('visitEnumDeclaration', () => { - it('should create a JSON schema for an enum declaration', () => { - let param = {}; - - let mockEnumDecl = sinon.createStubInstance(EnumDeclaration); - mockEnumDecl.accept.withArgs(loopbackVisit, param).returns('Duck'); - mockEnumDecl.isEnum.returns(true); - mockEnumDecl.getProperties.returns([ - { - accept: mockEnumDecl.accept - }, - { - accept: mockEnumDecl.accept - } - ]); - - loopbackVisit.visitEnumDeclaration(mockEnumDecl, param).should.deep.equal({ - type: 'string', - enum: ['Duck', 'Duck'] - }); - }); - }); - - describe('visitEnumValueDeclaration', () => { - it('should return the enumValueDeclaration\'s name', () => { - let mockEnumValDecl = sinon.createStubInstance(EnumValueDeclaration); - mockEnumValDecl.isEnumValue.returns(true); - mockEnumValDecl.getName.returns('Bob'); - - loopbackVisit.visitEnumValueDeclaration(mockEnumValDecl, {}).should.deep.equal('Bob'); - }); - }); - - describe('visitRelationshipDeclaration', () => { - it('should return a JSONSchema for a relationship', () => { - let mockRelationshipDeclaration = sinon.createStubInstance(RelationshipDeclaration); - mockRelationshipDeclaration.isRelationship.returns(true); - mockRelationshipDeclaration.getName.returns('Bob'); - mockRelationshipDeclaration.isOptional.returns(false); - - loopbackVisit.visitRelationshipDeclaration(mockRelationshipDeclaration, {}).should.deep.equal({ - type: 'any', - description: 'The identifier of an instance of Bob', - required: true - }); - }); - - it('should return a JSONSchema for a relationship that is an array', () => { - let mockRelationshipDeclaration = sinon.createStubInstance(RelationshipDeclaration); - mockRelationshipDeclaration.isRelationship.returns(true); - mockRelationshipDeclaration.getName.returns('Bob'); - mockRelationshipDeclaration.isOptional.returns(false); - mockRelationshipDeclaration.isArray.returns(true); - - loopbackVisit.visitRelationshipDeclaration(mockRelationshipDeclaration, {}).should.deep.equal({ - type: ['any'], - description: 'The identifier of an instance of Bob', - required: true - }); - }); - }); -}); \ No newline at end of file diff --git a/test/codegen/fromcto/loopback/loopbackvisitorcircular.js b/test/codegen/fromcto/loopback/loopbackvisitorcircular.js deleted file mode 100644 index ec31d3d0..00000000 --- a/test/codegen/fromcto/loopback/loopbackvisitorcircular.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const fs = require('fs'); -const FileWriter = require('@accordproject/concerto-util').FileWriter; -const ModelManager = require('@accordproject/concerto-core').ModelManager; -const LoopbackVisitor = require('../../../../lib/codegen/fromcto/loopback/loopbackvisitor'); -const path = require('path'); - -require('chai').should(); -const sinon = require('sinon'); - -describe('LoopbackVisitor with Circular Model', () => { - - let mockFileWriter; - let modelManager; - let visitor; - - let sandbox; - - [undefined, true, false].forEach((namespaces) => { - - describe(`namespaces = ${namespaces}`, () => { - - beforeEach(() => { - mockFileWriter = sinon.createStubInstance(FileWriter); - modelManager = new ModelManager(); - modelManager.addCTOModel(fs.readFileSync(path.resolve(__dirname, '../data/model/circular.cto'), 'utf8'), 'circular.cto'); - visitor = new LoopbackVisitor(namespaces); - sandbox = sinon.createSandbox(); - }); - - afterEach(() => { - sandbox.restore(); - }); - - describe('#visit', () => { - - it('should generate Loopback model files for each type when given a model manager', () => { - - // Visit all of the loaded model files and check that they were all generated - const schemas = modelManager.accept(visitor, { fileWriter: mockFileWriter }); - schemas.length.should.equal(29); - }); - - }); - - }); - }); - -}); From 673e012f91711ecf978b56b23569e176d3815194 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:39:51 +0100 Subject: [PATCH 12/22] chore(deps-dev): bump @babel/traverse from 7.22.11 to 7.23.2 (#67) Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.11 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Jonathan Casey --- package-lock.json | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4c63e2f..1112423c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -289,12 +289,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.10.tgz", - "integrity": "sha512-79KIf7YiWjjdZ81JnLujDRApWtl7BxTqWD88+FFdQEIOG8LJ0etDOM7CXuIgGJa55sGOwZVwuEsaLEm0PJ5/+A==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.22.10", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -437,22 +437,22 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -614,9 +614,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -674,9 +674,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.14", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.14.tgz", - "integrity": "sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1853,33 +1853,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.11.tgz", - "integrity": "sha512-mzAenteTfomcB7mfPtyi+4oe5BZ6MXxWcn4CX+h4IRJ+OOGXBrWU6jDQavkQI9Vuc5P+donFabBfFCcmWka9lQ==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.10", - "@babel/generator": "^7.22.10", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.11", - "@babel/types": "^7.22.11", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1888,13 +1888,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.11.tgz", - "integrity": "sha512-siazHiGuZRz9aB9NpHy9GOs9xiQPKnMzgdr493iI1M67vRXpnEq8ZOOKzezC5q7zwuQ6sDhdSp4SD9ixKSqKZg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { From f97ef0fca81acda2f2c0728a53eb38dc6d22168d Mon Sep 17 00:00:00 2001 From: Dan Selman Date: Thu, 2 Nov 2023 15:06:53 +0000 Subject: [PATCH 13/22] test(codegen) update HR model to use multiple namespaces (#68) Signed-off-by: Dan Selman Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/csharp/csharpvisitor.js | 4 +- .../fromcto/typescript/typescriptvisitor.js | 4 +- lib/common/graph.js | 4 +- package-lock.json | 60 +- package.json | 8 +- test/codegen/__snapshots__/codegen.js.snap | 2746 +++++++++++------ test/codegen/codegen.js | 7 +- test/codegen/fromcto/csharp/csharpvisitor.js | 25 +- test/codegen/fromcto/data/model/hr.cto | 60 +- test/codegen/fromcto/data/model/hr_base.cto | 32 + ...cordproject.protocol.v1_0_0-expected.proto | 2 +- test/common/graph.js | 148 +- .../fromcto/graphql/graphqlvisitor.d.ts | 8 + 13 files changed, 1946 insertions(+), 1162 deletions(-) create mode 100644 test/codegen/fromcto/data/model/hr_base.cto diff --git a/lib/codegen/fromcto/csharp/csharpvisitor.js b/lib/codegen/fromcto/csharp/csharpvisitor.js index 753544e7..10f40d72 100644 --- a/lib/codegen/fromcto/csharp/csharpvisitor.js +++ b/lib/codegen/fromcto/csharp/csharpvisitor.js @@ -314,8 +314,8 @@ class CSharpVisitor { writeField(field, parameters, externalFieldType, isOptional = false) { // write Map field - if ( Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) { - const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name); + if (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) { + const decl = field.getModelFile().getType(field.getType()); parameters.fileWriter.writeLine(1, `public Dictionary ${field.getName()} { get; set; }`); return null; } diff --git a/lib/codegen/fromcto/typescript/typescriptvisitor.js b/lib/codegen/fromcto/typescript/typescriptvisitor.js index 3da9d1c6..fc001537 100644 --- a/lib/codegen/fromcto/typescript/typescriptvisitor.js +++ b/lib/codegen/fromcto/typescript/typescriptvisitor.js @@ -288,9 +288,7 @@ class TypescriptVisitor { const isPrimitive = ModelUtil.isPrimitiveType(mapDeclaration.getValue().getType()); if (isScalar) { - const scalar = mapDeclaration.getModelFile() - .getAllDeclarations() - .find(decl => decl.name === mapDeclaration.getValue().getType()); + const scalar = mapDeclaration.getModelFile(mapDeclaration.getValue().getType()); const scalarType = scalar.getType(); valueType = this.toTsType(scalarType, false, false); } else if (isPrimitive) { diff --git a/lib/common/graph.js b/lib/common/graph.js index de872197..774f0627 100644 --- a/lib/common/graph.js +++ b/lib/common/graph.js @@ -203,7 +203,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { let valueEdge = mapDeclaration.getValue().getType(); if(!ModelUtil.isPrimitiveType(keyEdge)) { - keyEdge = modelFile.getAllDeclarations().find(d => d.name === mapDeclaration.getKey().getType()).getFullyQualifiedName(); + keyEdge = modelFile.getType(mapDeclaration.getKey().getType()).getFullyQualifiedName(); } if(!ModelUtil.isPrimitiveType(valueEdge)) { @@ -211,7 +211,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { if (!modelFile.isLocalType(mapDeclaration.getValue().getType())) { valueEdge = modelFile.resolveImport(mapDeclaration.getValue().getType()); } else { - valueEdge = modelFile.getAllDeclarations().find(d => d.name === mapDeclaration.getValue().getType()).getFullyQualifiedName(); + valueEdge = modelFile.getType(mapDeclaration.getValue().getType()).getFullyQualifiedName(); } } diff --git a/package-lock.json b/package-lock.json index 1112423c..3f18fcfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "3.16.2", "license": "Apache-2.0", "dependencies": { - "@accordproject/concerto-core": "3.14.0", - "@accordproject/concerto-util": "3.14.0", - "@accordproject/concerto-vocabulary": "3.14.0", + "@accordproject/concerto-core": "3.14.2", + "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-vocabulary": "3.14.2", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", @@ -22,7 +22,7 @@ "pluralize": "8.0.0" }, "devDependencies": { - "@accordproject/concerto-cto": "3.14.0", + "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -60,13 +60,13 @@ } }, "node_modules/@accordproject/concerto-core": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.0.tgz", - "integrity": "sha512-JOLG9ISzlowDUsrD0Lbks0ft08JiQZV6oPbBai0tBOy5x+CPd4JLoGmjfy/x6+6HsFWdk1aXV2tQJww6Gw+3Tw==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.2.tgz", + "integrity": "sha512-pnmA8LgPw4lXs//JGlIGJc5zS5bY8B9AyAJTexfcJIrihMZccQVONJ4AQ3/8eL2vh0OgofC65XCx4qrJXXw0Bw==", "dependencies": { - "@accordproject/concerto-cto": "3.14.0", - "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-cto": "3.14.2", + "@accordproject/concerto-metamodel": "3.9.0", + "@accordproject/concerto-util": "3.14.2", "dayjs": "1.11.10", "debug": "4.3.4", "lorem-ipsum": "2.0.8", @@ -110,12 +110,12 @@ } }, "node_modules/@accordproject/concerto-cto": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.0.tgz", - "integrity": "sha512-6Uf0fe5BZpgiBUONNAGxOrDdXvDK+6qMuWdcqN+aPddtFPLZ/2ldFarQaSkXHq71+yrM7B/Dh7Y/0KSvs1Tteg==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.2.tgz", + "integrity": "sha512-+gCGQzNKO+kbMAEIsESyOHpcAivOLVUHZU3P34PKMan/stLExLJNIERVWS+BeGvpHu8iQzaA6RiJ6XkjQNhUuA==", "dependencies": { - "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-metamodel": "3.9.0", + "@accordproject/concerto-util": "3.14.2", "path-browserify": "1.0.1" }, "engines": { @@ -124,11 +124,12 @@ } }, "node_modules/@accordproject/concerto-metamodel": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.8.1.tgz", - "integrity": "sha512-R0CAtzW/IciPz2BxlEyMgKZtya7sqgZ/YSk5iLD6g16NXsJtj6jytDuSZmNMz0B0FpjtEjSoSXPexCR/aPL1qA==", + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.9.0.tgz", + "integrity": "sha512-SbzLormyTORUZDt46umGZT2aVgOCkH5bo67SjuVRPd5YzywMb/vJfncyd6XCm/vzmUWZ3D9OkPqnnfPvPTRMNg==", "dependencies": { - "@accordproject/concerto-util": "3.9.1" + "@accordproject/concerto-util": "3.9.1", + "@types/node": "20.7.0" }, "engines": { "node": ">=14", @@ -161,9 +162,9 @@ } }, "node_modules/@accordproject/concerto-util": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.0.tgz", - "integrity": "sha512-M32oVsJ9n4l/o10pz0e+AmGEpUmUQ4nwS2ixB4Jz2/kzRgVjeyHoolGKJCgDn6K8LjsGclSkMcmQ6IeF/7mC0g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.2.tgz", + "integrity": "sha512-TagOBlneJlPXRKi75rWIshnqzQvsmWeXtFU7jwsvuFr2GeP+JeZwj4Clh4L3P8ah3Yu5mu5Z3n+w4M8KLbAxbg==", "dependencies": { "@supercharge/promise-pool": "1.7.0", "axios": "0.23.0", @@ -202,11 +203,11 @@ } }, "node_modules/@accordproject/concerto-vocabulary": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.0.tgz", - "integrity": "sha512-u0JABqvRjw9rE18+jmXlmFgw9xJprn4QT7jEZ+uFke2Gjr8LF2HwpNkzKFI/HQPLhIo/nGdBSm8ucXZ8a+axmw==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.2.tgz", + "integrity": "sha512-cparnUNjstm1IFq96hvG2TzaY5PBPotgH1zoJRxhwng7WDQP6dqatNiGmaF6tkpe0Edmkm/2VbA0CB9aSzavAg==", "dependencies": { - "@accordproject/concerto-metamodel": "3.8.1", + "@accordproject/concerto-metamodel": "3.9.0", "yaml": "2.2.2" }, "engines": { @@ -2590,10 +2591,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", - "integrity": "sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==", - "dev": true + "version": "20.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.0.tgz", + "integrity": "sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==" }, "node_modules/@types/stack-utils": { "version": "2.0.1", diff --git a/package.json b/package.json index d5fd36b2..72518b54 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "author": "accordproject.org", "license": "Apache-2.0", "devDependencies": { - "@accordproject/concerto-cto": "3.14.0", + "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -69,9 +69,9 @@ "webpack-cli": "4.9.1" }, "dependencies": { - "@accordproject/concerto-core": "3.14.0", - "@accordproject/concerto-util": "3.14.0", - "@accordproject/concerto-vocabulary": "3.14.0", + "@accordproject/concerto-core": "3.14.2", + "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-vocabulary": "3.14.2", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index c3b0b016..ab79ff80 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -6,7 +6,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -39,7 +39,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -64,12 +64,12 @@ protocol MyProtocol { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 3`] = ` { - "key": "org.acme.hr.avdl", - "value": "@namespace("org.acme.hr") + "key": "org.acme.hr.base.avdl", + "value": "@namespace("org.acme.hr.base") protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -79,23 +79,42 @@ protocol MyProtocol { CA } + enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE + } + record Address { string street; string city; union { null, State } state; string zipCode; string country; - Map1 dictionary1; - Map2 dictionary2; - Map3 dictionary3; - Map4 dictionary4; - Map5 dictionary5; - Map6 dictionary6; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'avro' 4`] = ` +{ + "key": "org.acme.hr.avdl", + "value": "@namespace("org.acme.hr") +protocol MyProtocol { + + import idl "org.acme.hr.base.avdl"; + import idl "concerto@1.0.0.avdl"; + record Company { string name; Address headquarters; + union { null, CompanyProperties } companyProperties; + union { null, EmployeeDirectory } employeeDirectory; + union { null, EmployeeTShirtSizes } employeeTShirtSizes; + union { null, EmployeeProfiles } employeeProfiles; + union { null, EmployeeSocialSecurityNumbers } employeeSocialSecurityNumbers; } enum Department { @@ -131,6 +150,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Employee { @@ -151,6 +171,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Contractor { @@ -165,6 +186,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Manager { @@ -186,6 +208,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record CompanyEvent { @@ -305,8 +328,8 @@ public abstract class Event : Concept { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 3`] = ` { - "key": "org.acme.hr.cs", - "value": "namespace org.acme.hr; + "key": "org.acme.hr.base.cs", + "value": "namespace org.acme.hr.base; using AccordProject.Concerto; [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum State { @@ -317,32 +340,49 @@ public enum State { IL, CA, } -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Address")] +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr.base", Version = null, Name = "Address")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Address : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr.Address"; + public override string _class { get; } = "org.acme.hr.base.Address"; public string street { get; set; } public string city { get; set; } public State? state { get; set; } public string zipCode { get; set; } public string country { get; set; } - public Dictionary dictionary1 { get; set; } - public Dictionary dictionary2 { get; set; } - public Dictionary dictionary3 { get; set; } - public Dictionary dictionary4 { get; set; } - public Dictionary dictionary5 { get; set; } - public Dictionary dictionary6 { get; set; } } //Dummy implementation of the scalar declaration to avoid compilation errors. class Time_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class SSN_Dummy {} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'csharp' 4`] = ` +{ + "key": "org.acme.hr.cs", + "value": "namespace org.acme.hr; +using org.acme.hr.base; +using AccordProject.Concerto; [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Company")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Company : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr.Company"; public string name { get; set; } - public Address headquarters { get; set; } + public org.acme.hr.base.Address headquarters { get; set; } + public Dictionary companyProperties { get; set; } + public Dictionary employeeDirectory { get; set; } + public Dictionary employeeTShirtSizes { get; set; } + public Dictionary employeeProfiles { get; set; } + public Dictionary employeeSocialSecurityNumbers { get; set; } } [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum Department { @@ -373,8 +413,6 @@ public class Laptop : Equipment { public override string _class { get; } = "org.acme.hr.Laptop"; public LaptopMake make { get; set; } } -//Dummy implementation of the scalar declaration to avoid compilation errors. -class SSN_Dummy {} [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Person")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public abstract class Person : Participant { @@ -385,11 +423,12 @@ public abstract class Person : Participant { public string firstName { get; set; } public string lastName { get; set; } public string? middleNames { get; set; } - public Address homeAddress { get; set; } + public org.acme.hr.base.Address homeAddress { get; set; } [System.ComponentModel.DataAnnotations.RegularExpression(@"\\d{3}-\\d{2}-\\{4}+", ErrorMessage = "Invalid characters")] public string ssn { get; set; } public float height { get; set; } public System.DateTime dob { get; set; } + public Dictionary nextOfKin { get; set; } } [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = null, Name = "Employee")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] @@ -401,7 +440,7 @@ public class Employee : Person { public int numDependents { get; set; } public bool retired { get; set; } public Department department { get; set; } - public Address officeAddress { get; set; } + public org.acme.hr.base.Address officeAddress { get; set; } public Equipment[] companyAssets { get; set; } public Manager manager { get; set; } } @@ -439,8 +478,12 @@ public class ChangeOfAddress : Transaction { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr.ChangeOfAddress"; public Person Person { get; set; } - public Address newAddress { get; set; } + public org.acme.hr.base.Address newAddress { get; set; } } +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinName_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinTelephone_Dummy {} ", } `; @@ -451,7 +494,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -479,7 +522,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -502,12 +545,11 @@ type Event struct { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 3`] = ` { - "key": "org.acme.hr.go", - "value": "// Package org_acme_hr contains domain objects and was generated from Concerto namespace org.acme.hr. -package org_acme_hr -import "time" + "key": "org.acme.hr.base.go", + "value": "// Package org_acme_hr_base contains domain objects and was generated from Concerto namespace org.acme.hr.base. +package org_acme_hr_base import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -517,6 +559,12 @@ const ( IL CA ) +type TShirtSizeType int +const ( + SMALL TShirtSizeType = 1 + iota + MEDIUM + LARGE +) type Address struct { concerto_1_0_0.Concept Street string \`json:"street"\` @@ -524,17 +572,29 @@ type Address struct { State State \`json:"state"\` ZipCode string \`json:"zipCode"\` Country string \`json:"country"\` - Dictionary1 Map1 \`json:"dictionary1"\` - Dictionary2 Map2 \`json:"dictionary2"\` - Dictionary3 Map3 \`json:"dictionary3"\` - Dictionary4 Map4 \`json:"dictionary4"\` - Dictionary5 Map5 \`json:"dictionary5"\` - Dictionary6 Map6 \`json:"dictionary6"\` } +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'golang' 4`] = ` +{ + "key": "org.acme.hr.go", + "value": "// Package org_acme_hr contains domain objects and was generated from Concerto namespace org.acme.hr. +package org_acme_hr +import "time" +import "org_acme_hr_base"; +import "concerto_1_0_0"; + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` Headquarters Address \`json:"headquarters"\` + CompanyProperties CompanyProperties \`json:"companyProperties"\` + EmployeeDirectory EmployeeDirectory \`json:"employeeDirectory"\` + EmployeeTShirtSizes EmployeeTShirtSizes \`json:"employeeTShirtSizes"\` + EmployeeProfiles EmployeeProfiles \`json:"employeeProfiles"\` + EmployeeSocialSecurityNumbers EmployeeSocialSecurityNumbers \`json:"employeeSocialSecurityNumbers"\` } type Department int const ( @@ -568,6 +628,7 @@ type Person struct { Ssn string \`json:"ssn"\` Height float64 \`json:"height"\` Dob time.Time \`json:"dob"\` + NextOfKin NextOfKin \`json:"nextOfKin"\` } type Employee struct { Person @@ -610,7 +671,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "model.gql", "value": "directive @resource on OBJECT | FIELD_DEFINITION scalar DateTime -# namespace org.acme.hr +# namespace org.acme.hr.base enum State { MA NY @@ -619,46 +680,55 @@ enum State { IL CA } +enum TShirtSizeType { + SMALL + MEDIUM + LARGE +} +type EmployeeTShirtSizes { + key: SSN + value: TShirtSizeType +} type Address { street: String! city: String! state: State zipCode: String! country: String! - dictionary1: Map1! - dictionary2: Map2! - dictionary3: Map3! - dictionary4: Map4! - dictionary5: Map5! - dictionary6: Map6! -} -type Map1 { +} +# namespace org.acme.hr +type CompanyProperties { key: String value: String } -type Map2 { +type EmployeeLoginTimes { key: String - value: DateTime + value: Time } -type Map3 { +type EmployeeSocialSecurityNumbers { key: String value: SSN } -type Map4 { +type NextOfKin { + key: KinName + value: KinTelephone +} +type EmployeeProfiles { key: String value: Concept } -type Map5 { - key: SSN - value: String -} -type Map6 { +type EmployeeDirectory { key: SSN value: Employee } type Company { name: String! headquarters: Address! + companyProperties: CompanyProperties + employeeDirectory: EmployeeDirectory + employeeTShirtSizes: EmployeeTShirtSizes + employeeProfiles: EmployeeProfiles + employeeSocialSecurityNumbers: EmployeeSocialSecurityNumbers } enum Department { Sales @@ -690,6 +760,7 @@ type Person @resource { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Employee { @@ -709,6 +780,7 @@ type Employee { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Contractor { @@ -722,6 +794,7 @@ type Contractor { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Manager { @@ -742,6 +815,7 @@ type Manager { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type CompanyEvent { @@ -796,7 +870,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -835,7 +909,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -885,9 +959,9 @@ public abstract class Event extends Concept { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 6`] = ` { - "key": "org/acme/hr/State.java", + "key": "org/acme/hr/base/State.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"$class"}) @@ -905,9 +979,26 @@ public enum State { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 7`] = ` { - "key": "org/acme/hr/Address.java", + "key": "org/acme/hr/base/TShirtSizeType.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 8`] = ` +{ + "key": "org/acme/hr/base/Address.java", + "value": "// this code is generated and should not be modified +package org.acme.hr.base; import concerto.Concept; import concerto.Asset; @@ -923,12 +1014,6 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map dictionary1 = new HashMap<>(); - private Map dictionary2 = new HashMap<>(); - private Map dictionary3 = new HashMap<>(); - private Map dictionary4 = new HashMap<>(); - private Map dictionary5 = new HashMap<>(); - private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } @@ -944,24 +1029,6 @@ public class Address extends Concept { public String getCountry() { return this.country; } - public Map1 getDictionary1() { - return this.dictionary1; - } - public Map2 getDictionary2() { - return this.dictionary2; - } - public Map3 getDictionary3() { - return this.dictionary3; - } - public Map4 getDictionary4() { - return this.dictionary4; - } - public Map5 getDictionary5() { - return this.dictionary5; - } - public Map6 getDictionary6() { - return this.dictionary6; - } public void setStreet(String street) { this.street = street; } @@ -977,35 +1044,22 @@ public class Address extends Concept { public void setCountry(String country) { this.country = country; } - public void setDictionary1(Map1 dictionary1) { - this.dictionary1 = dictionary1; - } - public void setDictionary2(Map2 dictionary2) { - this.dictionary2 = dictionary2; - } - public void setDictionary3(Map3 dictionary3) { - this.dictionary3 = dictionary3; - } - public void setDictionary4(Map4 dictionary4) { - this.dictionary4 = dictionary4; - } - public void setDictionary5(Map5 dictionary5) { - this.dictionary5 = dictionary5; - } - public void setDictionary6(Map6 dictionary6) { - this.dictionary6 = dictionary6; - } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 8`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 9`] = ` { "key": "org/acme/hr/Company.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1017,24 +1071,59 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; + private CompanyProperties companyProperties; + private EmployeeDirectory employeeDirectory; + private EmployeeTShirtSizes employeeTShirtSizes; + private EmployeeProfiles employeeProfiles; + private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; public String getName() { return this.name; } public Address getHeadquarters() { return this.headquarters; } + public CompanyProperties getCompanyProperties() { + return this.companyProperties; + } + public EmployeeDirectory getEmployeeDirectory() { + return this.employeeDirectory; + } + public EmployeeTShirtSizes getEmployeeTShirtSizes() { + return this.employeeTShirtSizes; + } + public EmployeeProfiles getEmployeeProfiles() { + return this.employeeProfiles; + } + public EmployeeSocialSecurityNumbers getEmployeeSocialSecurityNumbers() { + return this.employeeSocialSecurityNumbers; + } public void setName(String name) { this.name = name; } public void setHeadquarters(Address headquarters) { this.headquarters = headquarters; } + public void setCompanyProperties(CompanyProperties companyProperties) { + this.companyProperties = companyProperties; + } + public void setEmployeeDirectory(EmployeeDirectory employeeDirectory) { + this.employeeDirectory = employeeDirectory; + } + public void setEmployeeTShirtSizes(EmployeeTShirtSizes employeeTShirtSizes) { + this.employeeTShirtSizes = employeeTShirtSizes; + } + public void setEmployeeProfiles(EmployeeProfiles employeeProfiles) { + this.employeeProfiles = employeeProfiles; + } + public void setEmployeeSocialSecurityNumbers(EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers) { + this.employeeSocialSecurityNumbers = employeeSocialSecurityNumbers; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 9`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 10`] = ` { "key": "org/acme/hr/Department.java", "value": "// this code is generated and should not be modified @@ -1054,12 +1143,17 @@ public enum Department { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 10`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 11`] = ` { "key": "org/acme/hr/Equipment.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1070,7 +1164,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1088,7 +1182,7 @@ public abstract class Equipment extends Asset { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 11`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 12`] = ` { "key": "org/acme/hr/LaptopMake.java", "value": "// this code is generated and should not be modified @@ -1104,12 +1198,17 @@ public enum LaptopMake { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 12`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 13`] = ` { "key": "org/acme/hr/Laptop.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1120,7 +1219,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1138,12 +1237,17 @@ public class Laptop extends Equipment { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 13`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 14`] = ` { "key": "org/acme/hr/Person.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1154,7 +1258,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1168,6 +1272,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; + private NextOfKin nextOfKin; public String getEmail() { return this.email; } @@ -1192,6 +1297,9 @@ public abstract class Person extends Participant { public java.util.Date getDob() { return this.dob; } + public NextOfKin getNextOfKin() { + return this.nextOfKin; + } public void setEmail(String email) { this.email = email; } @@ -1216,17 +1324,25 @@ public abstract class Person extends Participant { public void setDob(java.util.Date dob) { this.dob = dob; } + public void setNextOfKin(NextOfKin nextOfKin) { + this.nextOfKin = nextOfKin; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 14`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 15`] = ` { "key": "org/acme/hr/Employee.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1237,7 +1353,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1304,12 +1420,17 @@ public class Employee extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 15`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 16`] = ` { "key": "org/acme/hr/Contractor.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1320,7 +1441,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1345,12 +1466,17 @@ public class Contractor extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 16`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 17`] = ` { "key": "org/acme/hr/Manager.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1361,7 +1487,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1379,12 +1505,17 @@ public class Manager extends Employee { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 17`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 18`] = ` { "key": "org/acme/hr/CompanyEvent.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1398,12 +1529,17 @@ public class CompanyEvent extends Event { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 18`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 19`] = ` { "key": "org/acme/hr/Onboarded.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1424,12 +1560,17 @@ public class Onboarded extends CompanyEvent { } `; -exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 19`] = ` +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'java' 20`] = ` { "key": "org/acme/hr/ChangeOfAddress.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -1463,9 +1604,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { - "org.acme.hr.State": { + "org.acme.hr.base.State": { "title": "State", - "description": "An instance of org.acme.hr.State", + "description": "An instance of org.acme.hr.base.State", "enum": [ "MA", "NY", @@ -1475,16 +1616,25 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "CA" ] }, - "org.acme.hr.Address": { + "org.acme.hr.base.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base.Address": { "title": "Address", - "description": "An instance of org.acme.hr.Address", + "description": "An instance of org.acme.hr.base.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr.Address", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", - "description": "The class identifier for org.acme.hr.Address" + "default": "org.acme.hr.base.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base\\\\.Address$", + "description": "The class identifier for org.acme.hr.base.Address" }, "street": { "type": "string" @@ -1493,7 +1643,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "state": { - "$ref": "#/definitions/org.acme.hr.State" + "$ref": "#/definitions/org.acme.hr.base.State" }, "zipCode": { "type": "string" @@ -1507,19 +1657,17 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr.Time": { + "org.acme.hr.base.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr.Company": { "title": "Company", "description": "An instance of org.acme.hr.Company", @@ -1535,7 +1683,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "headquarters": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" } }, "required": [ @@ -1613,10 +1761,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "serialNumber" ] }, - "org.acme.hr.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr.Person": { "title": "Person", "description": "An instance of org.acme.hr.Person", @@ -1642,7 +1786,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1665,7 +1809,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -1698,7 +1843,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/definitions/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -1731,7 +1876,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1761,7 +1906,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Contractor": { @@ -1796,7 +1942,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1820,7 +1966,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Manager": { @@ -1857,7 +2004,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/definitions/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -1890,7 +2037,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -1920,7 +2067,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.CompanyEvent": { @@ -1976,7 +2124,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "The identifier of an instance of org.acme.hr.Person" }, "newAddress": { - "$ref": "#/definitions/org.acme.hr.Address" + "$ref": "#/definitions/org.acme.hr.base.Address" } }, "required": [ @@ -1984,6 +2132,13 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "Person", "newAddress" ] + }, + "org.acme.hr.KinName": { + "type": "string" + }, + "org.acme.hr.KinTelephone": { + "format": "date-time", + "type": "string" } } } @@ -1994,16 +2149,16 @@ exports[`codegen #formats check we can convert all formats from namespace unvers exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'markdown' 1`] = ` { "key": "models.md", - "value": "# Namespace org.acme.hr + "value": "# Namespace org.acme.hr.base ## Overview -- 2 concepts -- 3 enumerations -- 2 assets -- 4 participants -- 1 transactions -- 2 events -- 22 total declarations +- 1 concepts +- 2 enumerations +- 0 assets +- 0 participants +- 0 transactions +- 0 events +- 6 total declarations ## Imports - concerto@1.0.0.Concept @@ -2015,7 +2170,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers ## Diagram \`\`\`mermaid classDiagram -class \`org.acme.hr.State\` { +class \`org.acme.hr.base.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -2025,35 +2180,68 @@ class \`org.acme.hr.State\` { + \`CA\` } -class \`org.acme.hr.Address\` { +class \`org.acme.hr.base.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +class \`org.acme.hr.base.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.State\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map1\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map2\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map3\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map4\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map5\` -\`org.acme.hr.Address\` "1" *-- "1" \`org.acme.hr.Map6\` +} + +\`org.acme.hr.base.Address\` "1" *-- "1" \`org.acme.hr.base.State\` +\`\`\` + +# Namespace org.acme.hr + +## Overview +- 1 concepts +- 2 enumerations +- 2 assets +- 4 participants +- 1 transactions +- 2 events +- 20 total declarations + +## Imports +- org.acme.hr.base.Address +- org.acme.hr.base.State +- org.acme.hr.base.SSN +- org.acme.hr.base.Time +- org.acme.hr.base.EmployeeTShirtSizes +- concerto@1.0.0.Concept +- concerto@1.0.0.Asset +- concerto@1.0.0.Transaction +- concerto@1.0.0.Participant +- concerto@1.0.0.Event + +## Diagram +\`\`\`mermaid +classDiagram class \`org.acme.hr.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.base.Address\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.CompanyProperties\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.EmployeeDirectory\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.base.EmployeeTShirtSizes\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.EmployeeProfiles\` +\`org.acme.hr.Company\` "1" *-- "1" \`org.acme.hr.EmployeeSocialSecurityNumbers\` class \`org.acme.hr.Department\` { << enumeration>> + \`Sales\` @@ -2092,10 +2280,12 @@ class \`org.acme.hr.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.Address\` -\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.SSN\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.base.Address\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.base.SSN\` +\`org.acme.hr.Person\` "1" *-- "1" \`org.acme.hr.NextOfKin\` class \`org.acme.hr.Employee\` { << participant>> + \`String\` \`employeeId\` @@ -2109,7 +2299,7 @@ class \`org.acme.hr.Employee\` { } \`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Department\` -\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.Address\` +\`org.acme.hr.Employee\` "1" *-- "1" \`org.acme.hr.base.Address\` \`org.acme.hr.Employee\` "1" *-- "*" \`org.acme.hr.Equipment\` \`org.acme.hr.Employee\` "1" o-- "1" \`org.acme.hr.Manager\` : manager \`org.acme.hr.Employee\` --|> \`org.acme.hr.Person\` @@ -2146,7 +2336,7 @@ class \`org.acme.hr.ChangeOfAddress\` { } \`org.acme.hr.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr.Person\` : Person -\`org.acme.hr.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.Address\` +\`org.acme.hr.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base.Address\` \`\`\` ", @@ -2157,7 +2347,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "model.mmd", "value": "classDiagram -class \`org.acme.hr.State\` { +class \`org.acme.hr.base.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -2167,27 +2357,34 @@ class \`org.acme.hr.State\` { + \`CA\` } -\`org.acme.hr.State\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr.Address\` { +\`org.acme.hr.base.State\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +\`org.acme.hr.base.TShirtSizeType\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` } -\`org.acme.hr.Address\` --|> \`concerto@1.0.0.Concept\` +\`org.acme.hr.base.Address\` --|> \`concerto@1.0.0.Concept\` class \`org.acme.hr.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` } \`org.acme.hr.Company\` --|> \`concerto@1.0.0.Concept\` @@ -2231,6 +2428,7 @@ class \`org.acme.hr.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } \`org.acme.hr.Person\` --|> \`concerto@1.0.0.Participant\` @@ -2321,7 +2519,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 2`] = ` { - "key": "org.acme.hr.csdl", + "key": "org.acme.hr.base.csdl", "value": " @@ -2331,7 +2529,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2346,34 +2544,65 @@ exports[`codegen #formats check we can convert all formats from namespace unvers + + + + + + + + - + - - - + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'odata' 3`] = ` +{ + "key": "org.acme.hr.csdl", + "value": " + + + + + + + + + + + + + + - + - + - + - + - - - + - + @@ -2417,7 +2646,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2425,6 +2654,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers + + @@ -2437,7 +2668,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2463,7 +2694,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers - + @@ -2492,9 +2723,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers }, "components": { "schemas": { - "org.acme.hr.State": { + "org.acme.hr.base.State": { "title": "State", - "description": "An instance of org.acme.hr.State", + "description": "An instance of org.acme.hr.base.State", "enum": [ "MA", "NY", @@ -2504,16 +2735,25 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "CA" ] }, - "org.acme.hr.Address": { + "org.acme.hr.base.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base.Address": { "title": "Address", - "description": "An instance of org.acme.hr.Address", + "description": "An instance of org.acme.hr.base.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr.Address", - "pattern": "^org\\\\.acme\\\\.hr\\\\.Address$", - "description": "The class identifier for org.acme.hr.Address" + "default": "org.acme.hr.base.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base\\\\.Address$", + "description": "The class identifier for org.acme.hr.base.Address" }, "street": { "type": "string" @@ -2522,7 +2762,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "state": { - "$ref": "#/components/schemas/org.acme.hr.State" + "$ref": "#/components/schemas/org.acme.hr.base.State" }, "zipCode": { "type": "string" @@ -2536,19 +2776,17 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr.Time": { + "org.acme.hr.base.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr.Company": { "title": "Company", "description": "An instance of org.acme.hr.Company", @@ -2564,7 +2802,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "headquarters": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" } }, "required": [ @@ -2642,10 +2880,6 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "serialNumber" ] }, - "org.acme.hr.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr.Person": { "title": "Person", "description": "An instance of org.acme.hr.Person", @@ -2671,7 +2905,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2694,7 +2928,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -2727,7 +2962,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/components/schemas/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -2760,7 +2995,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2790,7 +3025,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Contractor": { @@ -2825,7 +3061,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2849,7 +3085,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.Manager": { @@ -2886,7 +3123,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "$ref": "#/components/schemas/org.acme.hr.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "companyAssets": { "type": "array", @@ -2919,7 +3156,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" }, "ssn": { "default": "000-00-0000", @@ -2949,7 +3186,8 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr.CompanyEvent": { @@ -3005,7 +3243,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "description": "The identifier of an instance of org.acme.hr.Person" }, "newAddress": { - "$ref": "#/components/schemas/org.acme.hr.Address" + "$ref": "#/components/schemas/org.acme.hr.base.Address" } }, "required": [ @@ -3013,6 +3251,13 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "Person", "newAddress" ] + }, + "org.acme.hr.KinName": { + "type": "string" + }, + "org.acme.hr.KinTelephone": { + "format": "date-time", + "type": "string" } } }, @@ -3276,7 +3521,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers title Model endtitle -class org.acme.hr.State << (E,grey) >> { +class org.acme.hr.base.State << (E,grey) >> { + MA + NY + CO @@ -3284,24 +3529,29 @@ class org.acme.hr.State << (E,grey) >> { + IL + CA } -org.acme.hr.State --|> concerto_1_0_0.Concept -class org.acme.hr.Address { +org.acme.hr.base.State --|> concerto_1_0_0.Concept +class org.acme.hr.base.TShirtSizeType << (E,grey) >> { + + SMALL + + MEDIUM + + LARGE +} +org.acme.hr.base.TShirtSizeType --|> concerto_1_0_0.Concept +class org.acme.hr.base.Address { + String street + String city + State state + String zipCode + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr.Address --|> concerto_1_0_0.Concept +} +org.acme.hr.base.Address --|> concerto_1_0_0.Concept class org.acme.hr.Company { + String name + Address headquarters + + CompanyProperties companyProperties + + EmployeeDirectory employeeDirectory + + EmployeeTShirtSizes employeeTShirtSizes + + EmployeeProfiles employeeProfiles + + EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers } org.acme.hr.Company --|> concerto_1_0_0.Concept class org.acme.hr.Department << (E,grey) >> { @@ -3335,6 +3585,7 @@ class org.acme.hr.Person << (P,lightblue) >> { + String ssn + Double height + DateTime dob + + NextOfKin nextOfKin } org.acme.hr.Person --|> concerto_1_0_0.Participant class org.acme.hr.Employee << (P,lightblue) >> { @@ -3381,10 +3632,10 @@ org.acme.hr.ChangeOfAddress --|> concerto_1_0_0.Transaction exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'protobuf' 1`] = ` { - "key": "org.acme.hr.v.proto", + "key": "org.acme.hr.base.v.proto", "value": "syntax = "proto3"; -package org.acme.hr.v; +package org.acme.hr.base.v; import "google/protobuf/timestamp.proto"; @@ -3397,23 +3648,42 @@ enum State { State_WA = 5; } +enum TShirtSizeType { + TShirtSizeType_LARGE = 0; + TShirtSizeType_MEDIUM = 1; + TShirtSizeType_SMALL = 2; +} + message Address { string city = 1; string country = 2; - Map1 dictionary1 = 3; - Map2 dictionary2 = 4; - Map3 dictionary3 = 5; - Map4 dictionary4 = 6; - Map5 dictionary5 = 7; - Map6 dictionary6 = 8; - optional State state = 9; - string street = 10; - string zipCode = 11; + optional State state = 3; + string street = 4; + string zipCode = 5; +} + +", } +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'protobuf' 2`] = ` +{ + "key": "org.acme.hr.v.proto", + "value": "syntax = "proto3"; + +package org.acme.hr.v; + +import "google/protobuf/timestamp.proto"; +import "org.acme.hr.base.v.proto"; message Company { - Address headquarters = 1; - string name = 2; + optional CompanyProperties companyProperties = 1; + optional EmployeeDirectory employeeDirectory = 2; + optional EmployeeProfiles employeeProfiles = 3; + optional EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers = 4; + optional EmployeeTShirtSizes employeeTShirtSizes = 5; + Address headquarters = 6; + string name = 7; } enum Department { @@ -3461,11 +3731,12 @@ message Employee { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - bool retired = 14; - sint64 salary = 15; - string ssn = 16; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + bool retired = 15; + sint64 salary = 16; + string ssn = 17; } message _Subclasses_of_class_Employee { @@ -3485,7 +3756,8 @@ message Contractor { string lastName = 7; optional string manager = 8; optional string middleNames = 9; - string ssn = 10; + NextOfKin nextOfKin = 10; + string ssn = 11; } message Manager { @@ -3500,12 +3772,13 @@ message Manager { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - repeated string reports = 14; - bool retired = 15; - sint64 salary = 16; - string ssn = 17; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + repeated string reports = 15; + bool retired = 16; + sint64 salary = 17; + string ssn = 18; } message CompanyEvent { @@ -3539,6 +3812,8 @@ pub mod concerto_1_0_0; #[allow(unused_imports)] pub mod concerto; #[allow(unused_imports)] +pub mod org_acme_hr_base; +#[allow(unused_imports)] pub mod org_acme_hr; #[allow(unused_imports)] pub mod utils; @@ -3551,7 +3826,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -3581,7 +3856,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -3598,9 +3873,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3615,7 +3890,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3628,7 +3903,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3641,7 +3916,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3656,7 +3931,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3674,9 +3949,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3691,7 +3966,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3704,7 +3979,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3733,13 +4008,13 @@ pub struct Event { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 5`] = ` { - "key": "org_acme_hr.rs", + "key": "org_acme_hr_base.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -3756,86 +4031,110 @@ pub enum State { CA, } +#[derive(Debug, Serialize, Deserialize)] +pub enum TShirtSizeType { + #[allow(non_camel_case_types)] + SMALL, + #[allow(non_camel_case_types)] + MEDIUM, + #[allow(non_camel_case_types)] + LARGE, +} + #[derive(Debug, Serialize, Deserialize)] pub struct Address { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] pub country: String, - - #[serde( - rename = "dictionary1", - )] - pub dictionary1: Map1, - +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'rust' 6`] = ` +{ + "key": "org_acme_hr.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::org_acme_hr_base::*; +use crate::concerto_1_0_0::*; +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Company { #[serde( - rename = "dictionary2", + rename = "$class", )] - pub dictionary2: Map2, - + pub _class: String, + #[serde( - rename = "dictionary3", + rename = "name", )] - pub dictionary3: Map3, - + pub name: String, + #[serde( - rename = "dictionary4", + rename = "headquarters", )] - pub dictionary4: Map4, - + pub headquarters: Address, + #[serde( - rename = "dictionary5", + rename = "companyProperties", + skip_serializing_if = "Option::is_none", )] - pub dictionary5: Map5, - + pub company_properties: Option, + #[serde( - rename = "dictionary6", + rename = "employeeDirectory", + skip_serializing_if = "Option::is_none", )] - pub dictionary6: Map6, -} + pub employee_directory: Option, -#[derive(Debug, Serialize, Deserialize)] -pub struct Company { #[serde( - rename = "$class", + rename = "employeeTShirtSizes", + skip_serializing_if = "Option::is_none", )] - pub _class: String, - + pub employee_t_shirt_sizes: Option, + #[serde( - rename = "name", + rename = "employeeProfiles", + skip_serializing_if = "Option::is_none", )] - pub name: String, - + pub employee_profiles: Option, + #[serde( - rename = "headquarters", + rename = "employeeSocialSecurityNumbers", + skip_serializing_if = "Option::is_none", )] - pub headquarters: Address, + pub employee_social_security_numbers: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -3860,12 +4159,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -3886,17 +4185,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -3909,50 +4208,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -3965,88 +4269,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4059,58 +4368,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4123,91 +4437,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -4220,7 +4539,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4235,10 +4554,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4253,15 +4572,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4285,7 +4604,10 @@ exports[`codegen #formats check we can convert all formats from namespace unvers // Warning: Beware of circular dependencies when modifying these imports import type { State, - IAddress, + TShirtSizeType, + IAddress +} from './org.acme.hr.base'; +import type { ICompany, Department, LaptopMake @@ -4316,7 +4638,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -4380,20 +4702,12 @@ export interface IEvent extends IConcept { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 3`] = ` { - "key": "org.acme.hr.ts", + "key": "org.acme.hr.base.ts", "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: org.acme.hr +// Generated code for namespace: org.acme.hr.base // imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports -import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; +import {IConcept} from './concerto@1.0.0'; // interfaces export enum State { @@ -4405,35 +4719,65 @@ export enum State { CA = 'CA', } +export enum TShirtSizeType { + SMALL = 'SMALL', + MEDIUM = 'MEDIUM', + LARGE = 'LARGE', +} + +export type EmployeeTShirtSizes = Map; + export interface IAddress extends IConcept { street: string; city: string; state?: State; zipCode: string; country: string; - dictionary1: Map1; - dictionary2: Map2; - dictionary3: Map3; - dictionary4: Map4; - dictionary5: Map5; - dictionary6: Map6; } -export type Map1 = Map; +", +} +`; -export type Map2 = Map; +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'typescript' 4`] = ` +{ + "key": "org.acme.hr.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: org.acme.hr + +// imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports +import {IAddress,IEmployeeTShirtSizes,ISSN} from './org.acme.hr.base'; +import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; + +// interfaces +export type CompanyProperties = Map; + +export type EmployeeLoginTimes = Map; -export type Map3 = Map; +export type EmployeeSocialSecurityNumbers = Map; -export type Map4 = Map; +export type NextOfKin = Map; -export type Map5 = Map; +export type EmployeeProfiles = Map; -export type Map6 = Map; +export type EmployeeDirectory = Map; export interface ICompany extends IConcept { name: string; headquarters: IAddress; + companyProperties?: CompanyProperties; + employeeDirectory?: EmployeeDirectory; + employeeTShirtSizes?: EmployeeTShirtSizes; + employeeProfiles?: EmployeeProfiles; + employeeSocialSecurityNumbers?: EmployeeSocialSecurityNumbers; } export enum Department { @@ -4469,9 +4813,10 @@ export interface IPerson extends IParticipant { ssn: string; height: number; dob: Date; + nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -4516,10 +4861,10 @@ export interface IChangeOfAddress extends ITransaction { exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'vocabulary' 1`] = ` { - "key": "org.acme.hr_en.voc", - "value": "#Generated vocabulary for namespace: org.acme.hr + "key": "org.acme.hr.base_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr.base locale: en -namespace: org.acme.hr +namespace: org.acme.hr.base declarations: - State: State properties: @@ -4529,6 +4874,11 @@ declarations: - WA: WA of the State - IL: IL of the State - CA: CA of the State + - TShirtSizeType: TShirt Size Type + properties: + - SMALL: SMALL of the TShirt Size Type + - MEDIUM: MEDIUM of the TShirt Size Type + - LARGE: LARGE of the TShirt Size Type - Address: Address properties: - street: Street of the Address @@ -4536,17 +4886,28 @@ declarations: - state: State of the Address - zipCode: Zip Code of the Address - country: Country of the Address - - dictionary1: Dictionary1 of the Address - - dictionary2: Dictionary2 of the Address - - dictionary3: Dictionary3 of the Address - - dictionary4: Dictionary4 of the Address - - dictionary5: Dictionary5 of the Address - - dictionary6: Dictionary6 of the Address - Time: Time + - SSN: SSN +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'vocabulary' 2`] = ` +{ + "key": "org.acme.hr_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr +locale: en +namespace: org.acme.hr +declarations: - Company: Company properties: - name: Name of the Company - headquarters: Headquarters of the Company + - companyProperties: Company Properties of the Company + - employeeDirectory: Employee Directory of the Company + - employeeTShirtSizes: Employee TShirt Sizes of the Company + - employeeProfiles: Employee Profiles of the Company + - employeeSocialSecurityNumbers: Employee Social Security Numbers of the Company - Department: Department properties: - Sales: Sales of the Department @@ -4565,7 +4926,6 @@ declarations: - Laptop: Laptop properties: - make: Make of the Laptop - - SSN: SSN - Person: Person properties: - email: Email of the Person @@ -4576,6 +4936,7 @@ declarations: - ssn: Ssn of the Person - height: Height of the Person - dob: Dob of the Person + - nextOfKin: Next Of Kin of the Person - Employee: Employee properties: - employeeId: Employee Id of the Employee @@ -4601,6 +4962,8 @@ declarations: properties: - Person: Person of the Change Of Address - newAddress: New Address of the Change Of Address + - KinName: Kin Name + - KinTelephone: Kin Telephone ", } `; @@ -4609,7 +4972,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto@1.0.0.xsd", "value": " - @@ -4665,7 +5028,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto.xsd", "value": " - @@ -4717,9 +5080,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 3`] = ` { - "key": "org.acme.hr.xsd", + "key": "org.acme.hr.base.xsd", "value": " - @@ -4733,33 +5096,55 @@ xmlns:concerto="concerto" - + + + + + + + + + - + - - - - - - - + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace unversioned CTO, format 'xmlschema' 4`] = ` +{ + "key": "org.acme.hr.xsd", + "value": " + + + - + + + + + + @@ -4811,10 +5196,11 @@ xmlns:concerto="concerto" - + + @@ -4829,7 +5215,7 @@ xmlns:concerto="concerto" - + @@ -4882,7 +5268,7 @@ xmlns:concerto="concerto" - + @@ -4897,7 +5283,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "model.mmd", "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { +class \`org.acme.hr.base@1.0.0.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -4907,35 +5293,40 @@ class \`org.acme.hr@1.0.0.State\` { + \`CA\` } -class \`org.acme.hr@1.0.0.Address\` { +class \`org.acme.hr.base@1.0.0.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +class \`org.acme.hr.base@1.0.0.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` +} + +\`org.acme.hr.base@1.0.0.Address\` "1" *-- "1" \`org.acme.hr.base@1.0.0.State\` class \`org.acme.hr@1.0.0.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.CompanyProperties\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeDirectory\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeProfiles\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` class \`org.acme.hr@1.0.0.Department\` { << enumeration>> + \`Sales\` @@ -4974,10 +5365,12 @@ class \`org.acme.hr@1.0.0.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.NextOfKin\` class \`org.acme.hr@1.0.0.Employee\` { << participant>> + \`String\` \`employeeId\` @@ -4991,7 +5384,7 @@ class \`org.acme.hr@1.0.0.Employee\` { } \`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager \`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` @@ -5028,7 +5421,7 @@ class \`org.acme.hr@1.0.0.ChangeOfAddress\` { } \`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` ", } `; @@ -5040,7 +5433,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio title Model endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { +class org.acme.hr.base_1_0_0.State << (E,grey) >> { + MA + NY + CO @@ -5048,31 +5441,34 @@ class org.acme.hr_1_0_0.State << (E,grey) >> { + IL + CA } -class org.acme.hr_1_0_0.Address { +class org.acme.hr.base_1_0_0.TShirtSizeType << (E,grey) >> { + + SMALL + + MEDIUM + + LARGE +} +class org.acme.hr.base_1_0_0.Address { + String street + String city + State state + String zipCode + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map1 : dictionary1 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map2 : dictionary2 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map3 : dictionary3 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map4 : dictionary4 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map5 : dictionary5 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map6 : dictionary6 +} +org.acme.hr.base_1_0_0.Address "1" *-- "1" org.acme.hr.base_1_0_0.State : state class org.acme.hr_1_0_0.Company { + String name + Address headquarters -} -org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters + + CompanyProperties companyProperties + + EmployeeDirectory employeeDirectory + + EmployeeTShirtSizes employeeTShirtSizes + + EmployeeProfiles employeeProfiles + + EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers +} +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.Address : headquarters +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.CompanyProperties : companyProperties +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeDirectory : employeeDirectory +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.EmployeeTShirtSizes : employeeTShirtSizes +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeProfiles : employeeProfiles +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeSocialSecurityNumbers : employeeSocialSecurityNumbers class org.acme.hr_1_0_0.Department << (E,grey) >> { + Sales + Marketing @@ -5102,9 +5498,11 @@ class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + String ssn + Double height + DateTime dob + + NextOfKin nextOfKin } -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.Address : homeAddress -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.Address : homeAddress +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.NextOfKin : nextOfKin class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + String employeeId + Long salary @@ -5116,7 +5514,7 @@ class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + Manager manager } org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Department : department -org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Address : officeAddress +org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr.base_1_0_0.Address : officeAddress org.acme.hr_1_0_0.Employee "1" *-- "*" org.acme.hr_1_0_0.Equipment : companyAssets org.acme.hr_1_0_0.Employee "1" o-- "1" org.acme.hr_1_0_0.Manager : manager org.acme.hr_1_0_0.Employee --|> org.acme.hr_1_0_0.Person @@ -5144,7 +5542,7 @@ class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + Address newAddress } org.acme.hr_1_0_0.ChangeOfAddress "1" o-- "1" org.acme.hr_1_0_0.Person : Person -org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr_1_0_0.Address : newAddress +org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr.base_1_0_0.Address : newAddress @enduml ", } @@ -5156,7 +5554,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -5189,7 +5587,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -5214,12 +5612,12 @@ protocol MyProtocol { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 3`] = ` { - "key": "org.acme.hr@1.0.0.avdl", - "value": "@namespace("org.acme.hr@1.0.0") + "key": "org.acme.hr.base@1.0.0.avdl", + "value": "@namespace("org.acme.hr.base@1.0.0") protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -5229,23 +5627,42 @@ protocol MyProtocol { CA } + enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE + } + record Address { string street; string city; union { null, State } state; string zipCode; string country; - Map1 dictionary1; - Map2 dictionary2; - Map3 dictionary3; - Map4 dictionary4; - Map5 dictionary5; - Map6 dictionary6; } +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.avdl", + "value": "@namespace("org.acme.hr@1.0.0") +protocol MyProtocol { + + import idl "org.acme.hr.base@1.0.0.avdl"; + import idl "concerto@1.0.0.avdl"; + record Company { string name; Address headquarters; + union { null, CompanyProperties } companyProperties; + union { null, EmployeeDirectory } employeeDirectory; + union { null, EmployeeTShirtSizes } employeeTShirtSizes; + union { null, EmployeeProfiles } employeeProfiles; + union { null, EmployeeSocialSecurityNumbers } employeeSocialSecurityNumbers; } enum Department { @@ -5281,6 +5698,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Employee { @@ -5301,6 +5719,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Contractor { @@ -5315,6 +5734,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record Manager { @@ -5336,6 +5756,7 @@ protocol MyProtocol { double height; @logicalType("timestamp-micros") long dob; + NextOfKin nextOfKin; } record CompanyEvent { @@ -5455,8 +5876,8 @@ public abstract class Event : Concept { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 3`] = ` { - "key": "org.acme.hr@1.0.0.cs", - "value": "namespace org.acme.hr; + "key": "org.acme.hr.base@1.0.0.cs", + "value": "namespace org.acme.hr.base; using AccordProject.Concerto; [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum State { @@ -5467,32 +5888,49 @@ public enum State { IL, CA, } -[AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Address")] +[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +[AccordProject.Concerto.Type(Namespace = "org.acme.hr.base", Version = "1.0.0", Name = "Address")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Address : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] - public override string _class { get; } = "org.acme.hr@1.0.0.Address"; + public override string _class { get; } = "org.acme.hr.base@1.0.0.Address"; public string street { get; set; } public string city { get; set; } public State? state { get; set; } public string zipCode { get; set; } public string country { get; set; } - public Dictionary dictionary1 { get; set; } - public Dictionary dictionary2 { get; set; } - public Dictionary dictionary3 { get; set; } - public Dictionary dictionary4 { get; set; } - public Dictionary dictionary5 { get; set; } - public Dictionary dictionary6 { get; set; } } //Dummy implementation of the scalar declaration to avoid compilation errors. class Time_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class SSN_Dummy {} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'csharp' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.cs", + "value": "namespace org.acme.hr; +using org.acme.hr.base; +using AccordProject.Concerto; [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Company")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public class Company : Concept { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr@1.0.0.Company"; public string name { get; set; } - public Address headquarters { get; set; } + public org.acme.hr.base.Address headquarters { get; set; } + public Dictionary companyProperties { get; set; } + public Dictionary employeeDirectory { get; set; } + public Dictionary employeeTShirtSizes { get; set; } + public Dictionary employeeProfiles { get; set; } + public Dictionary employeeSocialSecurityNumbers { get; set; } } [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] public enum Department { @@ -5523,8 +5961,6 @@ public class Laptop : Equipment { public override string _class { get; } = "org.acme.hr@1.0.0.Laptop"; public LaptopMake make { get; set; } } -//Dummy implementation of the scalar declaration to avoid compilation errors. -class SSN_Dummy {} [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Person")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] public abstract class Person : Participant { @@ -5535,11 +5971,12 @@ public abstract class Person : Participant { public string firstName { get; set; } public string lastName { get; set; } public string? middleNames { get; set; } - public Address homeAddress { get; set; } + public org.acme.hr.base.Address homeAddress { get; set; } [System.ComponentModel.DataAnnotations.RegularExpression(@"\\d{3}-\\d{2}-\\{4}+", ErrorMessage = "Invalid characters")] public string ssn { get; set; } public float height { get; set; } public System.DateTime dob { get; set; } + public Dictionary nextOfKin { get; set; } } [AccordProject.Concerto.Type(Namespace = "org.acme.hr", Version = "1.0.0", Name = "Employee")] [System.Text.Json.Serialization.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterFactorySystem))] @@ -5551,7 +5988,7 @@ public class Employee : Person { public int numDependents { get; set; } public bool retired { get; set; } public Department department { get; set; } - public Address officeAddress { get; set; } + public org.acme.hr.base.Address officeAddress { get; set; } public Equipment[] companyAssets { get; set; } public Manager manager { get; set; } } @@ -5589,8 +6026,12 @@ public class ChangeOfAddress : Transaction { [System.Text.Json.Serialization.JsonPropertyName("$class")] public override string _class { get; } = "org.acme.hr@1.0.0.ChangeOfAddress"; public Person Person { get; set; } - public Address newAddress { get; set; } + public org.acme.hr.base.Address newAddress { get; set; } } +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinName_Dummy {} +//Dummy implementation of the scalar declaration to avoid compilation errors. +class KinTelephone_Dummy {} ", } `; @@ -5601,7 +6042,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -5629,7 +6070,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -5652,12 +6093,11 @@ type Event struct { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 3`] = ` { - "key": "org.acme.hr@1.0.0.go", - "value": "// Package org_acme_hr_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr@1.0.0. -package org_acme_hr_1_0_0 -import "time" + "key": "org.acme.hr.base@1.0.0.go", + "value": "// Package org_acme_hr_base_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr.base@1.0.0. +package org_acme_hr_base_1_0_0 import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -5667,6 +6107,12 @@ const ( IL CA ) +type TShirtSizeType int +const ( + SMALL TShirtSizeType = 1 + iota + MEDIUM + LARGE +) type Address struct { concerto_1_0_0.Concept Street string \`json:"street"\` @@ -5674,17 +6120,29 @@ type Address struct { State State \`json:"state"\` ZipCode string \`json:"zipCode"\` Country string \`json:"country"\` - Dictionary1 Map1 \`json:"dictionary1"\` - Dictionary2 Map2 \`json:"dictionary2"\` - Dictionary3 Map3 \`json:"dictionary3"\` - Dictionary4 Map4 \`json:"dictionary4"\` - Dictionary5 Map5 \`json:"dictionary5"\` - Dictionary6 Map6 \`json:"dictionary6"\` } +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'golang' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.go", + "value": "// Package org_acme_hr_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr@1.0.0. +package org_acme_hr_1_0_0 +import "time" +import "org_acme_hr_base_1_0_0"; +import "concerto_1_0_0"; + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` Headquarters Address \`json:"headquarters"\` + CompanyProperties CompanyProperties \`json:"companyProperties"\` + EmployeeDirectory EmployeeDirectory \`json:"employeeDirectory"\` + EmployeeTShirtSizes EmployeeTShirtSizes \`json:"employeeTShirtSizes"\` + EmployeeProfiles EmployeeProfiles \`json:"employeeProfiles"\` + EmployeeSocialSecurityNumbers EmployeeSocialSecurityNumbers \`json:"employeeSocialSecurityNumbers"\` } type Department int const ( @@ -5718,6 +6176,7 @@ type Person struct { Ssn string \`json:"ssn"\` Height float64 \`json:"height"\` Dob time.Time \`json:"dob"\` + NextOfKin NextOfKin \`json:"nextOfKin"\` } type Employee struct { Person @@ -5760,7 +6219,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "model.gql", "value": "directive @resource on OBJECT | FIELD_DEFINITION scalar DateTime -# namespace org.acme.hr@1.0.0 +# namespace org.acme.hr.base@1.0.0 enum State { MA NY @@ -5769,46 +6228,55 @@ enum State { IL CA } +enum TShirtSizeType { + SMALL + MEDIUM + LARGE +} +type EmployeeTShirtSizes { + key: SSN + value: TShirtSizeType +} type Address { street: String! city: String! state: State zipCode: String! country: String! - dictionary1: Map1! - dictionary2: Map2! - dictionary3: Map3! - dictionary4: Map4! - dictionary5: Map5! - dictionary6: Map6! -} -type Map1 { +} +# namespace org.acme.hr@1.0.0 +type CompanyProperties { key: String value: String } -type Map2 { +type EmployeeLoginTimes { key: String - value: DateTime + value: Time } -type Map3 { +type EmployeeSocialSecurityNumbers { key: String value: SSN } -type Map4 { +type NextOfKin { + key: KinName + value: KinTelephone +} +type EmployeeProfiles { key: String value: Concept } -type Map5 { - key: SSN - value: String -} -type Map6 { +type EmployeeDirectory { key: SSN value: Employee } type Company { name: String! headquarters: Address! + companyProperties: CompanyProperties + employeeDirectory: EmployeeDirectory + employeeTShirtSizes: EmployeeTShirtSizes + employeeProfiles: EmployeeProfiles + employeeSocialSecurityNumbers: EmployeeSocialSecurityNumbers } enum Department { Sales @@ -5840,6 +6308,7 @@ type Person @resource { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Employee { @@ -5859,6 +6328,7 @@ type Employee { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Contractor { @@ -5872,6 +6342,7 @@ type Contractor { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type Manager { @@ -5892,6 +6363,7 @@ type Manager { ssn: String! height: Float! dob: DateTime! + nextOfKin: NextOfKin! _identifier: String! } type CompanyEvent { @@ -5946,7 +6418,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -5985,7 +6457,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6035,9 +6507,9 @@ public abstract class Event extends Concept { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 6`] = ` { - "key": "org/acme/hr/State.java", + "key": "org/acme/hr/base/State.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"$class"}) @@ -6055,9 +6527,26 @@ public enum State { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 7`] = ` { - "key": "org/acme/hr/Address.java", + "key": "org/acme/hr/base/TShirtSizeType.java", "value": "// this code is generated and should not be modified -package org.acme.hr; +package org.acme.hr.base; + +import com.fasterxml.jackson.annotation.*; +@JsonIgnoreProperties({"$class"}) +public enum TShirtSizeType { + SMALL, + MEDIUM, + LARGE, +} +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 8`] = ` +{ + "key": "org/acme/hr/base/Address.java", + "value": "// this code is generated and should not be modified +package org.acme.hr.base; import concerto.Concept; import concerto.Asset; @@ -6073,12 +6562,6 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map dictionary1 = new HashMap<>(); - private Map dictionary2 = new HashMap<>(); - private Map dictionary3 = new HashMap<>(); - private Map dictionary4 = new HashMap<>(); - private Map dictionary5 = new HashMap<>(); - private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } @@ -6094,24 +6577,6 @@ public class Address extends Concept { public String getCountry() { return this.country; } - public Map1 getDictionary1() { - return this.dictionary1; - } - public Map2 getDictionary2() { - return this.dictionary2; - } - public Map3 getDictionary3() { - return this.dictionary3; - } - public Map4 getDictionary4() { - return this.dictionary4; - } - public Map5 getDictionary5() { - return this.dictionary5; - } - public Map6 getDictionary6() { - return this.dictionary6; - } public void setStreet(String street) { this.street = street; } @@ -6127,35 +6592,22 @@ public class Address extends Concept { public void setCountry(String country) { this.country = country; } - public void setDictionary1(Map1 dictionary1) { - this.dictionary1 = dictionary1; - } - public void setDictionary2(Map2 dictionary2) { - this.dictionary2 = dictionary2; - } - public void setDictionary3(Map3 dictionary3) { - this.dictionary3 = dictionary3; - } - public void setDictionary4(Map4 dictionary4) { - this.dictionary4 = dictionary4; - } - public void setDictionary5(Map5 dictionary5) { - this.dictionary5 = dictionary5; - } - public void setDictionary6(Map6 dictionary6) { - this.dictionary6 = dictionary6; - } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 8`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 9`] = ` { "key": "org/acme/hr/Company.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6167,24 +6619,59 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; + private CompanyProperties companyProperties; + private EmployeeDirectory employeeDirectory; + private EmployeeTShirtSizes employeeTShirtSizes; + private EmployeeProfiles employeeProfiles; + private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; public String getName() { return this.name; } public Address getHeadquarters() { return this.headquarters; } + public CompanyProperties getCompanyProperties() { + return this.companyProperties; + } + public EmployeeDirectory getEmployeeDirectory() { + return this.employeeDirectory; + } + public EmployeeTShirtSizes getEmployeeTShirtSizes() { + return this.employeeTShirtSizes; + } + public EmployeeProfiles getEmployeeProfiles() { + return this.employeeProfiles; + } + public EmployeeSocialSecurityNumbers getEmployeeSocialSecurityNumbers() { + return this.employeeSocialSecurityNumbers; + } public void setName(String name) { this.name = name; } public void setHeadquarters(Address headquarters) { this.headquarters = headquarters; } + public void setCompanyProperties(CompanyProperties companyProperties) { + this.companyProperties = companyProperties; + } + public void setEmployeeDirectory(EmployeeDirectory employeeDirectory) { + this.employeeDirectory = employeeDirectory; + } + public void setEmployeeTShirtSizes(EmployeeTShirtSizes employeeTShirtSizes) { + this.employeeTShirtSizes = employeeTShirtSizes; + } + public void setEmployeeProfiles(EmployeeProfiles employeeProfiles) { + this.employeeProfiles = employeeProfiles; + } + public void setEmployeeSocialSecurityNumbers(EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers) { + this.employeeSocialSecurityNumbers = employeeSocialSecurityNumbers; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 9`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 10`] = ` { "key": "org/acme/hr/Department.java", "value": "// this code is generated and should not be modified @@ -6204,12 +6691,17 @@ public enum Department { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 10`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 11`] = ` { "key": "org/acme/hr/Equipment.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6220,7 +6712,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6238,7 +6730,7 @@ public abstract class Equipment extends Asset { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 11`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 12`] = ` { "key": "org/acme/hr/LaptopMake.java", "value": "// this code is generated and should not be modified @@ -6254,12 +6746,17 @@ public enum LaptopMake { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 12`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 13`] = ` { "key": "org/acme/hr/Laptop.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6270,7 +6767,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6288,12 +6785,17 @@ public class Laptop extends Equipment { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 13`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 14`] = ` { "key": "org/acme/hr/Person.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6304,7 +6806,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6318,6 +6820,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; + private NextOfKin nextOfKin; public String getEmail() { return this.email; } @@ -6342,6 +6845,9 @@ public abstract class Person extends Participant { public java.util.Date getDob() { return this.dob; } + public NextOfKin getNextOfKin() { + return this.nextOfKin; + } public void setEmail(String email) { this.email = email; } @@ -6366,17 +6872,25 @@ public abstract class Person extends Participant { public void setDob(java.util.Date dob) { this.dob = dob; } + public void setNextOfKin(NextOfKin nextOfKin) { + this.nextOfKin = nextOfKin; + } } ", } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 14`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 15`] = ` { "key": "org/acme/hr/Employee.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6387,7 +6901,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6454,12 +6968,17 @@ public class Employee extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 15`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 16`] = ` { "key": "org/acme/hr/Contractor.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6470,7 +6989,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6495,12 +7014,17 @@ public class Contractor extends Person { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 16`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 17`] = ` { "key": "org/acme/hr/Manager.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6511,7 +7035,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6529,12 +7053,17 @@ public class Manager extends Employee { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 17`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 18`] = ` { "key": "org/acme/hr/CompanyEvent.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6548,12 +7077,17 @@ public class CompanyEvent extends Event { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 18`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 19`] = ` { "key": "org/acme/hr/Onboarded.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6574,12 +7108,17 @@ public class Onboarded extends CompanyEvent { } `; -exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 19`] = ` +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'java' 20`] = ` { "key": "org/acme/hr/ChangeOfAddress.java", "value": "// this code is generated and should not be modified package org.acme.hr; +import org.acme.hr.base.Address; +import org.acme.hr.base.State; +import org.acme.hr.base.SSN; +import org.acme.hr.base.Time; +import org.acme.hr.base.EmployeeTShirtSizes; import concerto.Concept; import concerto.Asset; import concerto.Transaction; @@ -6613,9 +7152,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { - "org.acme.hr@1.0.0.State": { + "org.acme.hr.base@1.0.0.State": { "title": "State", - "description": "An instance of org.acme.hr@1.0.0.State", + "description": "An instance of org.acme.hr.base@1.0.0.State", "enum": [ "MA", "NY", @@ -6625,16 +7164,25 @@ exports[`codegen #formats check we can convert all formats from namespace versio "CA" ] }, - "org.acme.hr@1.0.0.Address": { + "org.acme.hr.base@1.0.0.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base@1.0.0.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base@1.0.0.Address": { "title": "Address", - "description": "An instance of org.acme.hr@1.0.0.Address", + "description": "An instance of org.acme.hr.base@1.0.0.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr@1.0.0.Address", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Address$", - "description": "The class identifier for org.acme.hr@1.0.0.Address" + "default": "org.acme.hr.base@1.0.0.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base@1\\\\.0\\\\.0\\\\.Address$", + "description": "The class identifier for org.acme.hr.base@1.0.0.Address" }, "street": { "type": "string" @@ -6643,7 +7191,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "state": { - "$ref": "#/definitions/org.acme.hr@1.0.0.State" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.State" }, "zipCode": { "type": "string" @@ -6657,19 +7205,17 @@ exports[`codegen #formats check we can convert all formats from namespace versio "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr@1.0.0.Time": { + "org.acme.hr.base@1.0.0.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base@1.0.0.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr@1.0.0.Company": { "title": "Company", "description": "An instance of org.acme.hr@1.0.0.Company", @@ -6685,7 +7231,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "headquarters": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -6763,10 +7309,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "serialNumber" ] }, - "org.acme.hr@1.0.0.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr@1.0.0.Person": { "title": "Person", "description": "An instance of org.acme.hr@1.0.0.Person", @@ -6792,7 +7334,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -6815,7 +7357,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -6848,7 +7391,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/definitions/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -6881,7 +7424,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -6911,7 +7454,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Contractor": { @@ -6946,7 +7490,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -6970,7 +7514,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Manager": { @@ -7007,7 +7552,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/definitions/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -7040,7 +7585,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7070,7 +7615,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.CompanyEvent": { @@ -7126,7 +7672,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" }, "newAddress": { - "$ref": "#/definitions/org.acme.hr@1.0.0.Address" + "$ref": "#/definitions/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -7134,6 +7680,13 @@ exports[`codegen #formats check we can convert all formats from namespace versio "Person", "newAddress" ] + }, + "org.acme.hr@1.0.0.KinName": { + "type": "string" + }, + "org.acme.hr@1.0.0.KinTelephone": { + "format": "date-time", + "type": "string" } } } @@ -7144,16 +7697,16 @@ exports[`codegen #formats check we can convert all formats from namespace versio exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'markdown' 1`] = ` { "key": "models.md", - "value": "# Namespace org.acme.hr@1.0.0 + "value": "# Namespace org.acme.hr.base@1.0.0 ## Overview -- 2 concepts -- 3 enumerations -- 2 assets -- 4 participants -- 1 transactions -- 2 events -- 22 total declarations +- 1 concepts +- 2 enumerations +- 0 assets +- 0 participants +- 0 transactions +- 0 events +- 6 total declarations ## Imports - concerto@1.0.0.Concept @@ -7165,7 +7718,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio ## Diagram \`\`\`mermaid classDiagram -class \`org.acme.hr@1.0.0.State\` { +class \`org.acme.hr.base@1.0.0.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -7175,35 +7728,68 @@ class \`org.acme.hr@1.0.0.State\` { + \`CA\` } -class \`org.acme.hr@1.0.0.Address\` { +class \`org.acme.hr.base@1.0.0.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +class \`org.acme.hr.base@1.0.0.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` +} + +\`org.acme.hr.base@1.0.0.Address\` "1" *-- "1" \`org.acme.hr.base@1.0.0.State\` +\`\`\` + +# Namespace org.acme.hr@1.0.0 + +## Overview +- 1 concepts +- 2 enumerations +- 2 assets +- 4 participants +- 1 transactions +- 2 events +- 20 total declarations + +## Imports +- org.acme.hr.base@1.0.0.Address +- org.acme.hr.base@1.0.0.State +- org.acme.hr.base@1.0.0.SSN +- org.acme.hr.base@1.0.0.Time +- org.acme.hr.base@1.0.0.EmployeeTShirtSizes +- concerto@1.0.0.Concept +- concerto@1.0.0.Asset +- concerto@1.0.0.Transaction +- concerto@1.0.0.Participant +- concerto@1.0.0.Event + +## Diagram +\`\`\`mermaid +classDiagram class \`org.acme.hr@1.0.0.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.CompanyProperties\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeDirectory\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeProfiles\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` class \`org.acme.hr@1.0.0.Department\` { << enumeration>> + \`Sales\` @@ -7242,10 +7828,12 @@ class \`org.acme.hr@1.0.0.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.NextOfKin\` class \`org.acme.hr@1.0.0.Employee\` { << participant>> + \`String\` \`employeeId\` @@ -7259,7 +7847,7 @@ class \`org.acme.hr@1.0.0.Employee\` { } \`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager \`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` @@ -7296,7 +7884,7 @@ class \`org.acme.hr@1.0.0.ChangeOfAddress\` { } \`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`\`\` ", @@ -7307,7 +7895,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "model.mmd", "value": "classDiagram -class \`org.acme.hr@1.0.0.State\` { +class \`org.acme.hr.base@1.0.0.State\` { << enumeration>> + \`MA\` + \`NY\` @@ -7317,37 +7905,43 @@ class \`org.acme.hr@1.0.0.State\` { + \`CA\` } -\`org.acme.hr@1.0.0.State\` --|> \`concerto@1.0.0.Concept\` -class \`org.acme.hr@1.0.0.Address\` { +\`org.acme.hr.base@1.0.0.State\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base@1.0.0.TShirtSizeType\` { +<< enumeration>> + + \`SMALL\` + + \`MEDIUM\` + + \`LARGE\` +} + +\`org.acme.hr.base@1.0.0.TShirtSizeType\` --|> \`concerto@1.0.0.Concept\` +class \`org.acme.hr.base@1.0.0.Address\` { << concept>> + \`String\` \`street\` + \`String\` \`city\` + \`State\` \`state\` + \`String\` \`zipCode\` + \`String\` \`country\` - + \`Map1\` \`dictionary1\` - + \`Map2\` \`dictionary2\` - + \`Map3\` \`dictionary3\` - + \`Map4\` \`dictionary4\` - + \`Map5\` \`dictionary5\` - + \`Map6\` \`dictionary6\` -} - -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.State\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map1\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map2\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map3\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map4\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map5\` -\`org.acme.hr@1.0.0.Address\` "1" *-- "1" \`org.acme.hr@1.0.0.Map6\` -\`org.acme.hr@1.0.0.Address\` --|> \`concerto@1.0.0.Concept\` +} + +\`org.acme.hr.base@1.0.0.Address\` "1" *-- "1" \`org.acme.hr.base@1.0.0.State\` +\`org.acme.hr.base@1.0.0.Address\` --|> \`concerto@1.0.0.Concept\` class \`org.acme.hr@1.0.0.Company\` { << concept>> + \`String\` \`name\` + \`Address\` \`headquarters\` -} - -\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` + + \`CompanyProperties\` \`companyProperties\` + + \`EmployeeDirectory\` \`employeeDirectory\` + + \`EmployeeTShirtSizes\` \`employeeTShirtSizes\` + + \`EmployeeProfiles\` \`employeeProfiles\` + + \`EmployeeSocialSecurityNumbers\` \`employeeSocialSecurityNumbers\` +} + +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.CompanyProperties\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeDirectory\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeProfiles\` +\`org.acme.hr@1.0.0.Company\` "1" *-- "1" \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` \`org.acme.hr@1.0.0.Company\` --|> \`concerto@1.0.0.Concept\` class \`org.acme.hr@1.0.0.Department\` { << enumeration>> @@ -7390,10 +7984,12 @@ class \`org.acme.hr@1.0.0.Person\` { + \`String\` \`ssn\` + \`Double\` \`height\` + \`DateTime\` \`dob\` + + \`NextOfKin\` \`nextOfKin\` } -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` -\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr.base@1.0.0.SSN\` +\`org.acme.hr@1.0.0.Person\` "1" *-- "1" \`org.acme.hr@1.0.0.NextOfKin\` \`org.acme.hr@1.0.0.Person\` --|> \`concerto@1.0.0.Participant\` class \`org.acme.hr@1.0.0.Employee\` { << participant>> @@ -7408,7 +8004,7 @@ class \`org.acme.hr@1.0.0.Employee\` { } \`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Department\` -\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.Employee\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` "1" *-- "*" \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` "1" o-- "1" \`org.acme.hr@1.0.0.Manager\` : manager \`org.acme.hr@1.0.0.Employee\` --|> \`org.acme.hr@1.0.0.Person\` @@ -7446,7 +8042,7 @@ class \`org.acme.hr@1.0.0.ChangeOfAddress\` { } \`org.acme.hr@1.0.0.ChangeOfAddress\` "1" o-- "1" \`org.acme.hr@1.0.0.Person\` : Person -\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr@1.0.0.Address\` +\`org.acme.hr@1.0.0.ChangeOfAddress\` "1" *-- "1" \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --|> \`concerto@1.0.0.Transaction\` ", } @@ -7487,7 +8083,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 2`] = ` { - "key": "org.acme.hr.csdl", + "key": "org.acme.hr.base.csdl", "value": " @@ -7497,7 +8093,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7512,34 +8108,65 @@ exports[`codegen #formats check we can convert all formats from namespace versio + + + + + + + + - + - - - + + + + + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'odata' 3`] = ` +{ + "key": "org.acme.hr.csdl", + "value": " + + + + + + + + + + + + + + - + - + - + - + - - - + - + @@ -7583,7 +8210,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7591,6 +8218,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio + + @@ -7603,7 +8232,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7629,7 +8258,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio - + @@ -7658,9 +8287,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio }, "components": { "schemas": { - "org.acme.hr@1.0.0.State": { + "org.acme.hr.base@1.0.0.State": { "title": "State", - "description": "An instance of org.acme.hr@1.0.0.State", + "description": "An instance of org.acme.hr.base@1.0.0.State", "enum": [ "MA", "NY", @@ -7670,16 +8299,25 @@ exports[`codegen #formats check we can convert all formats from namespace versio "CA" ] }, - "org.acme.hr@1.0.0.Address": { + "org.acme.hr.base@1.0.0.TShirtSizeType": { + "title": "TShirtSizeType", + "description": "An instance of org.acme.hr.base@1.0.0.TShirtSizeType", + "enum": [ + "SMALL", + "MEDIUM", + "LARGE" + ] + }, + "org.acme.hr.base@1.0.0.Address": { "title": "Address", - "description": "An instance of org.acme.hr@1.0.0.Address", + "description": "An instance of org.acme.hr.base@1.0.0.Address", "type": "object", "properties": { "$class": { "type": "string", - "default": "org.acme.hr@1.0.0.Address", - "pattern": "^org\\\\.acme\\\\.hr@1\\\\.0\\\\.0\\\\.Address$", - "description": "The class identifier for org.acme.hr@1.0.0.Address" + "default": "org.acme.hr.base@1.0.0.Address", + "pattern": "^org\\\\.acme\\\\.hr\\\\.base@1\\\\.0\\\\.0\\\\.Address$", + "description": "The class identifier for org.acme.hr.base@1.0.0.Address" }, "street": { "type": "string" @@ -7688,7 +8326,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "state": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.State" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.State" }, "zipCode": { "type": "string" @@ -7702,19 +8340,17 @@ exports[`codegen #formats check we can convert all formats from namespace versio "street", "city", "zipCode", - "country", - "dictionary1", - "dictionary2", - "dictionary3", - "dictionary4", - "dictionary5", - "dictionary6" + "country" ] }, - "org.acme.hr@1.0.0.Time": { + "org.acme.hr.base@1.0.0.Time": { "format": "date-time", "type": "string" }, + "org.acme.hr.base@1.0.0.SSN": { + "type": "string", + "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" + }, "org.acme.hr@1.0.0.Company": { "title": "Company", "description": "An instance of org.acme.hr@1.0.0.Company", @@ -7730,7 +8366,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "headquarters": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -7808,10 +8444,6 @@ exports[`codegen #formats check we can convert all formats from namespace versio "serialNumber" ] }, - "org.acme.hr@1.0.0.SSN": { - "type": "string", - "pattern": "\\\\d{3}-\\\\d{2}-\\\\{4}+" - }, "org.acme.hr@1.0.0.Person": { "title": "Person", "description": "An instance of org.acme.hr@1.0.0.Person", @@ -7837,7 +8469,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7860,7 +8492,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ], "$decorators": { "resource": [] @@ -7893,7 +8526,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -7926,7 +8559,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -7956,7 +8589,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Contractor": { @@ -7991,7 +8625,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -8015,7 +8649,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.Manager": { @@ -8052,7 +8687,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "$ref": "#/components/schemas/org.acme.hr@1.0.0.Department" }, "officeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "companyAssets": { "type": "array", @@ -8085,7 +8720,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "type": "string" }, "homeAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" }, "ssn": { "default": "000-00-0000", @@ -8115,7 +8750,8 @@ exports[`codegen #formats check we can convert all formats from namespace versio "homeAddress", "ssn", "height", - "dob" + "dob", + "nextOfKin" ] }, "org.acme.hr@1.0.0.CompanyEvent": { @@ -8171,7 +8807,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "description": "The identifier of an instance of org.acme.hr@1.0.0.Person" }, "newAddress": { - "$ref": "#/components/schemas/org.acme.hr@1.0.0.Address" + "$ref": "#/components/schemas/org.acme.hr.base@1.0.0.Address" } }, "required": [ @@ -8179,6 +8815,13 @@ exports[`codegen #formats check we can convert all formats from namespace versio "Person", "newAddress" ] + }, + "org.acme.hr@1.0.0.KinName": { + "type": "string" + }, + "org.acme.hr@1.0.0.KinTelephone": { + "format": "date-time", + "type": "string" } } }, @@ -8442,7 +9085,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio title Model endtitle -class org.acme.hr_1_0_0.State << (E,grey) >> { +class org.acme.hr.base_1_0_0.State << (E,grey) >> { + MA + NY + CO @@ -8450,33 +9093,37 @@ class org.acme.hr_1_0_0.State << (E,grey) >> { + IL + CA } -org.acme.hr_1_0_0.State --|> concerto_1_0_0.Concept -class org.acme.hr_1_0_0.Address { +org.acme.hr.base_1_0_0.State --|> concerto_1_0_0.Concept +class org.acme.hr.base_1_0_0.TShirtSizeType << (E,grey) >> { + + SMALL + + MEDIUM + + LARGE +} +org.acme.hr.base_1_0_0.TShirtSizeType --|> concerto_1_0_0.Concept +class org.acme.hr.base_1_0_0.Address { + String street + String city + State state + String zipCode + String country - + Map1 dictionary1 - + Map2 dictionary2 - + Map3 dictionary3 - + Map4 dictionary4 - + Map5 dictionary5 - + Map6 dictionary6 -} -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.State : state -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map1 : dictionary1 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map2 : dictionary2 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map3 : dictionary3 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map4 : dictionary4 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map5 : dictionary5 -org.acme.hr_1_0_0.Address "1" *-- "1" org.acme.hr_1_0_0.Map6 : dictionary6 -org.acme.hr_1_0_0.Address --|> concerto_1_0_0.Concept +} +org.acme.hr.base_1_0_0.Address "1" *-- "1" org.acme.hr.base_1_0_0.State : state +org.acme.hr.base_1_0_0.Address --|> concerto_1_0_0.Concept class org.acme.hr_1_0_0.Company { + String name + Address headquarters -} -org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.Address : headquarters + + CompanyProperties companyProperties + + EmployeeDirectory employeeDirectory + + EmployeeTShirtSizes employeeTShirtSizes + + EmployeeProfiles employeeProfiles + + EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers +} +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.Address : headquarters +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.CompanyProperties : companyProperties +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeDirectory : employeeDirectory +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr.base_1_0_0.EmployeeTShirtSizes : employeeTShirtSizes +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeProfiles : employeeProfiles +org.acme.hr_1_0_0.Company "1" *-- "1" org.acme.hr_1_0_0.EmployeeSocialSecurityNumbers : employeeSocialSecurityNumbers org.acme.hr_1_0_0.Company --|> concerto_1_0_0.Concept class org.acme.hr_1_0_0.Department << (E,grey) >> { + Sales @@ -8510,9 +9157,11 @@ class org.acme.hr_1_0_0.Person << (P,lightblue) >> { + String ssn + Double height + DateTime dob + + NextOfKin nextOfKin } -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.Address : homeAddress -org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.Address : homeAddress +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr.base_1_0_0.SSN : ssn +org.acme.hr_1_0_0.Person "1" *-- "1" org.acme.hr_1_0_0.NextOfKin : nextOfKin org.acme.hr_1_0_0.Person --|> concerto_1_0_0.Participant class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + String employeeId @@ -8525,7 +9174,7 @@ class org.acme.hr_1_0_0.Employee << (P,lightblue) >> { + Manager manager } org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Department : department -org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr_1_0_0.Address : officeAddress +org.acme.hr_1_0_0.Employee "1" *-- "1" org.acme.hr.base_1_0_0.Address : officeAddress org.acme.hr_1_0_0.Employee "1" *-- "*" org.acme.hr_1_0_0.Equipment : companyAssets org.acme.hr_1_0_0.Employee "1" o-- "1" org.acme.hr_1_0_0.Manager : manager org.acme.hr_1_0_0.Employee --|> org.acme.hr_1_0_0.Person @@ -8554,7 +9203,7 @@ class org.acme.hr_1_0_0.ChangeOfAddress << (T,yellow) >> { + Address newAddress } org.acme.hr_1_0_0.ChangeOfAddress "1" o-- "1" org.acme.hr_1_0_0.Person : Person -org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr_1_0_0.Address : newAddress +org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr.base_1_0_0.Address : newAddress org.acme.hr_1_0_0.ChangeOfAddress --|> concerto_1_0_0.Transaction @enduml ", @@ -8563,10 +9212,10 @@ org.acme.hr_1_0_0.ChangeOfAddress --|> concerto_1_0_0.Transaction exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'protobuf' 1`] = ` { - "key": "org.acme.hr.v1_0_0.proto", + "key": "org.acme.hr.base.v1_0_0.proto", "value": "syntax = "proto3"; -package org.acme.hr.v1_0_0; +package org.acme.hr.base.v1_0_0; import "google/protobuf/timestamp.proto"; @@ -8579,23 +9228,42 @@ enum State { State_WA = 5; } +enum TShirtSizeType { + TShirtSizeType_LARGE = 0; + TShirtSizeType_MEDIUM = 1; + TShirtSizeType_SMALL = 2; +} + message Address { string city = 1; string country = 2; - Map1 dictionary1 = 3; - Map2 dictionary2 = 4; - Map3 dictionary3 = 5; - Map4 dictionary4 = 6; - Map5 dictionary5 = 7; - Map6 dictionary6 = 8; - optional State state = 9; - string street = 10; - string zipCode = 11; + optional State state = 3; + string street = 4; + string zipCode = 5; +} + +", } +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'protobuf' 2`] = ` +{ + "key": "org.acme.hr.v1_0_0.proto", + "value": "syntax = "proto3"; + +package org.acme.hr.v1_0_0; + +import "google/protobuf/timestamp.proto"; +import "org.acme.hr.base.v1_0_0.proto"; message Company { - Address headquarters = 1; - string name = 2; + optional CompanyProperties companyProperties = 1; + optional EmployeeDirectory employeeDirectory = 2; + optional EmployeeProfiles employeeProfiles = 3; + optional EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers = 4; + optional EmployeeTShirtSizes employeeTShirtSizes = 5; + Address headquarters = 6; + string name = 7; } enum Department { @@ -8643,11 +9311,12 @@ message Employee { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - bool retired = 14; - sint64 salary = 15; - string ssn = 16; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + bool retired = 15; + sint64 salary = 16; + string ssn = 17; } message _Subclasses_of_class_Employee { @@ -8667,7 +9336,8 @@ message Contractor { string lastName = 7; optional string manager = 8; optional string middleNames = 9; - string ssn = 10; + NextOfKin nextOfKin = 10; + string ssn = 11; } message Manager { @@ -8682,12 +9352,13 @@ message Manager { string lastName = 9; optional string manager = 10; optional string middleNames = 11; - sint64 numDependents = 12; - Address officeAddress = 13; - repeated string reports = 14; - bool retired = 15; - sint64 salary = 16; - string ssn = 17; + NextOfKin nextOfKin = 12; + sint64 numDependents = 13; + Address officeAddress = 14; + repeated string reports = 15; + bool retired = 16; + sint64 salary = 17; + string ssn = 18; } message CompanyEvent { @@ -8721,6 +9392,8 @@ pub mod concerto_1_0_0; #[allow(unused_imports)] pub mod concerto; #[allow(unused_imports)] +pub mod org_acme_hr_base_1_0_0; +#[allow(unused_imports)] pub mod org_acme_hr_1_0_0; #[allow(unused_imports)] pub mod utils; @@ -8733,7 +9406,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -8763,7 +9436,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -8780,9 +9453,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -8797,7 +9470,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -8810,7 +9483,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -8823,7 +9496,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -8838,7 +9511,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -8856,9 +9529,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -8873,7 +9546,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -8886,7 +9559,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -8915,13 +9588,13 @@ pub struct Event { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'rust' 5`] = ` { - "key": "org_acme_hr_1_0_0.rs", + "key": "org_acme_hr_base_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -8938,86 +9611,110 @@ pub enum State { CA, } +#[derive(Debug, Serialize, Deserialize)] +pub enum TShirtSizeType { + #[allow(non_camel_case_types)] + SMALL, + #[allow(non_camel_case_types)] + MEDIUM, + #[allow(non_camel_case_types)] + LARGE, +} + #[derive(Debug, Serialize, Deserialize)] pub struct Address { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] pub country: String, - - #[serde( - rename = "dictionary1", - )] - pub dictionary1: Map1, - +} + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'rust' 6`] = ` +{ + "key": "org_acme_hr_1_0_0.rs", + "value": "use serde::{ Deserialize, Serialize }; +use chrono::{ DateTime, TimeZone, Utc }; + +use crate::org_acme_hr_base_1_0_0::*; +use crate::concerto_1_0_0::*; +use crate::utils::*; + +#[derive(Debug, Serialize, Deserialize)] +pub struct Company { #[serde( - rename = "dictionary2", + rename = "$class", )] - pub dictionary2: Map2, - + pub _class: String, + #[serde( - rename = "dictionary3", + rename = "name", )] - pub dictionary3: Map3, - + pub name: String, + #[serde( - rename = "dictionary4", + rename = "headquarters", )] - pub dictionary4: Map4, - + pub headquarters: Address, + #[serde( - rename = "dictionary5", + rename = "companyProperties", + skip_serializing_if = "Option::is_none", )] - pub dictionary5: Map5, - + pub company_properties: Option, + #[serde( - rename = "dictionary6", + rename = "employeeDirectory", + skip_serializing_if = "Option::is_none", )] - pub dictionary6: Map6, -} + pub employee_directory: Option, -#[derive(Debug, Serialize, Deserialize)] -pub struct Company { #[serde( - rename = "$class", + rename = "employeeTShirtSizes", + skip_serializing_if = "Option::is_none", )] - pub _class: String, - + pub employee_t_shirt_sizes: Option, + #[serde( - rename = "name", + rename = "employeeProfiles", + skip_serializing_if = "Option::is_none", )] - pub name: String, - + pub employee_profiles: Option, + #[serde( - rename = "headquarters", + rename = "employeeSocialSecurityNumbers", + skip_serializing_if = "Option::is_none", )] - pub headquarters: Address, + pub employee_social_security_numbers: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -9042,12 +9739,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9068,17 +9765,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9091,50 +9788,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9147,88 +9849,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9241,58 +9948,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9305,91 +10017,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + + #[serde( + rename = "nextOfKin", + )] + pub next_of_kin: NextOfKin, + #[serde( rename = "$identifier", )] @@ -9402,7 +10119,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9417,10 +10134,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9435,15 +10152,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9467,7 +10184,10 @@ exports[`codegen #formats check we can convert all formats from namespace versio // Warning: Beware of circular dependencies when modifying these imports import type { State, - IAddress, + TShirtSizeType, + IAddress +} from './org.acme.hr.base@1.0.0'; +import type { ICompany, Department, LaptopMake @@ -9498,7 +10218,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -9562,20 +10282,12 @@ export interface IEvent extends IConcept { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'typescript' 3`] = ` { - "key": "org.acme.hr@1.0.0.ts", + "key": "org.acme.hr.base@1.0.0.ts", "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ -// Generated code for namespace: org.acme.hr@1.0.0 +// Generated code for namespace: org.acme.hr.base@1.0.0 // imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports - -// Warning: Beware of circular dependencies when modifying these imports -import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; +import {IConcept} from './concerto@1.0.0'; // interfaces export enum State { @@ -9587,35 +10299,65 @@ export enum State { CA = 'CA', } +export enum TShirtSizeType { + SMALL = 'SMALL', + MEDIUM = 'MEDIUM', + LARGE = 'LARGE', +} + +export type EmployeeTShirtSizes = Map; + export interface IAddress extends IConcept { street: string; city: string; state?: State; zipCode: string; country: string; - dictionary1: Map1; - dictionary2: Map2; - dictionary3: Map3; - dictionary4: Map4; - dictionary5: Map5; - dictionary6: Map6; } -export type Map1 = Map; +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'typescript' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.ts", + "value": "/* eslint-disable @typescript-eslint/no-empty-interface */ +// Generated code for namespace: org.acme.hr@1.0.0 + +// imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports + +// Warning: Beware of circular dependencies when modifying these imports +import {IAddress,IEmployeeTShirtSizes,ISSN} from './org.acme.hr.base@1.0.0'; +import {IConcept,IAsset,IParticipant,IEvent,ITransaction} from './concerto@1.0.0'; + +// interfaces +export type CompanyProperties = Map; -export type Map2 = Map; +export type EmployeeLoginTimes = Map; -export type Map3 = Map; +export type EmployeeSocialSecurityNumbers = Map; -export type Map4 = Map; +export type NextOfKin = Map; -export type Map5 = Map; +export type EmployeeProfiles = Map; -export type Map6 = Map; +export type EmployeeDirectory = Map; export interface ICompany extends IConcept { name: string; headquarters: IAddress; + companyProperties?: CompanyProperties; + employeeDirectory?: EmployeeDirectory; + employeeTShirtSizes?: EmployeeTShirtSizes; + employeeProfiles?: EmployeeProfiles; + employeeSocialSecurityNumbers?: EmployeeSocialSecurityNumbers; } export enum Department { @@ -9651,9 +10393,10 @@ export interface IPerson extends IParticipant { ssn: string; height: number; dob: Date; + nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -9698,10 +10441,10 @@ export interface IChangeOfAddress extends ITransaction { exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'vocabulary' 1`] = ` { - "key": "org.acme.hr@1.0.0_en.voc", - "value": "#Generated vocabulary for namespace: org.acme.hr@1.0.0 + "key": "org.acme.hr.base@1.0.0_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr.base@1.0.0 locale: en -namespace: org.acme.hr@1.0.0 +namespace: org.acme.hr.base@1.0.0 declarations: - State: State properties: @@ -9711,6 +10454,11 @@ declarations: - WA: WA of the State - IL: IL of the State - CA: CA of the State + - TShirtSizeType: TShirt Size Type + properties: + - SMALL: SMALL of the TShirt Size Type + - MEDIUM: MEDIUM of the TShirt Size Type + - LARGE: LARGE of the TShirt Size Type - Address: Address properties: - street: Street of the Address @@ -9718,17 +10466,28 @@ declarations: - state: State of the Address - zipCode: Zip Code of the Address - country: Country of the Address - - dictionary1: Dictionary1 of the Address - - dictionary2: Dictionary2 of the Address - - dictionary3: Dictionary3 of the Address - - dictionary4: Dictionary4 of the Address - - dictionary5: Dictionary5 of the Address - - dictionary6: Dictionary6 of the Address - Time: Time + - SSN: SSN +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'vocabulary' 2`] = ` +{ + "key": "org.acme.hr@1.0.0_en.voc", + "value": "#Generated vocabulary for namespace: org.acme.hr@1.0.0 +locale: en +namespace: org.acme.hr@1.0.0 +declarations: - Company: Company properties: - name: Name of the Company - headquarters: Headquarters of the Company + - companyProperties: Company Properties of the Company + - employeeDirectory: Employee Directory of the Company + - employeeTShirtSizes: Employee TShirt Sizes of the Company + - employeeProfiles: Employee Profiles of the Company + - employeeSocialSecurityNumbers: Employee Social Security Numbers of the Company - Department: Department properties: - Sales: Sales of the Department @@ -9747,7 +10506,6 @@ declarations: - Laptop: Laptop properties: - make: Make of the Laptop - - SSN: SSN - Person: Person properties: - email: Email of the Person @@ -9758,6 +10516,7 @@ declarations: - ssn: Ssn of the Person - height: Height of the Person - dob: Dob of the Person + - nextOfKin: Next Of Kin of the Person - Employee: Employee properties: - employeeId: Employee Id of the Employee @@ -9783,6 +10542,8 @@ declarations: properties: - Person: Person of the Change Of Address - newAddress: New Address of the Change Of Address + - KinName: Kin Name + - KinTelephone: Kin Telephone ", } `; @@ -9791,7 +10552,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto@1.0.0.xsd", "value": " - @@ -9847,7 +10608,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto.xsd", "value": " - @@ -9899,9 +10660,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'xmlschema' 3`] = ` { - "key": "org.acme.hr@1.0.0.xsd", + "key": "org.acme.hr.base@1.0.0.xsd", "value": " - @@ -9915,33 +10676,55 @@ xmlns:concerto="concerto" - + + + + + + + + + - + - - - - - - - + + +", +} +`; + +exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'xmlschema' 4`] = ` +{ + "key": "org.acme.hr@1.0.0.xsd", + "value": " + + + - + + + + + + @@ -9993,10 +10776,11 @@ xmlns:concerto="concerto" - + + @@ -10011,7 +10795,7 @@ xmlns:concerto="concerto" - + @@ -10064,7 +10848,7 @@ xmlns:concerto="concerto" - + diff --git a/test/codegen/codegen.js b/test/codegen/codegen.js index e4933acf..b80204d2 100644 --- a/test/codegen/codegen.js +++ b/test/codegen/codegen.js @@ -37,10 +37,15 @@ describe('codegen', function () { versionedModelManager = new ModelManager(); unversionedModelManager = new ModelManager(); + const base_cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr_base.cto', 'utf-8'); const cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); + + versionedModelManager.addCTOModel(base_cto, 'hr_base.cto'); versionedModelManager.addCTOModel(cto, 'hr.cto'); - const unversionedCto = cto.replace('namespace org.acme.hr@1.0.0', 'namespace org.acme.hr'); + const unversionedBaseCto = base_cto.replace('namespace org.acme.hr.base@1.0.0', 'namespace org.acme.hr.base'); + const unversionedCto = cto.replace('namespace org.acme.hr@1.0.0', 'namespace org.acme.hr').replace('import org.acme.hr.base@1.0.0', 'import org.acme.hr.base'); + unversionedModelManager.addCTOModel(unversionedBaseCto, 'hr_base.cto'); unversionedModelManager.addCTOModel(unversionedCto, 'hr.cto'); }); diff --git a/test/codegen/fromcto/csharp/csharpvisitor.js b/test/codegen/fromcto/csharp/csharpvisitor.js index 91dce556..28c5af63 100644 --- a/test/codegen/fromcto/csharp/csharpvisitor.js +++ b/test/codegen/fromcto/csharp/csharpvisitor.js @@ -1504,18 +1504,16 @@ public class SampleModel : Concept { it('should write a line for field name and type thats a map of ', () => { const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.getModelFile.returns({ getType: getType }); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('String'); mockField.getName.returns('Map1'); @@ -1530,18 +1528,17 @@ public class SampleModel : Concept { it('should write a line for field name and type thats a map of ', () => { const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.getModelFile.returns({ getType: getType }); + let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('Concept'); mockField.getName.returns('Map1'); @@ -1556,18 +1553,16 @@ public class SampleModel : Concept { it('should write a line for field name and type thats a map of ', () => { const mockField = sinon.createStubInstance(Field); - const getAllDeclarations = sinon.stub(); + const getType = sinon.stub(); mockField.dummy = 'Dummy Value'; - mockField.getModelFile.returns({ getAllDeclarations: getAllDeclarations }); + mockField.getModelFile.returns({ getType: getType }); let mockMapDeclaration = sinon.createStubInstance(MapDeclaration); - const findStub = sinon.stub(); const getKeyType = sinon.stub(); const getValueType = sinon.stub(); - getAllDeclarations.returns({ find: findStub }); - findStub.returns(mockMapDeclaration); + getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('DateTime'); mockField.getName.returns('Map1'); diff --git a/test/codegen/fromcto/data/model/hr.cto b/test/codegen/fromcto/data/model/hr.cto index 21c53218..cabf4d71 100644 --- a/test/codegen/fromcto/data/model/hr.cto +++ b/test/codegen/fromcto/data/model/hr.cto @@ -1,55 +1,33 @@ namespace org.acme.hr@1.0.0 -enum State { - o MA - o NY - o CO - o WA - o IL - o CA -} - -concept Address { - o String street - o String city - o State state optional - o String zipCode - o String country - o Map1 dictionary1 - o Map2 dictionary2 - o Map3 dictionary3 - o Map4 dictionary4 - o Map5 dictionary5 - o Map6 dictionary6 -} -scalar Time extends DateTime - -map Map1 { +import org.acme.hr.base@1.0.0.{Address, State, SSN, Time, EmployeeTShirtSizes} + +map CompanyProperties { o String o String } -map Map2 { +map EmployeeLoginTimes { o String - o DateTime + o Time } -map Map3 { +map EmployeeSocialSecurityNumbers { o String o SSN } -map Map4 { - o String - o Concept +map NextOfKin { + o KinName + o KinTelephone } -map Map5 { - o SSN +map EmployeeProfiles { o String + o Concept } -map Map6 { +map EmployeeDirectory { o SSN o Employee } @@ -57,6 +35,11 @@ map Map6 { concept Company { o String name o Address headquarters + o CompanyProperties companyProperties optional + o EmployeeDirectory employeeDirectory optional + o EmployeeTShirtSizes employeeTShirtSizes optional + o EmployeeProfiles employeeProfiles optional + o EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers optional } enum Department { @@ -82,8 +65,6 @@ asset Laptop extends Equipment { o LaptopMake make } -scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\{4}+/ - @resource abstract participant Person identified by email { o String email @@ -94,6 +75,7 @@ abstract participant Person identified by email { o SSN ssn o Double height o DateTime dob + o NextOfKin nextOfKin } participant Employee extends Person { @@ -107,9 +89,6 @@ participant Employee extends Person { --> Manager manager optional } - - - participant Contractor extends Person { o Company company --> Manager manager optional @@ -130,3 +109,6 @@ transaction ChangeOfAddress { --> Person Person o Address newAddress } + +scalar KinName extends String +scalar KinTelephone extends DateTime diff --git a/test/codegen/fromcto/data/model/hr_base.cto b/test/codegen/fromcto/data/model/hr_base.cto new file mode 100644 index 00000000..9a7fc935 --- /dev/null +++ b/test/codegen/fromcto/data/model/hr_base.cto @@ -0,0 +1,32 @@ +namespace org.acme.hr.base@1.0.0 + +enum State { + o MA + o NY + o CO + o WA + o IL + o CA +} + +enum TShirtSizeType { + o SMALL + o MEDIUM + o LARGE +} + +map EmployeeTShirtSizes { + o SSN + o TShirtSizeType +} + +concept Address { + o String street + o String city + o State state optional + o String zipCode + o String country +} + +scalar Time extends DateTime +scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\{4}+/ \ No newline at end of file diff --git a/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto b/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto index 42b43a87..7039a281 100644 --- a/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto +++ b/test/codegen/fromcto/protobuf/data/org.accordproject.protocol.v1_0_0-expected.proto @@ -45,7 +45,7 @@ message Code { message Function { Code code = 1; - string emittedTypes = 2; + repeated string emittedTypes = 2; string name = 3; string requestType = 4; string responseType = 5; diff --git a/test/common/graph.js b/test/common/graph.js index 08a9f112..65fd5742 100644 --- a/test/common/graph.js +++ b/test/common/graph.js @@ -35,8 +35,10 @@ describe('graph', function () { beforeEach(function() { modelManager = new ModelManager(); - const cto = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); - modelManager.addCTOModel(cto, 'hr.cto'); + const hrBase = fs.readFileSync('./test/codegen/fromcto/data/model/hr_base.cto', 'utf-8'); + modelManager.addCTOModel(hrBase, 'hr_base.cto'); + const hr = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); + modelManager.addCTOModel(hr, 'hr.cto'); }); @@ -53,38 +55,43 @@ describe('graph', function () { graph.print(writer); writer.closeFile(); expect(writer.data.get('graph.mmd')).toEqual(`flowchart LR - \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.State\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Time\` - \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Map1\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Map2\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` --> \`DateTime\` - \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Map3\` --> \`String\` - \`org.acme.hr@1.0.0.Map3\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Map4\` --> \`String\` - \`org.acme.hr@1.0.0.Map4\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Map5\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map5\` --> \`String\` - \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.Employee\` + \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.State\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.TShirtSizeType\` + \`org.acme.hr.base@1.0.0.TShirtSizeType\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` + \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` --> \`org.acme.hr.base@1.0.0.TShirtSizeType\` + \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr.base@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.Address\` --> \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.Time\` + \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.CompanyProperties\` + \`org.acme.hr@1.0.0.CompanyProperties\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeLoginTimes\` + \`org.acme.hr@1.0.0.EmployeeLoginTimes\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeLoginTimes\` --> \`org.acme.hr.base@1.0.0.Time\` + \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` + \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.NextOfKin\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinTelephone\` + \`org.acme.hr@1.0.0.EmployeeProfiles\` + \`org.acme.hr@1.0.0.EmployeeProfiles\` --> \`String\` + \`org.acme.hr@1.0.0.EmployeeProfiles\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr@1.0.0.EmployeeDirectory\` + \`org.acme.hr@1.0.0.EmployeeDirectory\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.EmployeeDirectory\` --> \`org.acme.hr@1.0.0.Employee\` \`org.acme.hr@1.0.0.Company\` \`org.acme.hr@1.0.0.Company\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.CompanyProperties\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.EmployeeDirectory\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr.base@1.0.0.EmployeeTShirtSizes\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.EmployeeProfiles\` + \`org.acme.hr@1.0.0.Company\` --> \`org.acme.hr@1.0.0.EmployeeSocialSecurityNumbers\` \`org.acme.hr@1.0.0.Department\` \`org.acme.hr@1.0.0.Department\` --> \`concerto@1.0.0.Concept\` \`org.acme.hr@1.0.0.Equipment\` @@ -94,15 +101,15 @@ describe('graph', function () { \`org.acme.hr@1.0.0.Laptop\` \`org.acme.hr@1.0.0.Laptop\` --> \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Laptop\` --> \`org.acme.hr@1.0.0.LaptopMake\` - \`org.acme.hr@1.0.0.SSN\` \`org.acme.hr@1.0.0.Person\` \`org.acme.hr@1.0.0.Person\` --> \`concerto@1.0.0.Participant\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.SSN\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.NextOfKin\` \`org.acme.hr@1.0.0.Employee\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Person\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Department\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr.base@1.0.0.Address\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Equipment\` \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Manager\` \`org.acme.hr@1.0.0.Contractor\` @@ -120,10 +127,13 @@ describe('graph', function () { \`org.acme.hr@1.0.0.ChangeOfAddress\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`concerto@1.0.0.Transaction\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Person\` - \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.KinTelephone\` `); }); + it('should visit find a connected subgraph', function () { const visitor = new ConcertoGraphVisitor(); visitor.should.not.be.null; @@ -138,63 +148,33 @@ describe('graph', function () { const filteredModelManager = modelManager .filter(declaration => connectedGraph.hasVertex(declaration.getFullyQualifiedName())); - expect(filteredModelManager.getModelFiles()).toHaveLength(1); - expect(filteredModelManager.getModelFiles()[0].getAllDeclarations()).toHaveLength(15); + expect(filteredModelManager.getModelFiles()).toHaveLength(2); + expect(filteredModelManager.getModelFiles()[0].getAllDeclarations()).toHaveLength(3); writer.openFile('graph.mmd'); connectedGraph.print(writer); writer.closeFile(); expect(writer.data.get('graph.mmd')).toEqual(`flowchart LR - \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.State\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.State\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Address\` --> \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Map1\` - \`org.acme.hr@1.0.0.Map1\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` - \`org.acme.hr@1.0.0.Map2\` --> \`String\` - \`org.acme.hr@1.0.0.Map2\` --> \`DateTime\` - \`org.acme.hr@1.0.0.Map3\` - \`org.acme.hr@1.0.0.Map3\` --> \`String\` - \`org.acme.hr@1.0.0.Map3\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map4\` - \`org.acme.hr@1.0.0.Map4\` --> \`String\` - \`org.acme.hr@1.0.0.Map4\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Map5\` - \`org.acme.hr@1.0.0.Map5\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map5\` --> \`String\` - \`org.acme.hr@1.0.0.Map6\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Map6\` --> \`org.acme.hr@1.0.0.Employee\` - \`org.acme.hr@1.0.0.Department\` - \`org.acme.hr@1.0.0.Department\` --> \`concerto@1.0.0.Concept\` - \`org.acme.hr@1.0.0.Equipment\` - \`org.acme.hr@1.0.0.Equipment\` --> \`concerto@1.0.0.Asset\` - \`org.acme.hr@1.0.0.SSN\` + \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.State\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr.base@1.0.0.Address\` --> \`concerto@1.0.0.Concept\` + \`org.acme.hr.base@1.0.0.Address\` --> \`org.acme.hr.base@1.0.0.State\` + \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.NextOfKin\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.NextOfKin\` --> \`org.acme.hr@1.0.0.KinTelephone\` \`org.acme.hr@1.0.0.Person\` \`org.acme.hr@1.0.0.Person\` --> \`concerto@1.0.0.Participant\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.SSN\` - \`org.acme.hr@1.0.0.Employee\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Person\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Department\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Address\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Equipment\` - \`org.acme.hr@1.0.0.Employee\` --> \`org.acme.hr@1.0.0.Manager\` - \`org.acme.hr@1.0.0.Manager\` - \`org.acme.hr@1.0.0.Manager\` --> \`org.acme.hr@1.0.0.Employee\` - \`org.acme.hr@1.0.0.Manager\` --> \`org.acme.hr@1.0.0.Person\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr.base@1.0.0.SSN\` + \`org.acme.hr@1.0.0.Person\` --> \`org.acme.hr@1.0.0.NextOfKin\` \`org.acme.hr@1.0.0.ChangeOfAddress\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`concerto@1.0.0.Transaction\` \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Person\` - \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Address\` + \`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr.base@1.0.0.Address\` + \`org.acme.hr@1.0.0.KinName\` + \`org.acme.hr@1.0.0.KinTelephone\` `); }); }); diff --git a/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts b/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts index b4aa57cc..6deecc6c 100644 --- a/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts +++ b/types/lib/codegen/fromcto/graphql/graphqlvisitor.d.ts @@ -66,6 +66,14 @@ declare class GraphQLVisitor { private visitEnumValueDeclaration; /** * Visitor design pattern + * @param {MapDeclaration} mapDeclaration - the object being visited + * @param {Object} parameters - the parameter + * @return {Object} the result of visiting or null + * @private + */ + private visitMapDeclaration; + /** + * Visitor design pattern * @param {Relationship} relationship - the object being visited * @param {Object} parameters - the parameter * @return {Object} the result of visiting or null From 4147fe1f11dd931e4ff629c35deddab92ddaccc4 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 10 Oct 2023 13:13:25 +0100 Subject: [PATCH 14/22] feat(map): update snapshot Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index ab79ff80..5a041b49 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1014,6 +1014,12 @@ public class Address extends Concept { private State state; private String zipCode; private String country; + private Map dictionary1 = new HashMap<>(); + private Map dictionary2 = new HashMap<>(); + private Map dictionary3 = new HashMap<>(); + private Map dictionary4 = new HashMap<>(); + private Map dictionary5 = new HashMap<>(); + private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } @@ -6562,6 +6568,12 @@ public class Address extends Concept { private State state; private String zipCode; private String country; + private Map dictionary1 = new HashMap<>(); + private Map dictionary2 = new HashMap<>(); + private Map dictionary3 = new HashMap<>(); + private Map dictionary4 = new HashMap<>(); + private Map dictionary5 = new HashMap<>(); + private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } From 541fb783ebdcd899ccfacf68bbca1d32322b9fed Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Sat, 21 Oct 2023 07:57:56 +0100 Subject: [PATCH 15/22] chore(deps): upgrade concerto Signed-off-by: Jonathan Casey --- package-lock.json | 52 +++++++++++++++++++++++++++++++---------------- package.json | 7 ++++--- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f18fcfa..8828e802 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "3.16.2", "license": "Apache-2.0", "dependencies": { - "@accordproject/concerto-core": "3.14.2", - "@accordproject/concerto-util": "3.14.2", - "@accordproject/concerto-vocabulary": "3.14.2", + "@accordproject/concerto-core": "3.14.0", + "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-vocabulary": "3.14.0", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", @@ -22,7 +22,7 @@ "pluralize": "8.0.0" }, "devDependencies": { - "@accordproject/concerto-cto": "3.14.2", + "@accordproject/concerto-cto": "3.14.0", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -60,13 +60,13 @@ } }, "node_modules/@accordproject/concerto-core": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.2.tgz", - "integrity": "sha512-pnmA8LgPw4lXs//JGlIGJc5zS5bY8B9AyAJTexfcJIrihMZccQVONJ4AQ3/8eL2vh0OgofC65XCx4qrJXXw0Bw==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.0.tgz", + "integrity": "sha512-JOLG9ISzlowDUsrD0Lbks0ft08JiQZV6oPbBai0tBOy5x+CPd4JLoGmjfy/x6+6HsFWdk1aXV2tQJww6Gw+3Tw==", "dependencies": { - "@accordproject/concerto-cto": "3.14.2", - "@accordproject/concerto-metamodel": "3.9.0", - "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-cto": "3.14.0", + "@accordproject/concerto-metamodel": "3.8.1", + "@accordproject/concerto-util": "3.14.0", "dayjs": "1.11.10", "debug": "4.3.4", "lorem-ipsum": "2.0.8", @@ -110,12 +110,12 @@ } }, "node_modules/@accordproject/concerto-cto": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.2.tgz", - "integrity": "sha512-+gCGQzNKO+kbMAEIsESyOHpcAivOLVUHZU3P34PKMan/stLExLJNIERVWS+BeGvpHu8iQzaA6RiJ6XkjQNhUuA==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.0.tgz", + "integrity": "sha512-6Uf0fe5BZpgiBUONNAGxOrDdXvDK+6qMuWdcqN+aPddtFPLZ/2ldFarQaSkXHq71+yrM7B/Dh7Y/0KSvs1Tteg==", "dependencies": { - "@accordproject/concerto-metamodel": "3.9.0", - "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-metamodel": "3.8.1", + "@accordproject/concerto-util": "3.14.0", "path-browserify": "1.0.1" }, "engines": { @@ -162,9 +162,9 @@ } }, "node_modules/@accordproject/concerto-util": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.2.tgz", - "integrity": "sha512-TagOBlneJlPXRKi75rWIshnqzQvsmWeXtFU7jwsvuFr2GeP+JeZwj4Clh4L3P8ah3Yu5mu5Z3n+w4M8KLbAxbg==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.0.tgz", + "integrity": "sha512-M32oVsJ9n4l/o10pz0e+AmGEpUmUQ4nwS2ixB4Jz2/kzRgVjeyHoolGKJCgDn6K8LjsGclSkMcmQ6IeF/7mC0g==", "dependencies": { "@supercharge/promise-pool": "1.7.0", "axios": "0.23.0", @@ -202,6 +202,22 @@ } } }, + "node_modules/@accordproject/concerto-vocabulary": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.0.tgz", + "integrity": "sha512-u0JABqvRjw9rE18+jmXlmFgw9xJprn4QT7jEZ+uFke2Gjr8LF2HwpNkzKFI/HQPLhIo/nGdBSm8ucXZ8a+axmw==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/@accordproject/concerto-vocabulary": { "version": "3.14.2", "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.2.tgz", diff --git a/package.json b/package.json index 72518b54..e126d387 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "author": "accordproject.org", "license": "Apache-2.0", "devDependencies": { + "@accordproject/concerto-cto": "3.14.0", "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", @@ -69,9 +70,9 @@ "webpack-cli": "4.9.1" }, "dependencies": { - "@accordproject/concerto-core": "3.14.2", - "@accordproject/concerto-util": "3.14.2", - "@accordproject/concerto-vocabulary": "3.14.2", + "@accordproject/concerto-core": "3.14.0", + "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-vocabulary": "3.14.0", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", From 5b2fca7dc96042e3643b796247f4f8f7e76532d8 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 3 Nov 2023 10:19:59 +0000 Subject: [PATCH 16/22] chore(deps): upgrade concerto Signed-off-by: Jonathan Casey --- package-lock.json | 52 ++++++++++++++++------------------------------- package.json | 8 ++++---- 2 files changed, 22 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8828e802..3f18fcfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "3.16.2", "license": "Apache-2.0", "dependencies": { - "@accordproject/concerto-core": "3.14.0", - "@accordproject/concerto-util": "3.14.0", - "@accordproject/concerto-vocabulary": "3.14.0", + "@accordproject/concerto-core": "3.14.2", + "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-vocabulary": "3.14.2", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", @@ -22,7 +22,7 @@ "pluralize": "8.0.0" }, "devDependencies": { - "@accordproject/concerto-cto": "3.14.0", + "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", "chai": "4.3.6", @@ -60,13 +60,13 @@ } }, "node_modules/@accordproject/concerto-core": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.0.tgz", - "integrity": "sha512-JOLG9ISzlowDUsrD0Lbks0ft08JiQZV6oPbBai0tBOy5x+CPd4JLoGmjfy/x6+6HsFWdk1aXV2tQJww6Gw+3Tw==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.14.2.tgz", + "integrity": "sha512-pnmA8LgPw4lXs//JGlIGJc5zS5bY8B9AyAJTexfcJIrihMZccQVONJ4AQ3/8eL2vh0OgofC65XCx4qrJXXw0Bw==", "dependencies": { - "@accordproject/concerto-cto": "3.14.0", - "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-cto": "3.14.2", + "@accordproject/concerto-metamodel": "3.9.0", + "@accordproject/concerto-util": "3.14.2", "dayjs": "1.11.10", "debug": "4.3.4", "lorem-ipsum": "2.0.8", @@ -110,12 +110,12 @@ } }, "node_modules/@accordproject/concerto-cto": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.0.tgz", - "integrity": "sha512-6Uf0fe5BZpgiBUONNAGxOrDdXvDK+6qMuWdcqN+aPddtFPLZ/2ldFarQaSkXHq71+yrM7B/Dh7Y/0KSvs1Tteg==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.14.2.tgz", + "integrity": "sha512-+gCGQzNKO+kbMAEIsESyOHpcAivOLVUHZU3P34PKMan/stLExLJNIERVWS+BeGvpHu8iQzaA6RiJ6XkjQNhUuA==", "dependencies": { - "@accordproject/concerto-metamodel": "3.8.1", - "@accordproject/concerto-util": "3.14.0", + "@accordproject/concerto-metamodel": "3.9.0", + "@accordproject/concerto-util": "3.14.2", "path-browserify": "1.0.1" }, "engines": { @@ -162,9 +162,9 @@ } }, "node_modules/@accordproject/concerto-util": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.0.tgz", - "integrity": "sha512-M32oVsJ9n4l/o10pz0e+AmGEpUmUQ4nwS2ixB4Jz2/kzRgVjeyHoolGKJCgDn6K8LjsGclSkMcmQ6IeF/7mC0g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.14.2.tgz", + "integrity": "sha512-TagOBlneJlPXRKi75rWIshnqzQvsmWeXtFU7jwsvuFr2GeP+JeZwj4Clh4L3P8ah3Yu5mu5Z3n+w4M8KLbAxbg==", "dependencies": { "@supercharge/promise-pool": "1.7.0", "axios": "0.23.0", @@ -202,22 +202,6 @@ } } }, - "node_modules/@accordproject/concerto-vocabulary": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.0.tgz", - "integrity": "sha512-u0JABqvRjw9rE18+jmXlmFgw9xJprn4QT7jEZ+uFke2Gjr8LF2HwpNkzKFI/HQPLhIo/nGdBSm8ucXZ8a+axmw==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/@accordproject/concerto-vocabulary": { "version": "3.14.2", "resolved": "https://registry.npmjs.org/@accordproject/concerto-vocabulary/-/concerto-vocabulary-3.14.2.tgz", diff --git a/package.json b/package.json index e126d387..f3b0aa56 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "author": "accordproject.org", "license": "Apache-2.0", "devDependencies": { - "@accordproject/concerto-cto": "3.14.0", + "@accordproject/concerto-cto": "3.14.2", "@accordproject/concerto-cto": "3.14.2", "@babel/preset-env": "7.16.11", "babel-loader": "8.2.3", @@ -70,9 +70,9 @@ "webpack-cli": "4.9.1" }, "dependencies": { - "@accordproject/concerto-core": "3.14.0", - "@accordproject/concerto-util": "3.14.0", - "@accordproject/concerto-vocabulary": "3.14.0", + "@accordproject/concerto-core": "3.14.2", + "@accordproject/concerto-util": "3.14.2", + "@accordproject/concerto-vocabulary": "3.14.2", "@openapi-contrib/openapi-schema-to-json-schema": "3.2.0", "ajv": "8.10.0", "ajv-formats": "2.1.1", From 5cf9d2188948a57412f4564a44dd0a9550c6210c Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 3 Nov 2023 10:20:16 +0000 Subject: [PATCH 17/22] test(*): snapshot update Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 516 ++++++++++----------- 1 file changed, 252 insertions(+), 264 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index 5a041b49..e392455c 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -6,7 +6,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -39,7 +39,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -69,7 +69,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -106,7 +106,7 @@ protocol MyProtocol { import idl "org.acme.hr.base.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -494,7 +494,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -522,7 +522,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -549,7 +549,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package org_acme_hr_base contains domain objects and was generated from Concerto namespace org.acme.hr.base. package org_acme_hr_base import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -585,7 +585,7 @@ package org_acme_hr import "time" import "org_acme_hr_base"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -870,7 +870,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -909,7 +909,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -1014,12 +1014,6 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map dictionary1 = new HashMap<>(); - private Map dictionary2 = new HashMap<>(); - private Map dictionary3 = new HashMap<>(); - private Map dictionary4 = new HashMap<>(); - private Map dictionary5 = new HashMap<>(); - private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } @@ -1077,11 +1071,11 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; - private CompanyProperties companyProperties; - private EmployeeDirectory employeeDirectory; - private EmployeeTShirtSizes employeeTShirtSizes; - private EmployeeProfiles employeeProfiles; - private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; + private Map companyProperties = new HashMap<>(); + private Map employeeDirectory = new HashMap<>(); + private Map employeeTShirtSizes = new HashMap<>(); + private Map employeeProfiles = new HashMap<>(); + private Map employeeSocialSecurityNumbers = new HashMap<>(); public String getName() { return this.name; } @@ -1170,7 +1164,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1225,7 +1219,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1264,7 +1258,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1278,7 +1272,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; - private NextOfKin nextOfKin; + private Map nextOfKin = new HashMap<>(); public String getEmail() { return this.email; } @@ -1359,7 +1353,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1447,7 +1441,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1493,7 +1487,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -3832,7 +3826,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -3862,7 +3856,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -3879,9 +3873,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3896,7 +3890,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3909,7 +3903,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3922,7 +3916,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3937,7 +3931,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3955,9 +3949,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3972,7 +3966,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3985,7 +3979,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4017,10 +4011,10 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr_base.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -4053,28 +4047,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -4090,52 +4084,52 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -4165,12 +4159,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4191,17 +4185,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4214,55 +4208,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4275,93 +4269,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4374,63 +4368,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4443,96 +4437,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4545,7 +4539,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4560,10 +4554,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4578,15 +4572,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4644,7 +4638,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -4822,7 +4816,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -4978,7 +4972,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto@1.0.0.xsd", "value": " - @@ -5034,7 +5028,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto.xsd", "value": " - @@ -5088,7 +5082,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.base.xsd", "value": " - @@ -5134,7 +5128,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.xsd", "value": " - @@ -5560,7 +5554,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -5593,7 +5587,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -5623,7 +5617,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -5660,7 +5654,7 @@ protocol MyProtocol { import idl "org.acme.hr.base@1.0.0.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -6048,7 +6042,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -6076,7 +6070,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -6103,7 +6097,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package org_acme_hr_base_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr.base@1.0.0. package org_acme_hr_base_1_0_0 import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -6139,7 +6133,7 @@ package org_acme_hr_1_0_0 import "time" import "org_acme_hr_base_1_0_0"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -6424,7 +6418,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6463,7 +6457,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6568,12 +6562,6 @@ public class Address extends Concept { private State state; private String zipCode; private String country; - private Map dictionary1 = new HashMap<>(); - private Map dictionary2 = new HashMap<>(); - private Map dictionary3 = new HashMap<>(); - private Map dictionary4 = new HashMap<>(); - private Map dictionary5 = new HashMap<>(); - private Map dictionary6 = new HashMap<>(); public String getStreet() { return this.street; } @@ -6631,11 +6619,11 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; - private CompanyProperties companyProperties; - private EmployeeDirectory employeeDirectory; - private EmployeeTShirtSizes employeeTShirtSizes; - private EmployeeProfiles employeeProfiles; - private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; + private Map companyProperties = new HashMap<>(); + private Map employeeDirectory = new HashMap<>(); + private Map employeeTShirtSizes = new HashMap<>(); + private Map employeeProfiles = new HashMap<>(); + private Map employeeSocialSecurityNumbers = new HashMap<>(); public String getName() { return this.name; } @@ -6724,7 +6712,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6779,7 +6767,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6818,7 +6806,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6832,7 +6820,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; - private NextOfKin nextOfKin; + private Map nextOfKin = new HashMap<>(); public String getEmail() { return this.email; } @@ -6913,7 +6901,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7001,7 +6989,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7047,7 +7035,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -9418,7 +9406,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -9448,7 +9436,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -9465,9 +9453,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9482,7 +9470,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9495,7 +9483,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9508,7 +9496,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9523,7 +9511,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9541,9 +9529,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9558,7 +9546,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9571,7 +9559,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9603,10 +9591,10 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_base_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -9639,28 +9627,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -9676,52 +9664,52 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base_1_0_0::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -9751,12 +9739,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9777,17 +9765,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9800,55 +9788,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -9861,93 +9849,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -9960,63 +9948,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10029,96 +10017,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10131,7 +10119,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10146,10 +10134,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10164,15 +10152,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10230,7 +10218,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -10408,7 +10396,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -10564,7 +10552,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto@1.0.0.xsd", "value": " - @@ -10620,7 +10608,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto.xsd", "value": " - @@ -10674,7 +10662,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr.base@1.0.0.xsd", "value": " - @@ -10720,7 +10708,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr@1.0.0.xsd", "value": " - From 5b97a34c00e502398337393ae47b8dc4a1658dd5 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 3 Nov 2023 10:43:45 +0000 Subject: [PATCH 18/22] test(*): snapshot update Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 504 ++++++++++----------- 1 file changed, 252 insertions(+), 252 deletions(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index ab79ff80..e392455c 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -6,7 +6,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -39,7 +39,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -69,7 +69,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -106,7 +106,7 @@ protocol MyProtocol { import idl "org.acme.hr.base.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -494,7 +494,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -522,7 +522,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -549,7 +549,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "value": "// Package org_acme_hr_base contains domain objects and was generated from Concerto namespace org.acme.hr.base. package org_acme_hr_base import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -585,7 +585,7 @@ package org_acme_hr import "time" import "org_acme_hr_base"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -870,7 +870,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -909,7 +909,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -1071,11 +1071,11 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; - private CompanyProperties companyProperties; - private EmployeeDirectory employeeDirectory; - private EmployeeTShirtSizes employeeTShirtSizes; - private EmployeeProfiles employeeProfiles; - private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; + private Map companyProperties = new HashMap<>(); + private Map employeeDirectory = new HashMap<>(); + private Map employeeTShirtSizes = new HashMap<>(); + private Map employeeProfiles = new HashMap<>(); + private Map employeeSocialSecurityNumbers = new HashMap<>(); public String getName() { return this.name; } @@ -1164,7 +1164,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1219,7 +1219,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -1258,7 +1258,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1272,7 +1272,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; - private NextOfKin nextOfKin; + private Map nextOfKin = new HashMap<>(); public String getEmail() { return this.email; } @@ -1353,7 +1353,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1441,7 +1441,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -1487,7 +1487,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -3826,7 +3826,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -3856,7 +3856,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -3873,9 +3873,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3890,7 +3890,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3903,7 +3903,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3916,7 +3916,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3931,7 +3931,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -3949,9 +3949,9 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -3966,7 +3966,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -3979,7 +3979,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -4011,10 +4011,10 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr_base.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -4047,28 +4047,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -4084,52 +4084,52 @@ exports[`codegen #formats check we can convert all formats from namespace unvers "key": "org_acme_hr.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -4159,12 +4159,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4185,17 +4185,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -4208,55 +4208,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4269,93 +4269,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4368,63 +4368,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4437,96 +4437,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -4539,7 +4539,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4554,10 +4554,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4572,15 +4572,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -4638,7 +4638,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -4816,7 +4816,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -4972,7 +4972,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto@1.0.0.xsd", "value": " - @@ -5028,7 +5028,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "concerto.xsd", "value": " - @@ -5082,7 +5082,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.base.xsd", "value": " - @@ -5128,7 +5128,7 @@ exports[`codegen #formats check we can convert all formats from namespace unvers { "key": "org.acme.hr.xsd", "value": " - @@ -5554,7 +5554,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto@1.0.0") protocol MyProtocol { - + record Concept { } @@ -5587,7 +5587,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "@namespace("concerto") protocol MyProtocol { - + record Concept { } @@ -5617,7 +5617,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio protocol MyProtocol { import idl "concerto@1.0.0.avdl"; - + enum State { MA, NY, @@ -5654,7 +5654,7 @@ protocol MyProtocol { import idl "org.acme.hr.base@1.0.0.avdl"; import idl "concerto@1.0.0.avdl"; - + record Company { string name; Address headquarters; @@ -6042,7 +6042,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package concerto_1_0_0 contains domain objects and was generated from Concerto namespace concerto@1.0.0. package concerto_1_0_0 import "time" - + type Concept struct { } type Asset struct { @@ -6070,7 +6070,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.go", "value": "// Package concerto contains domain objects and was generated from Concerto namespace concerto. package concerto - + type Concept struct { } type Asset struct { @@ -6097,7 +6097,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "value": "// Package org_acme_hr_base_1_0_0 contains domain objects and was generated from Concerto namespace org.acme.hr.base@1.0.0. package org_acme_hr_base_1_0_0 import "concerto_1_0_0"; - + type State int const ( MA State = 1 + iota @@ -6133,7 +6133,7 @@ package org_acme_hr_1_0_0 import "time" import "org_acme_hr_base_1_0_0"; import "concerto_1_0_0"; - + type Company struct { concerto_1_0_0.Concept Name string \`json:"name"\` @@ -6418,7 +6418,7 @@ public abstract class Asset extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6457,7 +6457,7 @@ public abstract class Participant extends Concept { public void set$id(String i) { $id = i; } - + // the accessor for the identifying field public String getID() { return this.get$identifier(); @@ -6619,11 +6619,11 @@ import com.fasterxml.jackson.annotation.*; public class Company extends Concept { private String name; private Address headquarters; - private CompanyProperties companyProperties; - private EmployeeDirectory employeeDirectory; - private EmployeeTShirtSizes employeeTShirtSizes; - private EmployeeProfiles employeeProfiles; - private EmployeeSocialSecurityNumbers employeeSocialSecurityNumbers; + private Map companyProperties = new HashMap<>(); + private Map employeeDirectory = new HashMap<>(); + private Map employeeTShirtSizes = new HashMap<>(); + private Map employeeProfiles = new HashMap<>(); + private Map employeeSocialSecurityNumbers = new HashMap<>(); public String getName() { return this.name; } @@ -6712,7 +6712,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public abstract class Equipment extends Asset { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6767,7 +6767,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "serialNumber") public class Laptop extends Equipment { - + // the accessor for the identifying field public String getID() { return this.getSerialNumber(); @@ -6806,7 +6806,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public abstract class Person extends Participant { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6820,7 +6820,7 @@ public abstract class Person extends Participant { private String ssn; private double height; private java.util.Date dob; - private NextOfKin nextOfKin; + private Map nextOfKin = new HashMap<>(); public String getEmail() { return this.email; } @@ -6901,7 +6901,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Employee extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -6989,7 +6989,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Contractor extends Person { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -7035,7 +7035,7 @@ import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "email") public class Manager extends Employee { - + // the accessor for the identifying field public String getID() { return this.getEmail(); @@ -9406,7 +9406,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "utils.rs", "value": "use chrono::{ DateTime, TimeZone, Utc }; use serde::{ Deserialize, Serialize, Deserializer, Serializer }; - + pub fn serialize_datetime_option(datetime: &Option>, serializer: S) -> Result where S: Serializer, @@ -9436,7 +9436,7 @@ where let datetime_str = String::deserialize(deserializer)?; Utc.datetime_from_str(&datetime_str, "%Y-%m-%dT%H:%M:%S%.3f%Z").map_err(serde::de::Error::custom) } - + pub fn serialize_datetime(datetime: &chrono::DateTime, serializer: S) -> Result where S: Serializer, @@ -9453,9 +9453,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9470,7 +9470,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9483,7 +9483,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9496,7 +9496,7 @@ pub struct Transaction { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9511,7 +9511,7 @@ pub struct Event { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -9529,9 +9529,9 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "concerto.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Concept { #[serde( @@ -9546,7 +9546,7 @@ pub struct Asset { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9559,7 +9559,7 @@ pub struct Participant { rename = "$class", )] pub _class: String, - + #[serde( rename = "$identifier", )] @@ -9591,10 +9591,10 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_base_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub enum State { #[allow(non_camel_case_types)] @@ -9627,28 +9627,28 @@ pub struct Address { rename = "$class", )] pub _class: String, - + #[serde( rename = "street", )] pub street: String, - + #[serde( rename = "city", )] pub city: String, - + #[serde( rename = "state", skip_serializing_if = "Option::is_none", )] pub state: Option, - + #[serde( rename = "zipCode", )] pub zip_code: String, - + #[serde( rename = "country", )] @@ -9664,52 +9664,52 @@ exports[`codegen #formats check we can convert all formats from namespace versio "key": "org_acme_hr_1_0_0.rs", "value": "use serde::{ Deserialize, Serialize }; use chrono::{ DateTime, TimeZone, Utc }; - + use crate::org_acme_hr_base_1_0_0::*; use crate::concerto_1_0_0::*; use crate::utils::*; - + #[derive(Debug, Serialize, Deserialize)] pub struct Company { #[serde( rename = "$class", )] pub _class: String, - + #[serde( rename = "name", )] pub name: String, - + #[serde( rename = "headquarters", )] pub headquarters: Address, - + #[serde( rename = "companyProperties", skip_serializing_if = "Option::is_none", )] pub company_properties: Option, - + #[serde( rename = "employeeDirectory", skip_serializing_if = "Option::is_none", )] pub employee_directory: Option, - + #[serde( rename = "employeeTShirtSizes", skip_serializing_if = "Option::is_none", )] pub employee_t_shirt_sizes: Option, - + #[serde( rename = "employeeProfiles", skip_serializing_if = "Option::is_none", )] pub employee_profiles: Option, - + #[serde( rename = "employeeSocialSecurityNumbers", skip_serializing_if = "Option::is_none", @@ -9739,12 +9739,12 @@ pub struct Equipment { rename = "$class", )] pub _class: String, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9765,17 +9765,17 @@ pub struct Laptop { rename = "$class", )] pub _class: String, - + #[serde( rename = "make", )] pub make: LaptopMake, - + #[serde( rename = "serialNumber", )] pub serial_number: String, - + #[serde( rename = "$identifier", )] @@ -9788,55 +9788,55 @@ pub struct Person { rename = "$class", )] pub _class: String, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -9849,93 +9849,93 @@ pub struct Employee { rename = "$class", )] pub _class: String, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -9948,63 +9948,63 @@ pub struct Contractor { rename = "$class", )] pub _class: String, - + #[serde( rename = "company", )] pub company: Company, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10017,96 +10017,96 @@ pub struct Manager { rename = "$class", )] pub _class: String, - + #[serde(rename = "reports")] pub reports: Option>, - + #[serde( rename = "employeeId", )] pub employee_id: String, - + #[serde( rename = "salary", )] pub salary: u64, - + #[serde( rename = "numDependents", )] pub num_dependents: Integer, - + #[serde( rename = "retired", )] pub retired: bool, - + #[serde( rename = "department", )] pub department: Department, - + #[serde( rename = "officeAddress", )] pub office_address: Address, - + #[serde( rename = "companyAssets", )] pub company_assets: Vec, - + #[serde(rename = "manager")] pub manager: Option, - + #[serde( rename = "email", )] pub email: String, - + #[serde( rename = "firstName", )] pub first_name: String, - + #[serde( rename = "lastName", )] pub last_name: String, - + #[serde( rename = "middleNames", skip_serializing_if = "Option::is_none", )] pub middle_names: Option, - + #[serde( rename = "homeAddress", )] pub home_address: Address, - + #[serde( rename = "ssn", )] pub ssn: String, - + #[serde( rename = "height", )] pub height: f64, - + #[serde( rename = "dob", serialize_with = "serialize_datetime", deserialize_with = "deserialize_datetime", )] pub dob: DateTime, - + #[serde( rename = "nextOfKin", )] pub next_of_kin: NextOfKin, - + #[serde( rename = "$identifier", )] @@ -10119,7 +10119,7 @@ pub struct CompanyEvent { rename = "$class", )] pub _class: String, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10134,10 +10134,10 @@ pub struct Onboarded { rename = "$class", )] pub _class: String, - + #[serde(rename = "employee")] pub employee: Employee, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10152,15 +10152,15 @@ pub struct ChangeOfAddress { rename = "$class", )] pub _class: String, - + #[serde(rename = "Person")] pub person: Person, - + #[serde( rename = "newAddress", )] pub new_address: Address, - + #[serde( rename = "$timestamp", serialize_with = "serialize_datetime", @@ -10218,7 +10218,7 @@ export interface IConcept { $class: string; } -export type ConceptUnion = IAddress | +export type ConceptUnion = IAddress | ICompany; export interface IAsset extends IConcept { @@ -10396,7 +10396,7 @@ export interface IPerson extends IParticipant { nextOfKin: NextOfKin; } -export type PersonUnion = IEmployee | +export type PersonUnion = IEmployee | IContractor; export interface IEmployee extends IPerson { @@ -10552,7 +10552,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto@1.0.0.xsd", "value": " - @@ -10608,7 +10608,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "concerto.xsd", "value": " - @@ -10662,7 +10662,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr.base@1.0.0.xsd", "value": " - @@ -10708,7 +10708,7 @@ exports[`codegen #formats check we can convert all formats from namespace versio { "key": "org.acme.hr@1.0.0.xsd", "value": " - From 1a55b9d987ba9147c44054bb0cf564fb42cb7909 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 3 Nov 2023 14:25:36 +0000 Subject: [PATCH 19/22] feat(map): write util import Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/java/javavisitor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index dc0c390e..bdeb4176 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -169,6 +169,15 @@ class JavaVisitor { parameters.fileWriter.writeLine(0, `import ${namespace}.${typeName};` ); }); + let hasImportedJavaMap = false; + classDeclaration.getOwnProperties().forEach(p => { + if(ModelUtil.isMap(p) && !hasImportedJavaMap) { + parameters.fileWriter.writeLine(0, 'import java.util.HashMap;'); + parameters.fileWriter.writeLine(0, 'import java.util.Map;'); + hasImportedJavaMap = true; + } + }); + parameters.fileWriter.writeLine(0, 'import com.fasterxml.jackson.annotation.*;'); parameters.fileWriter.writeLine(0, ''); From 0746a6608af7cd18d48a117d75eec14e79d1d7a1 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 3 Nov 2023 14:46:38 +0000 Subject: [PATCH 20/22] test(*): fix regressions Signed-off-by: Jonathan Casey --- test/codegen/__snapshots__/codegen.js.snap | 8 ++++++++ test/codegen/fromcto/java/javamissingplugin.js | 14 +++++++++++++- test/codegen/fromcto/java/javavisitor.js | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/codegen/__snapshots__/codegen.js.snap b/test/codegen/__snapshots__/codegen.js.snap index e392455c..c83d6015 100644 --- a/test/codegen/__snapshots__/codegen.js.snap +++ b/test/codegen/__snapshots__/codegen.js.snap @@ -1065,6 +1065,8 @@ import concerto.Asset; import concerto.Transaction; import concerto.Participant; import concerto.Event; +import java.util.HashMap; +import java.util.Map; import com.fasterxml.jackson.annotation.*; @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") @@ -1253,6 +1255,8 @@ import concerto.Asset; import concerto.Transaction; import concerto.Participant; import concerto.Event; +import java.util.HashMap; +import java.util.Map; import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) @@ -6613,6 +6617,8 @@ import concerto.Asset; import concerto.Transaction; import concerto.Participant; import concerto.Event; +import java.util.HashMap; +import java.util.Map; import com.fasterxml.jackson.annotation.*; @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "$class") @@ -6801,6 +6807,8 @@ import concerto.Asset; import concerto.Transaction; import concerto.Participant; import concerto.Event; +import java.util.HashMap; +import java.util.Map; import com.fasterxml.jackson.annotation.*; @JsonIgnoreProperties({"id"}) diff --git a/test/codegen/fromcto/java/javamissingplugin.js b/test/codegen/fromcto/java/javamissingplugin.js index 7fed131c..8d6f3e34 100644 --- a/test/codegen/fromcto/java/javamissingplugin.js +++ b/test/codegen/fromcto/java/javamissingplugin.js @@ -20,11 +20,14 @@ const sinon = require('sinon'); const JavaVisitor = require('../../../../lib/codegen/fromcto/java/javavisitor.js'); const AbstractPlugin = require('../../../../lib/codegen/abstractplugin.js'); +const ModelUtil = require('@accordproject/concerto-core').ModelUtil; const ClassDeclaration = require('@accordproject/concerto-core').ClassDeclaration; const EnumDeclaration = require('@accordproject/concerto-core').EnumDeclaration; const FileWriter = require('@accordproject/concerto-util').FileWriter; +let sandbox = sinon.createSandbox(); + describe('JavaMissingPlugin', function () { let javaVisit; let mockFileWriter; @@ -115,6 +118,15 @@ describe('JavaMissingPlugin', function () { sinon.stub(javaVisit, 'startClassFile'); sinon.stub(javaVisit, 'endClassFile'); + + sandbox.stub(ModelUtil, 'isMap').callsFake(() => { + return true; + }); + }); + + afterEach(() => { + sandbox.restore(); + }); it('should fail to write a class declaration and call accept on each property', () => { @@ -126,4 +138,4 @@ describe('JavaMissingPlugin', function () { }); }); -}); \ No newline at end of file +}); diff --git a/test/codegen/fromcto/java/javavisitor.js b/test/codegen/fromcto/java/javavisitor.js index e063c489..7dff420d 100644 --- a/test/codegen/fromcto/java/javavisitor.js +++ b/test/codegen/fromcto/java/javavisitor.js @@ -39,6 +39,13 @@ describe('JavaVisitor', function () { beforeEach(() => { javaVisit = new JavaVisitor(); mockFileWriter = sinon.createStubInstance(FileWriter); + sandbox.stub(ModelUtil, 'isMap').callsFake(() => { + return false; + }); + }); + + afterEach(() => { + sandbox.restore(); }); describe('visit', () => { From 60415e5f8a564c747ea935494adff4af8a2b061d Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 3 Nov 2023 15:42:38 +0000 Subject: [PATCH 21/22] test(*): add test coverage for map imports Signed-off-by: Jonathan Casey --- test/codegen/fromcto/java/javavisitor.js | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/codegen/fromcto/java/javavisitor.js b/test/codegen/fromcto/java/javavisitor.js index 7dff420d..7ed6f004 100644 --- a/test/codegen/fromcto/java/javavisitor.js +++ b/test/codegen/fromcto/java/javavisitor.js @@ -387,6 +387,36 @@ describe('JavaVisitor', function () { acceptSpy.withArgs(javaVisit, Object.assign({},param,{mode:'setter'})).calledTwice.should.be.ok; mockEndClassFile.withArgs(mockClassDeclaration, param).calledOnce.should.be.ok; }); + + it('should write a class declaration, including imports for java.util Map & HashMap types', () => { + mockClassDeclaration.getIdentifierFieldName.returns('employeeID'); + sandbox.restore(); + sandbox.stub(ModelUtil, 'isMap').callsFake(() => { + return true; + }); + javaVisit.visitClassDeclaration(mockClassDeclaration, param); + + mockStartClassFile.withArgs(mockClassDeclaration, param).calledOnce.should.be.ok; + param.fileWriter.writeLine.callCount.should.deep.equal(9); + param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, 'import fruit.oranges;']); + param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, 'import fruit.apples;']); + param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'import java.util.HashMap;']); + param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, 'import java.util.Map;']); + param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, 'import com.fasterxml.jackson.annotation.*;']); + param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '']); + param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, 'public class Bob {']); + param.fileWriter.writeLine.getCall(7).args.should.deep.equal([1, ` + // the accessor for the identifying field + public String getID() { + return this.getEmployeeID(); + } +`]); + param.fileWriter.writeLine.getCall(8).args.should.deep.equal([0, '}']); + acceptSpy.withArgs(javaVisit, Object.assign({},param,{mode:'field'})).calledTwice.should.be.ok; + acceptSpy.withArgs(javaVisit, Object.assign({},param,{mode:'getter'})).calledTwice.should.be.ok; + acceptSpy.withArgs(javaVisit, Object.assign({},param,{mode:'setter'})).calledTwice.should.be.ok; + mockEndClassFile.withArgs(mockClassDeclaration, param).calledOnce.should.be.ok; + }); }); describe('visitField', () => { From 64b1f1f622ad8f04bbdf998e96265fc0f16e7900 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Mon, 6 Nov 2023 11:10:28 +0000 Subject: [PATCH 22/22] test(*): uses isMap util fun Signed-off-by: Jonathan Casey --- lib/codegen/fromcto/java/javavisitor.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index bdeb4176..08160891 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -287,7 +287,7 @@ class JavaVisitor { parameters.fileWriter.writeLine(1, '}'); break; default: - if (this.isMap(field)) { + if (ModelUtil.isMap(field)) { const decl = field.getModelFile().getType(field.ast.type.name); parameters.fileWriter.writeLine(1, `private Map<${this.toJavaType(decl.getKey().getType())}, ${this.toJavaType(decl.getValue().getType())}> ${field.getName()} = new HashMap<>();`); } else { @@ -388,16 +388,6 @@ class JavaVisitor { capitalizeFirstLetter(s) { return s.charAt(0).toUpperCase() + s.slice(1); } - - /** - * Check if field is a Map Declaration - * @param {Field} field - the field being visited - * @return {boolean} true if field is a Map Declaration - * @private - */ - isMap(field) { - return (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)); - } } module.exports = JavaVisitor;