@accordproject/concerto-core 3.7.0 → 3.7.1-20230413115306
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/lib/factory.js
CHANGED
|
@@ -119,6 +119,17 @@ class Factory {
|
|
|
119
119
|
type: type
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
|
+
|
|
123
|
+
if (id) {
|
|
124
|
+
let idFullField = classDecl.getProperty(idField);
|
|
125
|
+
if (idFullField?.isTypeScalar?.()){
|
|
126
|
+
idFullField = idFullField.getScalarField();
|
|
127
|
+
}
|
|
128
|
+
// if regex on identifier field & provided id does not match regex, throw error
|
|
129
|
+
if(idFullField?.validator?.regex && (idFullField.validator?.regex.test(id) === false)) {
|
|
130
|
+
throw new Error('Provided id does not match regex: ' + idFullField?.validator?.regex);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
122
133
|
} else if(id) {
|
|
123
134
|
throw new Error('Type is not identifiable ' + classDecl.getFullyQualifiedName());
|
|
124
135
|
}
|
|
@@ -160,7 +160,16 @@ class InstanceGenerator {
|
|
|
160
160
|
|
|
161
161
|
let id = null;
|
|
162
162
|
if (classDeclaration.isIdentified()) {
|
|
163
|
-
|
|
163
|
+
let idFieldName = classDeclaration.getIdentifierFieldName();
|
|
164
|
+
let idField = classDeclaration.getProperty(idFieldName);
|
|
165
|
+
if (idField?.isTypeScalar?.()){
|
|
166
|
+
idField = idField.getScalarField();
|
|
167
|
+
}
|
|
168
|
+
if(idField?.validator?.regex){
|
|
169
|
+
id = parameters.valueGenerator.getRegex(fieldOrScalarDeclaration.validator.regex);
|
|
170
|
+
} else {
|
|
171
|
+
id = this.generateRandomId(classDeclaration);
|
|
172
|
+
}
|
|
164
173
|
}
|
|
165
174
|
let resource = parameters.factory.newResource(classDeclaration.getNamespace(), classDeclaration.getName(), id);
|
|
166
175
|
parameters.stack.push(resource);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accordproject/concerto-core",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.1-20230413115306",
|
|
4
4
|
"description": "Core Implementation for the Concerto Modeling Language",
|
|
5
5
|
"homepage": "https://github.com/accordproject/concerto",
|
|
6
6
|
"engines": {
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
"sinon-chai": "3.7.0",
|
|
66
66
|
"tmp-promise": "3.0.2",
|
|
67
67
|
"typescript": "4.6.3",
|
|
68
|
-
"webpack": "5.
|
|
68
|
+
"webpack": "5.76.0",
|
|
69
69
|
"webpack-cli": "4.9.1",
|
|
70
70
|
"xregexp": "5.1.1",
|
|
71
71
|
"yargs": "17.3.1"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@accordproject/concerto-cto": "3.7.
|
|
75
|
-
"@accordproject/concerto-metamodel": "3.7.
|
|
76
|
-
"@accordproject/concerto-util": "3.7.
|
|
74
|
+
"@accordproject/concerto-cto": "3.7.1-20230413115306",
|
|
75
|
+
"@accordproject/concerto-metamodel": "3.7.1-20230413115306",
|
|
76
|
+
"@accordproject/concerto-util": "3.7.1-20230413115306",
|
|
77
77
|
"dayjs": "1.10.8",
|
|
78
78
|
"debug": "4.3.1",
|
|
79
79
|
"lorem-ipsum": "2.0.3",
|