@accordproject/concerto-core 3.0.0-alpha.5 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/concerto-core.js +1 -1
- package/dist/concerto-core.js.LICENSE.txt +1 -1
- package/lib/concerto.js +1 -7
- package/lib/introspect/field.js +1 -1
- package/lib/modelutil.js +16 -0
- package/lib/serializer/jsonpopulator.js +3 -9
- package/lib/serializer/objectvalidator.js +2 -2
- package/package.json +8 -8
- package/types/lib/introspect/field.d.ts +2 -2
- package/types/lib/modelutil.d.ts +7 -0
package/lib/concerto.js
CHANGED
|
@@ -84,13 +84,7 @@ class Concerto {
|
|
|
84
84
|
throw new Error('Input object does not have a $class attribute.');
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (!typeDeclaration) {
|
|
90
|
-
throw new Error(`Type ${obj.$class} is not declared in the model manager`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return typeDeclaration;
|
|
87
|
+
return this.modelManager.getType(obj.$class);
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
/**
|
package/lib/introspect/field.js
CHANGED
|
@@ -90,7 +90,7 @@ class Field extends Property {
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Returns the default value for the field or null
|
|
93
|
-
* @return {string} the default value for the field or null
|
|
93
|
+
* @return {string | number} the default value for the field or null
|
|
94
94
|
*/
|
|
95
95
|
getDefaultValue() {
|
|
96
96
|
if(this.defaultValue) {
|
package/lib/modelutil.js
CHANGED
|
@@ -185,6 +185,22 @@ class ModelUtil {
|
|
|
185
185
|
return type;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Converts a fully qualified type name to a FQN without a namespace version.
|
|
191
|
+
* If the FQN is a primitive type it is returned unchanged.
|
|
192
|
+
* @param {string} fqn fully qualified name of a type
|
|
193
|
+
* @returns {string} the fully qualified name minus the namespace version
|
|
194
|
+
*/
|
|
195
|
+
static removeNamespaceVersionFromFullyQualifiedName(fqn) {
|
|
196
|
+
if(ModelUtil.isPrimitiveType(fqn)) {
|
|
197
|
+
return fqn;
|
|
198
|
+
}
|
|
199
|
+
const ns = ModelUtil.getNamespace(fqn);
|
|
200
|
+
const { name: namespace } = ModelUtil.parseNamespace(ns);
|
|
201
|
+
const typeName = ModelUtil.getShortName(fqn);
|
|
202
|
+
return ModelUtil.getFullyQualifiedName(namespace, typeName);
|
|
203
|
+
}
|
|
188
204
|
}
|
|
189
205
|
|
|
190
206
|
module.exports = ModelUtil;
|
|
@@ -338,11 +338,6 @@ class JSONPopulator {
|
|
|
338
338
|
|
|
339
339
|
if(relationshipDeclaration.isArray()) {
|
|
340
340
|
result = [];
|
|
341
|
-
if (this.ergo) {
|
|
342
|
-
if (Object.prototype.hasOwnProperty.call(jsonObj,'$coll')) {
|
|
343
|
-
jsonObj = jsonObj.$coll.slice(0,jsonObj.$length);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
341
|
for(let n=0; n < jsonObj.length; n++) {
|
|
347
342
|
let jsonItem = jsonObj[n];
|
|
348
343
|
if (typeof jsonItem === 'string') {
|
|
@@ -358,9 +353,9 @@ class JSONPopulator {
|
|
|
358
353
|
}
|
|
359
354
|
|
|
360
355
|
if (this.ergo) {
|
|
361
|
-
const theClass =
|
|
362
|
-
|
|
363
|
-
|
|
356
|
+
const theClass = jsonItem.$class.$coll[0];
|
|
357
|
+
jsonItem = jsonItem.$data;
|
|
358
|
+
jsonItem.$class = theClass;
|
|
364
359
|
}
|
|
365
360
|
const classDeclaration = parameters.modelManager.getType(jsonItem.$class);
|
|
366
361
|
|
|
@@ -386,7 +381,6 @@ class JSONPopulator {
|
|
|
386
381
|
if(!jsonObj.$class) {
|
|
387
382
|
throw new Error('Invalid JSON data. Does not contain a $class type identifier: ' + jsonObj + ' for relationship ' + relationshipDeclaration );
|
|
388
383
|
}
|
|
389
|
-
|
|
390
384
|
if (this.ergo) {
|
|
391
385
|
const theClass = jsonObj.$class.$coll[0];
|
|
392
386
|
jsonObj = jsonObj.$data;
|
|
@@ -410,8 +410,8 @@ class ObjectValidator {
|
|
|
410
410
|
let typeOfValue = typeof value;
|
|
411
411
|
|
|
412
412
|
if( concerto.isObject(value) && concerto.isIdentifiable(value)) {
|
|
413
|
-
typeOfValue =
|
|
414
|
-
value =
|
|
413
|
+
typeOfValue = concerto.getType(value);
|
|
414
|
+
value = concerto.getIdentifier(value);
|
|
415
415
|
}
|
|
416
416
|
else {
|
|
417
417
|
if(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accordproject/concerto-core",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
4
|
"description": "Core Implementation for the Concerto Modeling Language",
|
|
5
5
|
"homepage": "https://github.com/accordproject/concerto",
|
|
6
6
|
"engines": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"yargs": "17.3.1"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@accordproject/concerto-cto": "3.0.0-
|
|
72
|
-
"@accordproject/concerto-metamodel": "3.0.0-
|
|
73
|
-
"@accordproject/concerto-util": "3.0.0-
|
|
71
|
+
"@accordproject/concerto-cto": "3.0.0-beta.2",
|
|
72
|
+
"@accordproject/concerto-metamodel": "3.0.0-beta.2",
|
|
73
|
+
"@accordproject/concerto-util": "3.0.0-beta.2",
|
|
74
74
|
"dayjs": "1.10.8",
|
|
75
75
|
"debug": "4.3.1",
|
|
76
76
|
"lorem-ipsum": "2.0.3",
|
|
@@ -139,9 +139,9 @@
|
|
|
139
139
|
"exclude": [],
|
|
140
140
|
"all": true,
|
|
141
141
|
"check-coverage": true,
|
|
142
|
-
"statements":
|
|
143
|
-
"branches":
|
|
144
|
-
"functions":
|
|
145
|
-
"lines":
|
|
142
|
+
"statements": 99,
|
|
143
|
+
"branches": 98,
|
|
144
|
+
"functions": 98,
|
|
145
|
+
"lines": 99
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -19,9 +19,9 @@ declare class Field extends Property {
|
|
|
19
19
|
getValidator(): Validator;
|
|
20
20
|
/**
|
|
21
21
|
* Returns the default value for the field or null
|
|
22
|
-
* @return {string} the default value for the field or null
|
|
22
|
+
* @return {string | number} the default value for the field or null
|
|
23
23
|
*/
|
|
24
|
-
getDefaultValue(): string;
|
|
24
|
+
getDefaultValue(): string | number;
|
|
25
25
|
/**
|
|
26
26
|
* Returns true if this class is the definition of a field.
|
|
27
27
|
*
|
package/types/lib/modelutil.d.ts
CHANGED
|
@@ -98,4 +98,11 @@ declare class ModelUtil {
|
|
|
98
98
|
* @returns {string} the fully qualified type name.
|
|
99
99
|
*/
|
|
100
100
|
static getFullyQualifiedName(namespace: string, type: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Converts a fully qualified type name to a FQN without a namespace version.
|
|
103
|
+
* If the FQN is a primitive type it is returned unchanged.
|
|
104
|
+
* @param {string} fqn fully qualified name of a type
|
|
105
|
+
* @returns {string} the fully qualified name minus the namespace version
|
|
106
|
+
*/
|
|
107
|
+
static removeNamespaceVersionFromFullyQualifiedName(fqn: string): string;
|
|
101
108
|
}
|