@accordproject/concerto-core 2.1.0 → 2.2.1-20220527104623
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/changelog.txt
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
# Note that the latest public API is documented using JSDocs and is available in api.txt.
|
|
25
25
|
#
|
|
26
26
|
|
|
27
|
+
Version 2.0.2 {c9e7b234a5786db232520137be0a0fa8} 22-05-25
|
|
28
|
+
- Add ClassDeclaration.getDirectSubclasses for use in visitor
|
|
29
|
+
|
|
27
30
|
Version 2.0.1 {f5d85447683b22d6f4072f9cd7f8986e} 22-05-13
|
|
28
31
|
- Add Decorator.isDecorator for use in visitor
|
|
29
32
|
|
package/lib/datetimeutil.js
CHANGED
|
@@ -35,6 +35,9 @@ function setCurrentTime(currentTime, utcOffset) {
|
|
|
35
35
|
// Default UTC offset to local time
|
|
36
36
|
const utcOffsetResolved = typeof utcOffset === 'number' ? utcOffset : dayjs().utcOffset();
|
|
37
37
|
const currentTimeUTC = currentTime ? dayjs.utc(currentTime) : dayjs().utc();
|
|
38
|
+
if (!currentTimeUTC.isValid()) {
|
|
39
|
+
throw new Error(`Current time '${currentTime}' is not in standard UTC format`);
|
|
40
|
+
}
|
|
38
41
|
const currentTimeResolved = currentTimeUTC.utcOffset(utcOffsetResolved);
|
|
39
42
|
if (!currentTimeResolved.isValid()) {
|
|
40
43
|
throw new Error(`Cannot set current time to '${currentTime}' with UTC offset '${utcOffset}'`);
|
|
@@ -474,6 +474,35 @@ class ClassDeclaration extends Decorated {
|
|
|
474
474
|
return Array.from(results);
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Get the class declarations for just the direct subclasses of this class, excluding this class.
|
|
479
|
+
* @return {ClassDeclaration[]} direct subclass declarations.
|
|
480
|
+
*/
|
|
481
|
+
getDirectSubclasses() {
|
|
482
|
+
const modelManager = this.getModelFile().getModelManager();
|
|
483
|
+
const introspector = new Introspector(modelManager);
|
|
484
|
+
const allClassDeclarations = introspector.getClassDeclarations();
|
|
485
|
+
const subclassMap = new Map();
|
|
486
|
+
|
|
487
|
+
// Build map of all direct subclasses relationships
|
|
488
|
+
allClassDeclarations.forEach((declaration) => {
|
|
489
|
+
const superType = declaration.getSuperType();
|
|
490
|
+
if (superType) {
|
|
491
|
+
const subclasses = subclassMap.get(superType) || new Set();
|
|
492
|
+
subclasses.add(declaration);
|
|
493
|
+
subclassMap.set(superType, subclasses);
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
const superType = this.getFullyQualifiedName();
|
|
498
|
+
const subclasses = subclassMap.get(superType);
|
|
499
|
+
|
|
500
|
+
if (subclasses) {
|
|
501
|
+
return Array.from(subclasses);
|
|
502
|
+
}
|
|
503
|
+
return [];
|
|
504
|
+
}
|
|
505
|
+
|
|
477
506
|
/**
|
|
478
507
|
* Get all the super-type declarations for this type.
|
|
479
508
|
* @return {ClassDeclaration[]} super-type declarations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accordproject/concerto-core",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1-20220527104623",
|
|
4
4
|
"description": "Core Implementation for the Concerto Modeling Language",
|
|
5
5
|
"homepage": "https://github.com/accordproject/concerto",
|
|
6
6
|
"engines": {
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"yargs": "17.3.1"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@accordproject/concerto-cto": "2.1
|
|
69
|
-
"@accordproject/concerto-metamodel": "2.1
|
|
70
|
-
"@accordproject/concerto-util": "2.1
|
|
68
|
+
"@accordproject/concerto-cto": "2.2.1-20220527104623",
|
|
69
|
+
"@accordproject/concerto-metamodel": "2.2.1-20220527104623",
|
|
70
|
+
"@accordproject/concerto-util": "2.2.1-20220527104623",
|
|
71
71
|
"dayjs": "1.10.8",
|
|
72
72
|
"debug": "4.3.1",
|
|
73
73
|
"lorem-ipsum": "2.0.3",
|
|
@@ -137,6 +137,11 @@ declare class ClassDeclaration extends Decorated {
|
|
|
137
137
|
* @return {ClassDeclaration[]} subclass declarations.
|
|
138
138
|
*/
|
|
139
139
|
getAssignableClassDeclarations(): ClassDeclaration[];
|
|
140
|
+
/**
|
|
141
|
+
* Get the class declarations for just the direct subclasses of this class, excluding this class.
|
|
142
|
+
* @return {ClassDeclaration[]} direct subclass declarations.
|
|
143
|
+
*/
|
|
144
|
+
getDirectSubclasses(): ClassDeclaration[];
|
|
140
145
|
/**
|
|
141
146
|
* Get all the super-type declarations for this type.
|
|
142
147
|
* @return {ClassDeclaration[]} super-type declarations.
|