From d12bcaa5c61818f8a77e21fce26e1c3a3de3e8fc Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 26 Sep 2023 15:47:33 +0100 Subject: [PATCH 01/11] feat(map): resolves namespace for Map Type Signed-off-by: Jonathan Casey --- lib/metamodelutil.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/metamodelutil.js b/lib/metamodelutil.js index 6bcdfe7..939e5e6 100644 --- a/lib/metamodelutil.js +++ b/lib/metamodelutil.js @@ -29,6 +29,7 @@ const MetaModelNamespace = 'concerto.metamodel@1.0.0'; * The metamodel itself, as a CTO string */ const metaModelCto = require('./metamodel.js'); +const ModelUtil = require('@accordproject/concerto-core').ModelUtil; /** * Find the model for a given namespace @@ -64,6 +65,14 @@ function createNameTable(priorModels, metaModel) { 'Participant': concertoNs, 'Transaction ': concertoNs, 'Event': concertoNs, + 'StringMapKeyType': concertoNs, + 'DateTimeMapKeyType': concertoNs, + 'BooleanMapValueType': concertoNs, + 'DateTimeMapValueType': concertoNs, + 'StringMapValueType': concertoNs, + 'IntegerMapValueType': concertoNs, + 'LongMapValueType': concertoNs, + 'DoubleMapValueType': concertoNs, }; // First list the imported names in order (overriding as we go along) @@ -147,6 +156,13 @@ function resolveTypeNames(metaModel, table) { }); } break; + case `${MetaModelNamespace}.MapDeclaration`: { + const nameK = metaModel.key.$class === `${MetaModelNamespace}.ObjectMapKeyType` ? metaModel.key.type.name : ModelUtil.getShortName(metaModel.key.$class); + metaModel.key.$class === `${MetaModelNamespace}.ObjectMapKeyType` ? metaModel.key.type.namespace = resolveName(nameK, table) : metaModel.key.namespace = resolveName(nameK, table); + const nameV = metaModel.value.$class === `${MetaModelNamespace}.ObjectMapValueType` ? metaModel.value.type.name : ModelUtil.getShortName(metaModel.value.$class); + metaModel.key.$class === `${MetaModelNamespace}.ObjectMapKeyType` ? metaModel.value.type.namespace = resolveName(nameV, table) : metaModel.value.namespace = resolveName(nameV, table); + } + break; case `${MetaModelNamespace}.EnumProperty`: case `${MetaModelNamespace}.ObjectProperty`: case `${MetaModelNamespace}.RelationshipProperty`: { From af9dcc410cf57a3a8e6144cff0b3e0b0b37a4c0c Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 26 Sep 2023 15:48:45 +0100 Subject: [PATCH 02/11] chore(dep): add concerto-core dep Signed-off-by: Jonathan Casey --- package-lock.json | 237 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 1 + 2 files changed, 223 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6d4b4eb..21f66b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "3.8.1", "license": "Apache-2.0", "dependencies": { + "@accordproject/concerto-core": "3.9.1", "@accordproject/concerto-util": "3.9.1" }, "devDependencies": { @@ -31,6 +32,71 @@ "npm": ">=6" } }, + "node_modules/@accordproject/concerto-core": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.9.1.tgz", + "integrity": "sha512-+0ao/fvilYyWQbdnRvu1kT3t0rKa5CLyeay65LKMLu9oR2akuHAp28BaujcUQQscAWLHJE+1ks7BoODJop7kzw==", + "dependencies": { + "@accordproject/concerto-cto": "3.9.1", + "@accordproject/concerto-metamodel": "3.8.0", + "@accordproject/concerto-util": "3.9.1", + "dayjs": "1.10.8", + "debug": "4.3.1", + "lorem-ipsum": "2.0.3", + "randexp": "0.5.3", + "semver": "7.5.4", + "slash": "3.0.0", + "urijs": "1.19.11", + "uuid": "8.3.2" + }, + "engines": { + "node": ">=16", + "npm": ">=8" + } + }, + "node_modules/@accordproject/concerto-cto": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.9.1.tgz", + "integrity": "sha512-YGy9NhypzcUOPcnP+lBoibyw85jKX5PcwSCMp0plvfPoZnO2ShvZ9LX6eGPccZX8wBDuY5GbfVTm0TUiz7c5Uw==", + "dependencies": { + "@accordproject/concerto-metamodel": "3.8.0", + "@accordproject/concerto-util": "3.9.1", + "path-browserify": "1.0.1" + }, + "engines": { + "node": ">=16", + "npm": ">=8" + } + }, + "node_modules/@accordproject/concerto-metamodel": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.8.0.tgz", + "integrity": "sha512-oqJP+6xKlnvR4SrDU3U+iMhFeErdn9uKRdMqlOj6lW5Geyi4DTTURkf1Vf+x8LeI6CwuOErSNNxVVKFd3LoVjQ==", + "dependencies": { + "@accordproject/concerto-util": "3.7.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6" + } + }, + "node_modules/@accordproject/concerto-metamodel/node_modules/@accordproject/concerto-util": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.7.0.tgz", + "integrity": "sha512-3qGVb/pv12hy5g44JvSH4ZZtFQ/9KNd9lWvVdh7AGfgtUdhPwlAssZTrmfY96uNP0eVE786HedC1DH6YstNK8g==", + "dependencies": { + "@supercharge/promise-pool": "1.7.0", + "axios": "0.23.0", + "colors": "1.4.0", + "debug": "4.3.1", + "json-colorizer": "2.2.2", + "slash": "3.0.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6" + } + }, "node_modules/@accordproject/concerto-util": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.9.1.tgz", @@ -1194,6 +1260,11 @@ "node": ">=0.1.90" } }, + "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==" + }, "node_modules/commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -1229,8 +1300,7 @@ "node_modules/dayjs": { "version": "1.10.8", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.8.tgz", - "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==", - "dev": true + "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==" }, "node_modules/debug": { "version": "4.3.1", @@ -1311,6 +1381,14 @@ "node": ">=6.0.0" } }, + "node_modules/drange": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/drange/-/drange-1.1.1.tgz", + "integrity": "sha512-pYxfDYpued//QpnLIm4Avk7rsNtAtQkUES2cwAYSvD/wd2pKD71gN2Ebj3e7klzXwjocvE8c5vx/1fxwpqmSxA==", + "engines": { + "node": ">=4" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.286", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.286.tgz", @@ -2482,6 +2560,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "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==", + "dependencies": { + "commander": "^2.17.1" + }, + "bin": { + "lorem-ipsum": "dist/bin/lorem-ipsum.bin.js" + }, + "engines": { + "node": ">= 8.x", + "npm": ">= 5.x" + } + }, "node_modules/loupe": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", @@ -3081,6 +3174,11 @@ "node": ">=0.10.0" } }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -3317,6 +3415,18 @@ "node": ">=6" } }, + "node_modules/randexp": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", + "integrity": "sha512-U+5l2KrcMNOUPYvazA3h5ekF80FHTUG+87SEAmHZmolh1M+i/WyTCxVzmi+tidIa1tM4BSe8g2Y/D3loWDjj+w==", + "dependencies": { + "drange": "^1.0.2", + "ret": "^0.2.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -3395,6 +3505,14 @@ "node": ">=4" } }, + "node_modules/ret": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", + "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -3434,7 +3552,6 @@ "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, "dependencies": { "lru-cache": "^6.0.0" }, @@ -3449,7 +3566,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "dependencies": { "yallist": "^4.0.0" }, @@ -3460,8 +3576,7 @@ "node_modules/semver/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/serialize-javascript": { "version": "6.0.0", @@ -3781,11 +3896,15 @@ "punycode": "^2.1.0" } }, + "node_modules/urijs": { + "version": "1.19.11", + "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.11.tgz", + "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==" + }, "node_modules/uuid": { "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" } @@ -3968,6 +4087,57 @@ } }, "dependencies": { + "@accordproject/concerto-core": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.9.1.tgz", + "integrity": "sha512-+0ao/fvilYyWQbdnRvu1kT3t0rKa5CLyeay65LKMLu9oR2akuHAp28BaujcUQQscAWLHJE+1ks7BoODJop7kzw==", + "requires": { + "@accordproject/concerto-cto": "3.9.1", + "@accordproject/concerto-metamodel": "3.8.0", + "@accordproject/concerto-util": "3.9.1", + "dayjs": "1.10.8", + "debug": "4.3.1", + "lorem-ipsum": "2.0.3", + "randexp": "0.5.3", + "semver": "7.5.4", + "slash": "3.0.0", + "urijs": "1.19.11", + "uuid": "8.3.2" + } + }, + "@accordproject/concerto-cto": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.9.1.tgz", + "integrity": "sha512-YGy9NhypzcUOPcnP+lBoibyw85jKX5PcwSCMp0plvfPoZnO2ShvZ9LX6eGPccZX8wBDuY5GbfVTm0TUiz7c5Uw==", + "requires": { + "@accordproject/concerto-metamodel": "3.8.0", + "@accordproject/concerto-util": "3.9.1", + "path-browserify": "1.0.1" + } + }, + "@accordproject/concerto-metamodel": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.8.0.tgz", + "integrity": "sha512-oqJP+6xKlnvR4SrDU3U+iMhFeErdn9uKRdMqlOj6lW5Geyi4DTTURkf1Vf+x8LeI6CwuOErSNNxVVKFd3LoVjQ==", + "requires": { + "@accordproject/concerto-util": "3.7.0" + }, + "dependencies": { + "@accordproject/concerto-util": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.7.0.tgz", + "integrity": "sha512-3qGVb/pv12hy5g44JvSH4ZZtFQ/9KNd9lWvVdh7AGfgtUdhPwlAssZTrmfY96uNP0eVE786HedC1DH6YstNK8g==", + "requires": { + "@supercharge/promise-pool": "1.7.0", + "axios": "0.23.0", + "colors": "1.4.0", + "debug": "4.3.1", + "json-colorizer": "2.2.2", + "slash": "3.0.0" + } + } + } + }, "@accordproject/concerto-util": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.9.1.tgz", @@ -4856,6 +5026,11 @@ "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" }, + "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==" + }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -4888,8 +5063,7 @@ "dayjs": { "version": "1.10.8", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.8.tgz", - "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==", - "dev": true + "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==" }, "debug": { "version": "4.3.1", @@ -4944,6 +5118,11 @@ "esutils": "^2.0.2" } }, + "drange": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/drange/-/drange-1.1.1.tgz", + "integrity": "sha512-pYxfDYpued//QpnLIm4Avk7rsNtAtQkUES2cwAYSvD/wd2pKD71gN2Ebj3e7klzXwjocvE8c5vx/1fxwpqmSxA==" + }, "electron-to-chromium": { "version": "1.4.286", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.286.tgz", @@ -5815,6 +5994,14 @@ "is-unicode-supported": "^0.1.0" } }, + "lorem-ipsum": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/lorem-ipsum/-/lorem-ipsum-2.0.3.tgz", + "integrity": "sha512-CX2r84DMWjW/DWiuzicTI9aRaJPAw2cvAGMJYZh/nx12OkTGqloj8y8FU0S8ZkKwOdqhfxEA6Ly8CW2P6Yxjwg==", + "requires": { + "commander": "^2.17.1" + } + }, "loupe": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", @@ -6285,6 +6472,11 @@ "error-ex": "^1.2.0" } }, + "path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" + }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -6459,6 +6651,15 @@ "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", "dev": true }, + "randexp": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", + "integrity": "sha512-U+5l2KrcMNOUPYvazA3h5ekF80FHTUG+87SEAmHZmolh1M+i/WyTCxVzmi+tidIa1tM4BSe8g2Y/D3loWDjj+w==", + "requires": { + "drange": "^1.0.2", + "ret": "^0.2.0" + } + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -6519,6 +6720,11 @@ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, + "ret": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", + "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==" + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -6538,7 +6744,6 @@ "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, "requires": { "lru-cache": "^6.0.0" }, @@ -6547,7 +6752,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "requires": { "yallist": "^4.0.0" } @@ -6555,8 +6759,7 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } }, @@ -6794,11 +6997,15 @@ "punycode": "^2.1.0" } }, + "urijs": { + "version": "1.19.11", + "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.11.tgz", + "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==" + }, "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" }, "v8-compile-cache": { "version": "2.3.0", diff --git a/package.json b/package.json index 265061c..db82211 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "typescript": "4.6.3" }, "dependencies": { + "@accordproject/concerto-core": "3.9.1", "@accordproject/concerto-util": "3.9.1" }, "browserslist": "> 0.25%, not dead", From 595838c15572d14c4c90547c0012bdb6bb2c07de Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 26 Sep 2023 15:49:06 +0100 Subject: [PATCH 03/11] feat(map): extend test coverage Signed-off-by: Jonathan Casey --- test/cto/car.json | 186 ++++++++++++++++++++++++++++++++++++- test/cto/carResolved.json | 190 +++++++++++++++++++++++++++++++++++++- 2 files changed, 374 insertions(+), 2 deletions(-) diff --git a/test/cto/car.json b/test/cto/car.json index c5c4a85..84f17be 100644 --- a/test/cto/car.json +++ b/test/cto/car.json @@ -1 +1,185 @@ -{"$class":"concerto.metamodel@1.0.0.Models","models":[{"$class":"concerto.metamodel@1.0.0.Model","decorators":[],"namespace":"org.vehicle","imports":[],"declarations":[{"$class":"concerto.metamodel@1.0.0.ConceptDeclaration","name":"Manufactured","isAbstract":true,"properties":[],"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":23,"line":3,"column":1,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":56,"line":4,"column":2,"$class":"concerto.metamodel@1.0.0.Position"}}},{"$class":"concerto.metamodel@1.0.0.ConceptDeclaration","name":"Vehicle","isAbstract":true,"properties":[{"$class":"concerto.metamodel@1.0.0.StringProperty","name":"name","isArray":false,"isOptional":false,"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":108,"line":7,"column":3,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":124,"line":8,"column":3,"$class":"concerto.metamodel@1.0.0.Position"}}},{"$class":"concerto.metamodel@1.0.0.DoubleProperty","name":"range","isArray":false,"isOptional":false,"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":124,"line":8,"column":3,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":139,"line":9,"column":1,"$class":"concerto.metamodel@1.0.0.Position"}}}],"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":58,"line":6,"column":1,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":140,"line":9,"column":2,"$class":"concerto.metamodel@1.0.0.Position"}},"superType":{"$class":"concerto.metamodel@1.0.0.TypeIdentifier","name":"Manufactured"}}]},{"$class":"concerto.metamodel@1.0.0.Model","decorators":[],"namespace":"org.car","imports":[{"$class":"concerto.metamodel@1.0.0.ImportAll","namespace":"org.vehicle"}],"declarations":[{"$class":"concerto.metamodel@1.0.0.ConceptDeclaration","name":"Car","isAbstract":false,"properties":[{"$class":"concerto.metamodel@1.0.0.DoubleProperty","name":"mileage","isArray":false,"isOptional":false,"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":73,"line":6,"column":3,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":90,"line":7,"column":1,"$class":"concerto.metamodel@1.0.0.Position"}}}],"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":41,"line":5,"column":1,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":91,"line":7,"column":2,"$class":"concerto.metamodel@1.0.0.Position"}},"superType":{"$class":"concerto.metamodel@1.0.0.TypeIdentifier","name":"Vehicle"}}]}]} +{ + "$class": "concerto.metamodel@1.0.0.Models", + "models": [ + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "org.vehicle", + "imports": [], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.ConceptDeclaration", + "name": "Manufactured", + "isAbstract": true, + "properties": [], + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 23, + "line": 3, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 56, + "line": 4, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.ConceptDeclaration", + "name": "Vehicle", + "isAbstract": true, + "properties": [ + { + "$class": "concerto.metamodel@1.0.0.StringProperty", + "name": "name", + "isArray": false, + "isOptional": false, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 108, + "line": 7, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 124, + "line": 8, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.DoubleProperty", + "name": "range", + "isArray": false, + "isOptional": false, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 124, + "line": 8, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 139, + "line": 9, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ], + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 58, + "line": 6, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 140, + "line": 9, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "superType": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Manufactured" + } + } + ] + }, + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "org.car", + "imports": [ + { + "$class": "concerto.metamodel@1.0.0.ImportAll", + "namespace": "org.vehicle" + } + ], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.DateTimeScalar", + "defaultValue": null, + "name": "DateServiced" + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "ServicedPart", + "key": { + "$class": "concerto.metamodel@1.0.0.ObjectMapKeyType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "DateServiced" + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Concept" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.ConceptDeclaration", + "name": "Car", + "isAbstract": false, + "properties": [ + { + "$class": "concerto.metamodel@1.0.0.DoubleProperty", + "name": "mileage", + "isArray": false, + "isOptional": false, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 73, + "line": 6, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 90, + "line": 7, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ], + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 41, + "line": 5, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 91, + "line": 7, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "superType": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Vehicle" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/test/cto/carResolved.json b/test/cto/carResolved.json index 6679735..41c8ded 100644 --- a/test/cto/carResolved.json +++ b/test/cto/carResolved.json @@ -1 +1,189 @@ -{"$class":"concerto.metamodel@1.0.0.Models","models":[{"$class":"concerto.metamodel@1.0.0.Model","decorators":[],"namespace":"org.vehicle","imports":[],"declarations":[{"$class":"concerto.metamodel@1.0.0.ConceptDeclaration","name":"Manufactured","isAbstract":true,"properties":[],"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":23,"line":3,"column":1,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":56,"line":4,"column":2,"$class":"concerto.metamodel@1.0.0.Position"}}},{"$class":"concerto.metamodel@1.0.0.ConceptDeclaration","name":"Vehicle","isAbstract":true,"properties":[{"$class":"concerto.metamodel@1.0.0.StringProperty","name":"name","isArray":false,"isOptional":false,"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":108,"line":7,"column":3,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":124,"line":8,"column":3,"$class":"concerto.metamodel@1.0.0.Position"}}},{"$class":"concerto.metamodel@1.0.0.DoubleProperty","name":"range","isArray":false,"isOptional":false,"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":124,"line":8,"column":3,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":139,"line":9,"column":1,"$class":"concerto.metamodel@1.0.0.Position"}}}],"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":58,"line":6,"column":1,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":140,"line":9,"column":2,"$class":"concerto.metamodel@1.0.0.Position"}},"superType":{"$class":"concerto.metamodel@1.0.0.TypeIdentifier","name":"Manufactured","namespace":"org.vehicle"}}]},{"$class":"concerto.metamodel@1.0.0.Model","decorators":[],"namespace":"org.car","imports":[{"$class":"concerto.metamodel@1.0.0.ImportAll","namespace":"org.vehicle"}],"declarations":[{"$class":"concerto.metamodel@1.0.0.ConceptDeclaration","name":"Car","isAbstract":false,"properties":[{"$class":"concerto.metamodel@1.0.0.DoubleProperty","name":"mileage","isArray":false,"isOptional":false,"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":73,"line":6,"column":3,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":90,"line":7,"column":1,"$class":"concerto.metamodel@1.0.0.Position"}}}],"location":{"$class":"concerto.metamodel@1.0.0.Range","start":{"offset":41,"line":5,"column":1,"$class":"concerto.metamodel@1.0.0.Position"},"end":{"offset":91,"line":7,"column":2,"$class":"concerto.metamodel@1.0.0.Position"}},"superType":{"$class":"concerto.metamodel@1.0.0.TypeIdentifier","name":"Vehicle","namespace":"org.vehicle"}}]}]} +{ + "$class": "concerto.metamodel@1.0.0.Models", + "models": [ + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "org.vehicle", + "imports": [], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.ConceptDeclaration", + "name": "Manufactured", + "isAbstract": true, + "properties": [], + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 23, + "line": 3, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 56, + "line": 4, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.ConceptDeclaration", + "name": "Vehicle", + "isAbstract": true, + "properties": [ + { + "$class": "concerto.metamodel@1.0.0.StringProperty", + "name": "name", + "isArray": false, + "isOptional": false, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 108, + "line": 7, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 124, + "line": 8, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.DoubleProperty", + "name": "range", + "isArray": false, + "isOptional": false, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 124, + "line": 8, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 139, + "line": 9, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ], + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 58, + "line": 6, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 140, + "line": 9, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "superType": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Manufactured", + "namespace": "org.vehicle" + } + } + ] + }, + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "org.car", + "imports": [ + { + "$class": "concerto.metamodel@1.0.0.ImportAll", + "namespace": "org.vehicle" + } + ], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.DateTimeScalar", + "defaultValue": null, + "name": "DateServiced" + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "ServicedPart", + "key": { + "$class": "concerto.metamodel@1.0.0.ObjectMapKeyType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "DateServiced", + "namespace": "org.car" + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Concept", + "namespace": "concerto@1.0.0" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.ConceptDeclaration", + "name": "Car", + "isAbstract": false, + "properties": [ + { + "$class": "concerto.metamodel@1.0.0.DoubleProperty", + "name": "mileage", + "isArray": false, + "isOptional": false, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 73, + "line": 6, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 90, + "line": 7, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ], + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 41, + "line": 5, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 91, + "line": 7, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "superType": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Vehicle", + "namespace": "org.vehicle" + } + } + ] + } + ] +} \ No newline at end of file From f877b877b74772d79d3f371c0d1d4bb93f135f67 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Tue, 26 Sep 2023 16:15:25 +0100 Subject: [PATCH 04/11] chore(dep): add node types Signed-off-by: Jonathan Casey --- package-lock.json | 13 ++++++++++++- package.json | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21f66b2..fec578e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "Apache-2.0", "dependencies": { "@accordproject/concerto-core": "3.9.1", - "@accordproject/concerto-util": "3.9.1" + "@accordproject/concerto-util": "3.9.1", + "@types/node": "20.7.0" }, "devDependencies": { "chai": "4.3.6", @@ -829,6 +830,11 @@ "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", "dev": true }, + "node_modules/@types/node": { + "version": "20.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.0.tgz", + "integrity": "sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==" + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -4715,6 +4721,11 @@ "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", "dev": true }, + "@types/node": { + "version": "20.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.0.tgz", + "integrity": "sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==" + }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", diff --git a/package.json b/package.json index db82211..74b0401 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,8 @@ }, "dependencies": { "@accordproject/concerto-core": "3.9.1", - "@accordproject/concerto-util": "3.9.1" + "@accordproject/concerto-util": "3.9.1", + "@types/node": "20.7.0" }, "browserslist": "> 0.25%, not dead", "license-check-and-add-config": { From 754e9bda4cf4da7685193b6de7649988bc7b3e1d Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 11:39:00 +0100 Subject: [PATCH 05/11] feat(map): define ns recursively Signed-off-by: Jonathan Casey --- lib/metamodelutil.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/metamodelutil.js b/lib/metamodelutil.js index 939e5e6..e47ba95 100644 --- a/lib/metamodelutil.js +++ b/lib/metamodelutil.js @@ -29,7 +29,6 @@ const MetaModelNamespace = 'concerto.metamodel@1.0.0'; * The metamodel itself, as a CTO string */ const metaModelCto = require('./metamodel.js'); -const ModelUtil = require('@accordproject/concerto-core').ModelUtil; /** * Find the model for a given namespace @@ -64,15 +63,7 @@ function createNameTable(priorModels, metaModel) { 'Asset': concertoNs, 'Participant': concertoNs, 'Transaction ': concertoNs, - 'Event': concertoNs, - 'StringMapKeyType': concertoNs, - 'DateTimeMapKeyType': concertoNs, - 'BooleanMapValueType': concertoNs, - 'DateTimeMapValueType': concertoNs, - 'StringMapValueType': concertoNs, - 'IntegerMapValueType': concertoNs, - 'LongMapValueType': concertoNs, - 'DoubleMapValueType': concertoNs, + 'Event': concertoNs }; // First list the imported names in order (overriding as we go along) @@ -157,10 +148,8 @@ function resolveTypeNames(metaModel, table) { } break; case `${MetaModelNamespace}.MapDeclaration`: { - const nameK = metaModel.key.$class === `${MetaModelNamespace}.ObjectMapKeyType` ? metaModel.key.type.name : ModelUtil.getShortName(metaModel.key.$class); - metaModel.key.$class === `${MetaModelNamespace}.ObjectMapKeyType` ? metaModel.key.type.namespace = resolveName(nameK, table) : metaModel.key.namespace = resolveName(nameK, table); - const nameV = metaModel.value.$class === `${MetaModelNamespace}.ObjectMapValueType` ? metaModel.value.type.name : ModelUtil.getShortName(metaModel.value.$class); - metaModel.key.$class === `${MetaModelNamespace}.ObjectMapKeyType` ? metaModel.value.type.namespace = resolveName(nameV, table) : metaModel.value.namespace = resolveName(nameV, table); + resolveTypeNames(metaModel.key, table); + resolveTypeNames(metaModel.value, table); } break; case `${MetaModelNamespace}.EnumProperty`: @@ -184,6 +173,11 @@ function resolveTypeNames(metaModel, table) { metaModel.type.namespace = resolveName(name, table); } break; + case `${MetaModelNamespace}.ObjectMapKeyType`: + case `${MetaModelNamespace}.ObjectMapValueType`: { + metaModel.type.namespace = resolveName(metaModel.type.name, table); + } + break; } return metaModel; } From c1afe8700c0a5db01933fab953d8b9bb78a61b79 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 11:58:23 +0100 Subject: [PATCH 06/11] feat(*): add scalar support Signed-off-by: Jonathan Casey --- lib/metamodelutil.js | 9 +++++++++ test/cto/carResolved.json | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/metamodelutil.js b/lib/metamodelutil.js index e47ba95..c3a9181 100644 --- a/lib/metamodelutil.js +++ b/lib/metamodelutil.js @@ -178,6 +178,15 @@ function resolveTypeNames(metaModel, table) { metaModel.type.namespace = resolveName(metaModel.type.name, table); } break; + case `${MetaModelNamespace}.StringScalar`: + case `${MetaModelNamespace}.BooleanScalar`: + case `${MetaModelNamespace}.DateTimeScalar`: + case `${MetaModelNamespace}.DoubleScalar`: + case `${MetaModelNamespace}.LongScalar`: + case `${MetaModelNamespace}.IntegerScalar`: { + metaModel.namespace = resolveName(metaModel.name, table); + } + break; } return metaModel; } diff --git a/test/cto/carResolved.json b/test/cto/carResolved.json index 41c8ded..f63458e 100644 --- a/test/cto/carResolved.json +++ b/test/cto/carResolved.json @@ -113,7 +113,8 @@ { "$class": "concerto.metamodel@1.0.0.DateTimeScalar", "defaultValue": null, - "name": "DateServiced" + "name": "DateServiced", + "namespace": "org.car" }, { "$class": "concerto.metamodel@1.0.0.MapDeclaration", From f099dd6e15acb6b9bb4f50341ffd50f29d085802 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 13:58:20 +0100 Subject: [PATCH 07/11] feat(map): use latest concerto-core Signed-off-by: Jonathan Casey --- package-lock.json | 266 +++++++++++++++++++++++++++++++++------------- package.json | 2 +- 2 files changed, 191 insertions(+), 77 deletions(-) diff --git a/package-lock.json b/package-lock.json index fec578e..34f575d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "3.8.1", "license": "Apache-2.0", "dependencies": { - "@accordproject/concerto-core": "3.9.1", + "@accordproject/concerto-core": "3.14.0", "@accordproject/concerto-util": "3.9.1", "@types/node": "20.7.0" }, @@ -34,65 +34,131 @@ } }, "node_modules/@accordproject/concerto-core": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.9.1.tgz", - "integrity": "sha512-+0ao/fvilYyWQbdnRvu1kT3t0rKa5CLyeay65LKMLu9oR2akuHAp28BaujcUQQscAWLHJE+1ks7BoODJop7kzw==", - "dependencies": { - "@accordproject/concerto-cto": "3.9.1", - "@accordproject/concerto-metamodel": "3.8.0", - "@accordproject/concerto-util": "3.9.1", - "dayjs": "1.10.8", - "debug": "4.3.1", - "lorem-ipsum": "2.0.3", + "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.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", "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-cto": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.9.1.tgz", - "integrity": "sha512-YGy9NhypzcUOPcnP+lBoibyw85jKX5PcwSCMp0plvfPoZnO2ShvZ9LX6eGPccZX8wBDuY5GbfVTm0TUiz7c5Uw==", + "node_modules/@accordproject/concerto-core/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==", "dependencies": { - "@accordproject/concerto-metamodel": "3.8.0", - "@accordproject/concerto-util": "3.9.1", - "path-browserify": "1.0.1" + "@supercharge/promise-pool": "1.7.0", + "axios": "0.23.0", + "colors": "1.4.0", + "debug": "4.3.4", + "json-colorizer": "2.2.2", + "slash": "3.0.0" }, "engines": { "node": ">=16", "npm": ">=8" } }, - "node_modules/@accordproject/concerto-metamodel": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.8.0.tgz", - "integrity": "sha512-oqJP+6xKlnvR4SrDU3U+iMhFeErdn9uKRdMqlOj6lW5Geyi4DTTURkf1Vf+x8LeI6CwuOErSNNxVVKFd3LoVjQ==", + "node_modules/@accordproject/concerto-core/node_modules/dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, + "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": { - "@accordproject/concerto-util": "3.7.0" + "ms": "2.1.2" }, "engines": { - "node": ">=14", - "npm": ">=6" + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/@accordproject/concerto-metamodel/node_modules/@accordproject/concerto-util": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.7.0.tgz", - "integrity": "sha512-3qGVb/pv12hy5g44JvSH4ZZtFQ/9KNd9lWvVdh7AGfgtUdhPwlAssZTrmfY96uNP0eVE786HedC1DH6YstNK8g==", + "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.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.14.0", + "path-browserify": "1.0.1" + }, + "engines": { + "node": ">=16", + "npm": ">=8" + } + }, + "node_modules/@accordproject/concerto-cto/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==", "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" }, + "engines": { + "node": ">=16", + "npm": ">=8" + } + }, + "node_modules/@accordproject/concerto-cto/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-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==", + "dependencies": { + "@accordproject/concerto-util": "3.9.1" + }, "engines": { "node": ">=14", "npm": ">=6" @@ -1267,9 +1333,12 @@ } }, "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==" + "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/commondir": { "version": "1.0.1", @@ -1306,7 +1375,8 @@ "node_modules/dayjs": { "version": "1.10.8", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.8.tgz", - "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==" + "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==", + "dev": true }, "node_modules/debug": { "version": "4.3.1", @@ -2567,11 +2637,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" @@ -3911,6 +3981,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" } @@ -4094,56 +4165,97 @@ }, "dependencies": { "@accordproject/concerto-core": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-core/-/concerto-core-3.9.1.tgz", - "integrity": "sha512-+0ao/fvilYyWQbdnRvu1kT3t0rKa5CLyeay65LKMLu9oR2akuHAp28BaujcUQQscAWLHJE+1ks7BoODJop7kzw==", - "requires": { - "@accordproject/concerto-cto": "3.9.1", - "@accordproject/concerto-metamodel": "3.8.0", - "@accordproject/concerto-util": "3.9.1", - "dayjs": "1.10.8", - "debug": "4.3.1", - "lorem-ipsum": "2.0.3", + "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==", + "requires": { + "@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", "randexp": "0.5.3", "semver": "7.5.4", "slash": "3.0.0", "urijs": "1.19.11", - "uuid": "8.3.2" + "uuid": "9.0.1" + }, + "dependencies": { + "@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==", + "requires": { + "@supercharge/promise-pool": "1.7.0", + "axios": "0.23.0", + "colors": "1.4.0", + "debug": "4.3.4", + "json-colorizer": "2.2.2", + "slash": "3.0.0" + } + }, + "dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" + } } }, "@accordproject/concerto-cto": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-cto/-/concerto-cto-3.9.1.tgz", - "integrity": "sha512-YGy9NhypzcUOPcnP+lBoibyw85jKX5PcwSCMp0plvfPoZnO2ShvZ9LX6eGPccZX8wBDuY5GbfVTm0TUiz7c5Uw==", + "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==", "requires": { - "@accordproject/concerto-metamodel": "3.8.0", - "@accordproject/concerto-util": "3.9.1", + "@accordproject/concerto-metamodel": "3.8.1", + "@accordproject/concerto-util": "3.14.0", "path-browserify": "1.0.1" - } - }, - "@accordproject/concerto-metamodel": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-metamodel/-/concerto-metamodel-3.8.0.tgz", - "integrity": "sha512-oqJP+6xKlnvR4SrDU3U+iMhFeErdn9uKRdMqlOj6lW5Geyi4DTTURkf1Vf+x8LeI6CwuOErSNNxVVKFd3LoVjQ==", - "requires": { - "@accordproject/concerto-util": "3.7.0" }, "dependencies": { "@accordproject/concerto-util": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.7.0.tgz", - "integrity": "sha512-3qGVb/pv12hy5g44JvSH4ZZtFQ/9KNd9lWvVdh7AGfgtUdhPwlAssZTrmfY96uNP0eVE786HedC1DH6YstNK8g==", + "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==", "requires": { "@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" } + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } } } }, + "@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==", + "requires": { + "@accordproject/concerto-util": "3.9.1" + } + }, "@accordproject/concerto-util": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/@accordproject/concerto-util/-/concerto-util-3.9.1.tgz", @@ -5038,9 +5150,9 @@ "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" }, "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==" + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==" }, "commondir": { "version": "1.0.1", @@ -5074,7 +5186,8 @@ "dayjs": { "version": "1.10.8", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.8.tgz", - "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==" + "integrity": "sha512-wbNwDfBHHur9UOzNUjeKUOJ0fCb0a52Wx0xInmQ7Y8FstyajiV1NmK1e00cxsr9YrE9r7yAChE0VvpuY5Rnlow==", + "dev": true }, "debug": { "version": "4.3.1", @@ -6006,11 +6119,11 @@ } }, "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==", "requires": { - "commander": "^2.17.1" + "commander": "^9.3.0" } }, "loupe": { @@ -7016,7 +7129,8 @@ "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true }, "v8-compile-cache": { "version": "2.3.0", diff --git a/package.json b/package.json index 74b0401..2a129d3 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "typescript": "4.6.3" }, "dependencies": { - "@accordproject/concerto-core": "3.9.1", + "@accordproject/concerto-core": "3.14.0", "@accordproject/concerto-util": "3.9.1", "@types/node": "20.7.0" }, From 1c1b3920f3fea656ca2fd8b4ad68ace0d6fbad79 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 13:59:49 +0100 Subject: [PATCH 08/11] feat(map): test coverage for resolving imports on maps Signed-off-by: Jonathan Casey --- test/cto/base.cto | 21 ++ test/cto/base.json | 33 ++ test/cto/mapImportsResolved.json | 515 +++++++++++++++++++++++++++++++ test/cto/model.cto | 47 +++ test/cto/model.json | 105 +++++++ test/metamodelutil.js | 26 ++ 6 files changed, 747 insertions(+) create mode 100644 test/cto/base.cto create mode 100644 test/cto/base.json create mode 100644 test/cto/mapImportsResolved.json create mode 100644 test/cto/model.cto create mode 100644 test/cto/model.json diff --git a/test/cto/base.cto b/test/cto/base.cto new file mode 100644 index 0000000..acc06e4 --- /dev/null +++ b/test/cto/base.cto @@ -0,0 +1,21 @@ +/* + * 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. + */ +namespace com.testing.base@1.0.0 + +scalar Foo extends String +scalar Bar extends Boolean +scalar Baz extends DateTime +scalar Bazola extends Long +scalar Bongo extends Double +scalar Qux extends Integer \ No newline at end of file diff --git a/test/cto/base.json b/test/cto/base.json new file mode 100644 index 0000000..4cd19d9 --- /dev/null +++ b/test/cto/base.json @@ -0,0 +1,33 @@ +{ + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "com.testing.base@1.0.0", + "imports": [], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.StringScalar", + "name": "Foo" + }, + { + "$class": "concerto.metamodel@1.0.0.BooleanScalar", + "name": "Bar" + }, + { + "$class": "concerto.metamodel@1.0.0.DateTimeScalar", + "defaultValue": null, + "name": "Baz" + }, + { + "$class": "concerto.metamodel@1.0.0.LongScalar", + "name": "Bazola" + }, + { + "$class": "concerto.metamodel@1.0.0.DoubleScalar", + "name": "Bongo" + }, + { + "$class": "concerto.metamodel@1.0.0.IntegerScalar", + "name": "Qux" + } + ] +} \ No newline at end of file diff --git a/test/cto/mapImportsResolved.json b/test/cto/mapImportsResolved.json new file mode 100644 index 0000000..620e702 --- /dev/null +++ b/test/cto/mapImportsResolved.json @@ -0,0 +1,515 @@ +{ + "$class": "concerto.metamodel@1.0.0.Models", + "models": [ + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "com.testing.base@1.0.0", + "imports": [], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.StringScalar", + "name": "Foo", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 594, + "line": 18, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 620, + "line": 19, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "namespace": "com.testing.base@1.0.0" + }, + { + "$class": "concerto.metamodel@1.0.0.BooleanScalar", + "name": "Bar", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 620, + "line": 19, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 647, + "line": 20, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "namespace": "com.testing.base@1.0.0" + }, + { + "$class": "concerto.metamodel@1.0.0.DateTimeScalar", + "defaultValue": null, + "name": "Baz", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 647, + "line": 20, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 675, + "line": 21, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "namespace": "com.testing.base@1.0.0" + }, + { + "$class": "concerto.metamodel@1.0.0.LongScalar", + "name": "Bazola", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 675, + "line": 21, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 702, + "line": 22, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "namespace": "com.testing.base@1.0.0" + }, + { + "$class": "concerto.metamodel@1.0.0.DoubleScalar", + "name": "Bongo", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 702, + "line": 22, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 730, + "line": 23, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "namespace": "com.testing.base@1.0.0" + }, + { + "$class": "concerto.metamodel@1.0.0.IntegerScalar", + "name": "Qux", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 730, + "line": 23, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 756, + "line": 23, + "column": 27, + "$class": "concerto.metamodel@1.0.0.Position" + } + }, + "namespace": "com.testing.base@1.0.0" + } + ] + }, + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "com.testing@1.0.0", + "imports": [ + { + "$class": "concerto.metamodel@1.0.0.ImportTypes", + "namespace": "com.testing.base@1.0.0", + "types": [ + "Foo", + "Bar", + "Baz", + "Bazola", + "Bongo", + "Qux" + ] + } + ], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation1", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 678, + "line": 19, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 689, + "line": 20, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Foo", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 689, + "line": 20, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 695, + "line": 21, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 654, + "line": 18, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 696, + "line": 21, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation2", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 722, + "line": 24, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 733, + "line": 25, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bar", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 733, + "line": 25, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 739, + "line": 26, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 698, + "line": 23, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 740, + "line": 26, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation3", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 766, + "line": 29, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 777, + "line": 30, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Baz", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 777, + "line": 30, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 783, + "line": 31, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 742, + "line": 28, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 784, + "line": 31, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation4", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 810, + "line": 34, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 821, + "line": 35, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bazola", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 821, + "line": 35, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 830, + "line": 36, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 786, + "line": 33, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 831, + "line": 36, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation5", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 857, + "line": 39, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 868, + "line": 40, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bongo", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 868, + "line": 40, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 876, + "line": 41, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 833, + "line": 38, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 877, + "line": 41, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation6", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 903, + "line": 44, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 914, + "line": 45, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Qux", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 914, + "line": 45, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 920, + "line": 46, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 879, + "line": 43, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 921, + "line": 46, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ] + } + ] +} \ No newline at end of file diff --git a/test/cto/model.cto b/test/cto/model.cto new file mode 100644 index 0000000..eaf13f1 --- /dev/null +++ b/test/cto/model.cto @@ -0,0 +1,47 @@ +/* + * 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. + */ +namespace com.testing@1.0.0 + +import com.testing.base@1.0.0.{Foo, Bar, Baz, Bazola, Bongo, Qux} + +map MapPermutation1 { + o String + o Foo +} + +map MapPermutation2 { + o String + o Bar +} + +map MapPermutation3 { + o String + o Baz +} + +map MapPermutation4 { + o String + o Bazola +} + +map MapPermutation5 { + o String + o Bongo +} + +map MapPermutation6 { + o String + o Qux +} + diff --git a/test/cto/model.json b/test/cto/model.json new file mode 100644 index 0000000..67ba10f --- /dev/null +++ b/test/cto/model.json @@ -0,0 +1,105 @@ +{ + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "com.testing@1.0.0", + "imports": [ + { + "$class": "concerto.metamodel@1.0.0.ImportTypes", + "namespace": "com.testing.base@1.0.0", + "types": [ + "Foo", + "Bar", + "Baz", + "Bazola", + "Bongo", + "Qux" + ] + } + ], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation1", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType" + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Foo" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation2", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType" + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bar" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation3", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType" + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Baz" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation4", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType" + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bazola" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation5", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType" + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bongo" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation6", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType" + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Qux" + } + } + } + ] +} \ No newline at end of file diff --git a/test/metamodelutil.js b/test/metamodelutil.js index 3125bc4..dabb22b 100644 --- a/test/metamodelutil.js +++ b/test/metamodelutil.js @@ -15,6 +15,7 @@ 'use strict'; const MetaModelUtil = require('../lib/metamodelutil'); +const ModelManager = require('@accordproject/concerto-core').ModelManager; const fs = require('fs'); const path = require('path'); @@ -100,6 +101,31 @@ describe('MetaModel (Car)', () => { }); }); +describe('MetaModel (with Maps & Scalars)', () => { + const modelManager = new ModelManager(); + + // Add base + const baseModelPath = path.resolve(__dirname, './cto/base.cto'); + let baseModel = fs.readFileSync(baseModelPath, 'utf8'); + modelManager.addCTOModel(baseModel, 'base.cto'); + + // Add Model which imports from base + const modelPath = path.resolve(__dirname, './cto/model.cto'); + let model = fs.readFileSync(modelPath, 'utf8'); + modelManager.addCTOModel(model, 'model.cto'); + + // The ModelFile resolved + const mapImportsResolved = JSON.parse(fs.readFileSync(path.resolve(__dirname, './cto/mapImportsResolved.json'), 'utf8')); + + describe('#toMetaModel', () => { + it('should resolve all namespaces on a Model containing Map Types, where the Map Types are imported', async () => { + const modelFile = modelManager.getAst(); + const mm1r = MetaModelUtil.resolveLocalNamesForAll(modelFile); + mm1r.should.deep.equal(mapImportsResolved); + }); + }); +}); + describe('MetaModel (Car - with import types)', () => { const carModelPath = path.resolve(__dirname, './cto/carImportTypes.json'); const carModel = JSON.parse(fs.readFileSync(carModelPath, 'utf8')); From 7b847fb416ca2cc6ff67d2a18412fb28cbf875d0 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 14:37:02 +0100 Subject: [PATCH 09/11] feat(map): test refactor Signed-off-by: Jonathan Casey --- test/cto/base.cto | 21 -- test/cto/base.json | 33 -- test/cto/mapImportsResolved.json | 108 ++++-- test/cto/mapsImported.json | 562 +++++++++++++++++++++++++++++++ test/cto/model.cto | 47 --- test/cto/model.json | 105 ------ test/metamodelutil.js | 16 +- 7 files changed, 649 insertions(+), 243 deletions(-) delete mode 100644 test/cto/base.cto delete mode 100644 test/cto/base.json create mode 100644 test/cto/mapsImported.json delete mode 100644 test/cto/model.cto delete mode 100644 test/cto/model.json diff --git a/test/cto/base.cto b/test/cto/base.cto deleted file mode 100644 index acc06e4..0000000 --- a/test/cto/base.cto +++ /dev/null @@ -1,21 +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. - */ -namespace com.testing.base@1.0.0 - -scalar Foo extends String -scalar Bar extends Boolean -scalar Baz extends DateTime -scalar Bazola extends Long -scalar Bongo extends Double -scalar Qux extends Integer \ No newline at end of file diff --git a/test/cto/base.json b/test/cto/base.json deleted file mode 100644 index 4cd19d9..0000000 --- a/test/cto/base.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "$class": "concerto.metamodel@1.0.0.Model", - "decorators": [], - "namespace": "com.testing.base@1.0.0", - "imports": [], - "declarations": [ - { - "$class": "concerto.metamodel@1.0.0.StringScalar", - "name": "Foo" - }, - { - "$class": "concerto.metamodel@1.0.0.BooleanScalar", - "name": "Bar" - }, - { - "$class": "concerto.metamodel@1.0.0.DateTimeScalar", - "defaultValue": null, - "name": "Baz" - }, - { - "$class": "concerto.metamodel@1.0.0.LongScalar", - "name": "Bazola" - }, - { - "$class": "concerto.metamodel@1.0.0.DoubleScalar", - "name": "Bongo" - }, - { - "$class": "concerto.metamodel@1.0.0.IntegerScalar", - "name": "Qux" - } - ] -} \ No newline at end of file diff --git a/test/cto/mapImportsResolved.json b/test/cto/mapImportsResolved.json index 620e702..4d3d024 100644 --- a/test/cto/mapImportsResolved.json +++ b/test/cto/mapImportsResolved.json @@ -13,14 +13,14 @@ "location": { "$class": "concerto.metamodel@1.0.0.Range", "start": { - "offset": 594, - "line": 18, + "offset": 592, + "line": 16, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" }, "end": { - "offset": 620, - "line": 19, + "offset": 618, + "line": 17, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" } @@ -33,14 +33,14 @@ "location": { "$class": "concerto.metamodel@1.0.0.Range", "start": { - "offset": 620, - "line": 19, + "offset": 618, + "line": 17, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" }, "end": { - "offset": 647, - "line": 20, + "offset": 645, + "line": 18, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" } @@ -54,14 +54,14 @@ "location": { "$class": "concerto.metamodel@1.0.0.Range", "start": { - "offset": 647, - "line": 20, + "offset": 645, + "line": 18, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" }, "end": { - "offset": 675, - "line": 21, + "offset": 673, + "line": 19, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" } @@ -74,14 +74,14 @@ "location": { "$class": "concerto.metamodel@1.0.0.Range", "start": { - "offset": 675, - "line": 21, + "offset": 673, + "line": 19, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" }, "end": { - "offset": 702, - "line": 22, + "offset": 700, + "line": 20, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" } @@ -94,14 +94,14 @@ "location": { "$class": "concerto.metamodel@1.0.0.Range", "start": { - "offset": 702, - "line": 22, + "offset": 700, + "line": 20, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" }, "end": { - "offset": 730, - "line": 23, + "offset": 728, + "line": 21, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" } @@ -114,14 +114,14 @@ "location": { "$class": "concerto.metamodel@1.0.0.Range", "start": { - "offset": 730, - "line": 23, + "offset": 728, + "line": 21, "column": 1, "$class": "concerto.metamodel@1.0.0.Position" }, "end": { - "offset": 756, - "line": 23, + "offset": 754, + "line": 21, "column": 27, "$class": "concerto.metamodel@1.0.0.Position" } @@ -508,6 +508,66 @@ "$class": "concerto.metamodel@1.0.0.Position" } } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation7", + "key": { + "$class": "concerto.metamodel@1.0.0.ObjectMapKeyType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Qux", + "namespace": "com.testing.base@1.0.0" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 947, + "line": 49, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 955, + "line": 50, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.StringMapValueType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 955, + "line": 50, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 964, + "line": 51, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 923, + "line": 48, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 965, + "line": 51, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } } ] } diff --git a/test/cto/mapsImported.json b/test/cto/mapsImported.json new file mode 100644 index 0000000..340295f --- /dev/null +++ b/test/cto/mapsImported.json @@ -0,0 +1,562 @@ +{ + "$class": "concerto.metamodel@1.0.0.Models", + "models": [ + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "com.testing.base@1.0.0", + "imports": [], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.StringScalar", + "name": "Foo", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 592, + "line": 16, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 618, + "line": 17, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.BooleanScalar", + "name": "Bar", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 618, + "line": 17, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 645, + "line": 18, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.DateTimeScalar", + "defaultValue": null, + "name": "Baz", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 645, + "line": 18, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 673, + "line": 19, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.LongScalar", + "name": "Bazola", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 673, + "line": 19, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 700, + "line": 20, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.DoubleScalar", + "name": "Bongo", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 700, + "line": 20, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 728, + "line": 21, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.IntegerScalar", + "name": "Qux", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 728, + "line": 21, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 754, + "line": 21, + "column": 27, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ] + }, + { + "$class": "concerto.metamodel@1.0.0.Model", + "decorators": [], + "namespace": "com.testing@1.0.0", + "imports": [ + { + "$class": "concerto.metamodel@1.0.0.ImportTypes", + "namespace": "com.testing.base@1.0.0", + "types": [ + "Foo", + "Bar", + "Baz", + "Bazola", + "Bongo", + "Qux" + ] + } + ], + "declarations": [ + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation1", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 678, + "line": 19, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 689, + "line": 20, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Foo" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 689, + "line": 20, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 695, + "line": 21, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 654, + "line": 18, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 696, + "line": 21, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation2", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 722, + "line": 24, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 733, + "line": 25, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bar" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 733, + "line": 25, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 739, + "line": 26, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 698, + "line": 23, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 740, + "line": 26, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation3", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 766, + "line": 29, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 777, + "line": 30, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Baz" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 777, + "line": 30, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 783, + "line": 31, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 742, + "line": 28, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 784, + "line": 31, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation4", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 810, + "line": 34, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 821, + "line": 35, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bazola" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 821, + "line": 35, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 830, + "line": 36, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 786, + "line": 33, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 831, + "line": 36, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation5", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 857, + "line": 39, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 868, + "line": 40, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Bongo" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 868, + "line": 40, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 876, + "line": 41, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 833, + "line": 38, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 877, + "line": 41, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation6", + "key": { + "$class": "concerto.metamodel@1.0.0.StringMapKeyType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 903, + "line": 44, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 914, + "line": 45, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Qux" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 914, + "line": 45, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 920, + "line": 46, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 879, + "line": 43, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 921, + "line": 46, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + { + "$class": "concerto.metamodel@1.0.0.MapDeclaration", + "name": "MapPermutation7", + "key": { + "$class": "concerto.metamodel@1.0.0.ObjectMapKeyType", + "type": { + "$class": "concerto.metamodel@1.0.0.TypeIdentifier", + "name": "Qux" + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 947, + "line": 49, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 955, + "line": 50, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "value": { + "$class": "concerto.metamodel@1.0.0.StringMapValueType", + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 955, + "line": 50, + "column": 3, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 964, + "line": 51, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + }, + "location": { + "$class": "concerto.metamodel@1.0.0.Range", + "start": { + "offset": 923, + "line": 48, + "column": 1, + "$class": "concerto.metamodel@1.0.0.Position" + }, + "end": { + "offset": 965, + "line": 51, + "column": 2, + "$class": "concerto.metamodel@1.0.0.Position" + } + } + } + ] + } + ] +} \ No newline at end of file diff --git a/test/cto/model.cto b/test/cto/model.cto deleted file mode 100644 index eaf13f1..0000000 --- a/test/cto/model.cto +++ /dev/null @@ -1,47 +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. - */ -namespace com.testing@1.0.0 - -import com.testing.base@1.0.0.{Foo, Bar, Baz, Bazola, Bongo, Qux} - -map MapPermutation1 { - o String - o Foo -} - -map MapPermutation2 { - o String - o Bar -} - -map MapPermutation3 { - o String - o Baz -} - -map MapPermutation4 { - o String - o Bazola -} - -map MapPermutation5 { - o String - o Bongo -} - -map MapPermutation6 { - o String - o Qux -} - diff --git a/test/cto/model.json b/test/cto/model.json deleted file mode 100644 index 67ba10f..0000000 --- a/test/cto/model.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "$class": "concerto.metamodel@1.0.0.Model", - "decorators": [], - "namespace": "com.testing@1.0.0", - "imports": [ - { - "$class": "concerto.metamodel@1.0.0.ImportTypes", - "namespace": "com.testing.base@1.0.0", - "types": [ - "Foo", - "Bar", - "Baz", - "Bazola", - "Bongo", - "Qux" - ] - } - ], - "declarations": [ - { - "$class": "concerto.metamodel@1.0.0.MapDeclaration", - "name": "MapPermutation1", - "key": { - "$class": "concerto.metamodel@1.0.0.StringMapKeyType" - }, - "value": { - "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", - "type": { - "$class": "concerto.metamodel@1.0.0.TypeIdentifier", - "name": "Foo" - } - } - }, - { - "$class": "concerto.metamodel@1.0.0.MapDeclaration", - "name": "MapPermutation2", - "key": { - "$class": "concerto.metamodel@1.0.0.StringMapKeyType" - }, - "value": { - "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", - "type": { - "$class": "concerto.metamodel@1.0.0.TypeIdentifier", - "name": "Bar" - } - } - }, - { - "$class": "concerto.metamodel@1.0.0.MapDeclaration", - "name": "MapPermutation3", - "key": { - "$class": "concerto.metamodel@1.0.0.StringMapKeyType" - }, - "value": { - "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", - "type": { - "$class": "concerto.metamodel@1.0.0.TypeIdentifier", - "name": "Baz" - } - } - }, - { - "$class": "concerto.metamodel@1.0.0.MapDeclaration", - "name": "MapPermutation4", - "key": { - "$class": "concerto.metamodel@1.0.0.StringMapKeyType" - }, - "value": { - "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", - "type": { - "$class": "concerto.metamodel@1.0.0.TypeIdentifier", - "name": "Bazola" - } - } - }, - { - "$class": "concerto.metamodel@1.0.0.MapDeclaration", - "name": "MapPermutation5", - "key": { - "$class": "concerto.metamodel@1.0.0.StringMapKeyType" - }, - "value": { - "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", - "type": { - "$class": "concerto.metamodel@1.0.0.TypeIdentifier", - "name": "Bongo" - } - } - }, - { - "$class": "concerto.metamodel@1.0.0.MapDeclaration", - "name": "MapPermutation6", - "key": { - "$class": "concerto.metamodel@1.0.0.StringMapKeyType" - }, - "value": { - "$class": "concerto.metamodel@1.0.0.ObjectMapValueType", - "type": { - "$class": "concerto.metamodel@1.0.0.TypeIdentifier", - "name": "Qux" - } - } - } - ] -} \ No newline at end of file diff --git a/test/metamodelutil.js b/test/metamodelutil.js index dabb22b..98e7b07 100644 --- a/test/metamodelutil.js +++ b/test/metamodelutil.js @@ -15,7 +15,6 @@ 'use strict'; const MetaModelUtil = require('../lib/metamodelutil'); -const ModelManager = require('@accordproject/concerto-core').ModelManager; const fs = require('fs'); const path = require('path'); @@ -102,24 +101,15 @@ describe('MetaModel (Car)', () => { }); describe('MetaModel (with Maps & Scalars)', () => { - const modelManager = new ModelManager(); - - // Add base - const baseModelPath = path.resolve(__dirname, './cto/base.cto'); - let baseModel = fs.readFileSync(baseModelPath, 'utf8'); - modelManager.addCTOModel(baseModel, 'base.cto'); - - // Add Model which imports from base - const modelPath = path.resolve(__dirname, './cto/model.cto'); - let model = fs.readFileSync(modelPath, 'utf8'); - modelManager.addCTOModel(model, 'model.cto'); + process.env.ENABLE_MAP_TYPE = 'true'; // TODO Remove on release of MapType + const modelPath = path.resolve(__dirname, './cto/mapsImported.json'); + let modelFile = JSON.parse(fs.readFileSync(modelPath, 'utf8')); // The ModelFile resolved const mapImportsResolved = JSON.parse(fs.readFileSync(path.resolve(__dirname, './cto/mapImportsResolved.json'), 'utf8')); describe('#toMetaModel', () => { it('should resolve all namespaces on a Model containing Map Types, where the Map Types are imported', async () => { - const modelFile = modelManager.getAst(); const mm1r = MetaModelUtil.resolveLocalNamesForAll(modelFile); mm1r.should.deep.equal(mapImportsResolved); }); From e145900cae0c9ca88b77eeade4cb75f0d0f2f529 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 14:38:00 +0100 Subject: [PATCH 10/11] chore(*): no circular dependency Signed-off-by: Jonathan Casey --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2a129d3..b471bc4 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "typescript": "4.6.3" }, "dependencies": { - "@accordproject/concerto-core": "3.14.0", "@accordproject/concerto-util": "3.9.1", "@types/node": "20.7.0" }, From 0faf117d78ada3934d48e4c5afa790b01ad04436 Mon Sep 17 00:00:00 2001 From: Jonathan Casey Date: Fri, 20 Oct 2023 14:45:26 +0100 Subject: [PATCH 11/11] feat(map): resolve decorators on MapDeclarations and Scalars Signed-off-by: Jonathan Casey --- lib/metamodelutil.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/metamodelutil.js b/lib/metamodelutil.js index c3a9181..7512ed2 100644 --- a/lib/metamodelutil.js +++ b/lib/metamodelutil.js @@ -176,6 +176,9 @@ function resolveTypeNames(metaModel, table) { case `${MetaModelNamespace}.ObjectMapKeyType`: case `${MetaModelNamespace}.ObjectMapValueType`: { metaModel.type.namespace = resolveName(metaModel.type.name, table); + (metaModel.decorators || []).forEach((decorator) => { + resolveTypeNames(decorator, table); + }); } break; case `${MetaModelNamespace}.StringScalar`: @@ -185,6 +188,9 @@ function resolveTypeNames(metaModel, table) { case `${MetaModelNamespace}.LongScalar`: case `${MetaModelNamespace}.IntegerScalar`: { metaModel.namespace = resolveName(metaModel.name, table); + (metaModel.decorators || []).forEach((decorator) => { + resolveTypeNames(decorator, table); + }); } break; }