Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(map): Extend Type support #677

Merged
merged 41 commits into from
Aug 16, 2023
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2029833
feat(map): add to introspection API
jonathan-casey Aug 1, 2023
1539a64
feat(map): extend JsonGenerator for Map Types
jonathan-casey Aug 1, 2023
fcd0b20
feat(map): extend JsonPopulator for Map Types
jonathan-casey Aug 1, 2023
a3f247a
feat(map): extend ResourceValidator for Map Types
jonathan-casey Aug 1, 2023
4817266
feat(map): add test cases for Map serialisation <> deserialisation
jonathan-casey Aug 1, 2023
d0802b1
feat(map): cleanup
jonathan-casey Aug 1, 2023
916069d
feat(map): add type definitions
jonathan-casey Aug 1, 2023
6c23986
feat(map): satisfy version checker
jonathan-casey Aug 1, 2023
fb3c393
feat(map): remove variable assignment for chai import
jonathan-casey Aug 1, 2023
a788e44
feat(map): satisfy version checker
jonathan-casey Aug 1, 2023
34fbf74
feat(map): update test cases to match on error handling changes
jonathan-casey Aug 1, 2023
116b180
feat(map): cleanup
jonathan-casey Aug 1, 2023
4478693
feat(map): cleanup test cases
jonathan-casey Aug 1, 2023
ffe486a
test(map): add tests for missed cases
mttrbrts Aug 2, 2023
389449e
feat(map): fixes metamodel parsing for MapDeclarations
jonathan-casey Aug 3, 2023
bfbe382
feat(map): printer update reads new metamodel map shape
jonathan-casey Aug 3, 2023
9570985
feat(map): updates test data for new metamodel design
jonathan-casey Aug 3, 2023
57408b5
feat(map): initial rework of introspection
jonathan-casey Aug 4, 2023
42668f9
feat(map): add more test coverage
jonathan-casey Aug 9, 2023
5f627f8
feat(map): improve error messaging & cleanup
jonathan-casey Aug 9, 2023
b5d6c83
feat(map): adds more test coverage for MapKeyType introspection
jonathan-casey Aug 9, 2023
882bf5a
feat(map): adds more test coverage for MapValueType introspection
jonathan-casey Aug 9, 2023
85f8f10
feat(map): refactor serialization
jonathan-casey Aug 10, 2023
2f8d622
feat(map): refactor serialization test coverage
jonathan-casey Aug 10, 2023
427658f
feat(map): cleanup
jonathan-casey Aug 10, 2023
539e393
feat(map): DRY up code in the JSONPopulator
jonathan-casey Aug 10, 2023
bdeeb02
feat(map): adds coverage to new introspection functions
jonathan-casey Aug 10, 2023
b01e444
feat(map): adds type definitions
jonathan-casey Aug 10, 2023
9bce014
feat(map): updates changelog
jonathan-casey Aug 10, 2023
56204f6
fix: Private identifiers are only available when targeting ECMAScript…
jonathan-casey Aug 10, 2023
0d495d5
fix: updates changelog
jonathan-casey Aug 10, 2023
f72a3d0
feat(map): moves isValidMapKey & isValidMapValue to ModelUtils
jonathan-casey Aug 14, 2023
32951fc
feat(map): removes unreachable default case
jonathan-casey Aug 14, 2023
a4d3749
feat(map): removes unreachable code
jonathan-casey Aug 14, 2023
af42e11
feat(map): adds more test coverage
jonathan-casey Aug 14, 2023
926f91d
feat(map): remove dead code
jonathan-casey Aug 14, 2023
04b0798
feat(map): adds JSDoc @private
jonathan-casey Aug 14, 2023
d446e1d
feat(map): adds type defs & change log
jonathan-casey Aug 14, 2023
19dfcf7
feat(map): improve error message
jonathan-casey Aug 16, 2023
74cb997
feat(map): add util method
jonathan-casey Aug 16, 2023
08ce775
fix: update type def
jonathan-casey Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(map): improve error messaging & cleanup
Signed-off-by: jonathan.casey <[email protected]>
  • Loading branch information
jonathan-casey committed Aug 9, 2023
commit 5f627f866e13b80f2efdf71aabbb42f2c3a0b643
9 changes: 3 additions & 6 deletions packages/concerto-core/lib/introspect/mapkeytype.js
Original file line number Diff line number Diff line change
@@ -69,31 +69,28 @@ class MapKeyType extends Decorated {
*/
validate() {


// TODO Test cases - illegal Primitives.
if (!ModelUtil.isPrimitiveType(this.type)) {
let decl = this.parent.getModelFile().getAllDeclarations().find(d => d.name === this.ast.type?.name);

if (decl?.isScalarDeclaration?.() &&
!(decl?.ast.$class === `${MetaModelNamespace}.StringScalar`) &&
!(decl?.ast.$class === `${MetaModelNamespace}.DateTimeScalar`)) {
throw new IllegalModelException(
`Scalar must be one of StringScalar, DateTimeScalar in context of MapKeyType. Invalid Scalar: ${this.type}`
`Scalar must be one of StringScalar, DateTimeScalar in context of MapKeyType. Invalid Scalar: ${this.type}, for MapDeclaration ${this.parent.name}`
);
}

if(decl.isMapDeclaration?.()) {
throw new IllegalModelException(
`MapDeclaration as Map Type Value is not supported: ${this.type}`
`MapDeclaration as MapKeyType is not supported, for MapDeclaration ${this.parent.name}`
);
}

if (decl?.isConcept?.() || decl?.isClassDeclaration?.()) {
throw new IllegalModelException(
`Concept as Map Type Key is not supported: ${this.type}`
`MapKeyType supports String and DateTime only,for MapDeclaration ${this.parent.name}`
jonathan-casey marked this conversation as resolved.
Show resolved Hide resolved
);
}

}
}

4 changes: 0 additions & 4 deletions packages/concerto-core/lib/introspect/mapvaluetype.js
Original file line number Diff line number Diff line change
@@ -108,10 +108,6 @@ class MapValueType extends Decorated {

this.type = decl.getName();
break;
// case 'RelationshipMapValueType':
// // todo - how to handle relationship??
// this.type = 'Boolean';
// break;
case `${MetaModelNamespace}.BooleanMapValueType`:
this.type = 'Boolean';
break;
21 changes: 0 additions & 21 deletions packages/concerto-core/test/introspect/mapdeclaration.js
Original file line number Diff line number Diff line change
@@ -145,7 +145,6 @@ describe('MapDeclaration', () => {
});
});


describe('#validate success scenarios - Map Value', () => {
it('should validate when map value is a concept declaration', () => {
let decl = introspectUtils.loadLastDeclaration('test/data/parser/mapdeclaration/mapdeclaration.goodvalue.declaration.concept.cto', MapDeclaration);
@@ -290,26 +289,6 @@ describe('MapDeclaration', () => {
}).should.throw(IllegalModelException);
});

it.skip('should throw if ast contains illegal Map Key Property - Concept', () => {
(() => {
new MapDeclaration(modelFile, {
$class: '[email protected]',
name: 'MapPermutation1',
key: {
$class: '[email protected]',
type: {
$class: '[email protected]',
name: 'Person'
}
},
value: {
$class: '[email protected]'
}
});
}).should.throw(IllegalModelException);
});


it('should throw if ast contains illegal Map Key Property - Enum', () => {
(() => {
new MapDeclaration(modelFile, {