@accordproject/concerto-core 3.6.0 → 3.6.1-20230308142539
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/index.js +2 -0
- package/lib/basemodelmanager.js +27 -0
- package/lib/introspect/classdeclaration.js +2 -63
- package/lib/introspect/declaration.js +182 -0
- package/lib/introspect/modelfile.js +30 -0
- package/lib/introspect/scalardeclaration.js +33 -93
- package/lib/modelutil.js +4 -4
- package/package.json +4 -4
- package/types/index.d.ts +2 -1
- package/types/lib/basemodelmanager.d.ts +17 -0
- package/types/lib/introspect/classdeclaration.d.ts +2 -65
- package/types/lib/introspect/declaration.d.ts +89 -0
- package/types/lib/introspect/modelfile.d.ts +18 -0
- package/types/lib/introspect/scalardeclaration.d.ts +17 -77
- package/types/lib/modelutil.d.ts +1 -1
package/index.js
CHANGED
|
@@ -39,6 +39,7 @@ const EnumValueDeclaration = require('./lib/introspect/enumvaluedeclaration');
|
|
|
39
39
|
const EventDeclaration = require('./lib/introspect/eventdeclaration');
|
|
40
40
|
const ParticipantDeclaration = require('./lib/introspect/participantdeclaration');
|
|
41
41
|
const TransactionDeclaration = require('./lib/introspect/transactiondeclaration');
|
|
42
|
+
const ScalarDeclaration = require('./lib/introspect/scalardeclaration');
|
|
42
43
|
|
|
43
44
|
// Properties
|
|
44
45
|
const Property = require('./lib/introspect/property');
|
|
@@ -114,6 +115,7 @@ module.exports = {
|
|
|
114
115
|
EventDeclaration,
|
|
115
116
|
ParticipantDeclaration,
|
|
116
117
|
TransactionDeclaration,
|
|
118
|
+
ScalarDeclaration,
|
|
117
119
|
Property,
|
|
118
120
|
Field,
|
|
119
121
|
EnumDeclaration,
|
package/lib/basemodelmanager.js
CHANGED
|
@@ -32,6 +32,7 @@ const { getRootModel } = require('./rootmodel');
|
|
|
32
32
|
/* eslint-disable no-unused-vars */
|
|
33
33
|
/* istanbul ignore next */
|
|
34
34
|
if (global === undefined) {
|
|
35
|
+
const Declaration = require('./introspect/declaration');
|
|
35
36
|
const AssetDeclaration = require('./introspect/assetdeclaration');
|
|
36
37
|
const ClassDeclaration = require('./introspect/classdeclaration');
|
|
37
38
|
const ConceptDeclaration = require('./introspect/conceptdeclaration');
|
|
@@ -709,6 +710,32 @@ class BaseModelManager {
|
|
|
709
710
|
});
|
|
710
711
|
return result;
|
|
711
712
|
}
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* A function type definition for use as an argument to the filter function
|
|
717
|
+
* @callback FilterFunction
|
|
718
|
+
* @param {Declaration} declaration
|
|
719
|
+
* @returns {boolean} true, if the declaration satisfies the filter function
|
|
720
|
+
*/
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Returns a new ModelManager with only the types for which the
|
|
724
|
+
* filter function returns true.
|
|
725
|
+
*
|
|
726
|
+
* ModelFiles with no declarations after filtering will be removed.
|
|
727
|
+
*
|
|
728
|
+
* @param {FilterFunction} predicate - the filter function over a Declaration object
|
|
729
|
+
* @returns {BaseModelManager} - the filtered ModelManager
|
|
730
|
+
*/
|
|
731
|
+
filter(predicate){
|
|
732
|
+
const modelManager = new BaseModelManager({...this.options}, this.processFile);
|
|
733
|
+
const filteredModels = Object.values(this.modelFiles)
|
|
734
|
+
.map((modelFile) => modelFile.filter(predicate, modelManager))
|
|
735
|
+
.filter(Boolean);
|
|
736
|
+
modelManager.addModelFiles(filteredModels);
|
|
737
|
+
return modelManager;
|
|
738
|
+
}
|
|
712
739
|
}
|
|
713
740
|
|
|
714
741
|
module.exports = BaseModelManager;
|
|
@@ -16,20 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
const { MetaModelNamespace } = require('@accordproject/concerto-metamodel');
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const Declaration = require('./declaration');
|
|
20
20
|
const EnumValueDeclaration = require('./enumvaluedeclaration');
|
|
21
21
|
const Field = require('./field');
|
|
22
22
|
const Globalize = require('../globalize');
|
|
23
23
|
const IllegalModelException = require('./illegalmodelexception');
|
|
24
24
|
const Introspector = require('./introspector');
|
|
25
|
-
const ModelUtil = require('../modelutil');
|
|
26
25
|
const RelationshipDeclaration = require('./relationshipdeclaration');
|
|
27
26
|
|
|
28
27
|
// Types needed for TypeScript generation.
|
|
29
28
|
/* eslint-disable no-unused-vars */
|
|
30
29
|
/* istanbul ignore next */
|
|
31
30
|
if (global === undefined) {
|
|
32
|
-
const ModelFile = require('./modelfile');
|
|
33
31
|
const Property = require('./property');
|
|
34
32
|
}
|
|
35
33
|
/* eslint-enable no-unused-vars */
|
|
@@ -45,31 +43,7 @@ if (global === undefined) {
|
|
|
45
43
|
* @class
|
|
46
44
|
* @memberof module:concerto-core
|
|
47
45
|
*/
|
|
48
|
-
class ClassDeclaration extends
|
|
49
|
-
/**
|
|
50
|
-
* Create a ClassDeclaration from an Abstract Syntax Tree. The AST is the
|
|
51
|
-
* result of parsing.
|
|
52
|
-
*
|
|
53
|
-
* @param {ModelFile} modelFile - the ModelFile for this class
|
|
54
|
-
* @param {Object} ast - the AST created by the parser
|
|
55
|
-
* @throws {IllegalModelException}
|
|
56
|
-
*/
|
|
57
|
-
constructor(modelFile, ast) {
|
|
58
|
-
super(ast);
|
|
59
|
-
this.modelFile = modelFile;
|
|
60
|
-
this.process();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns the ModelFile that defines this class.
|
|
65
|
-
*
|
|
66
|
-
* @public
|
|
67
|
-
* @return {ModelFile} the owning ModelFile
|
|
68
|
-
*/
|
|
69
|
-
getModelFile() {
|
|
70
|
-
return this.modelFile;
|
|
71
|
-
}
|
|
72
|
-
|
|
46
|
+
class ClassDeclaration extends Declaration {
|
|
73
47
|
/**
|
|
74
48
|
* Process the AST and build the model
|
|
75
49
|
*
|
|
@@ -79,13 +53,8 @@ class ClassDeclaration extends Decorated {
|
|
|
79
53
|
process() {
|
|
80
54
|
super.process();
|
|
81
55
|
|
|
82
|
-
if (!ModelUtil.isValidIdentifier(this.ast.name)){
|
|
83
|
-
throw new IllegalModelException(`Invalid class name '${this.ast.name}'`, this.modelFile, this.ast.location);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
56
|
const reservedProperties = ['$class', '$identifier', '$timestamp'];
|
|
87
57
|
|
|
88
|
-
this.name = this.ast.name;
|
|
89
58
|
this.properties = [];
|
|
90
59
|
this.superType = null;
|
|
91
60
|
this.superTypeDeclaration = null;
|
|
@@ -143,8 +112,6 @@ class ClassDeclaration extends Decorated {
|
|
|
143
112
|
}
|
|
144
113
|
}
|
|
145
114
|
|
|
146
|
-
this.fqn = ModelUtil.getFullyQualifiedName(this.modelFile.getNamespace(), this.name);
|
|
147
|
-
|
|
148
115
|
if (this.fqn === 'concerto@1.0.0.Transaction' || this.fqn === 'concerto@1.0.0.Event') {
|
|
149
116
|
this.addTimestampField();
|
|
150
117
|
}
|
|
@@ -332,34 +299,6 @@ class ClassDeclaration extends Decorated {
|
|
|
332
299
|
return this.abstract;
|
|
333
300
|
}
|
|
334
301
|
|
|
335
|
-
/**
|
|
336
|
-
* Returns the short name of a class. This name does not include the
|
|
337
|
-
* namespace from the owning ModelFile.
|
|
338
|
-
*
|
|
339
|
-
* @return {string} the short name of this class
|
|
340
|
-
*/
|
|
341
|
-
getName() {
|
|
342
|
-
return this.name;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Return the namespace of this class.
|
|
347
|
-
* @return {string} namespace - a namespace.
|
|
348
|
-
*/
|
|
349
|
-
getNamespace() {
|
|
350
|
-
return this.modelFile.getNamespace();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Returns the fully qualified name of this class.
|
|
355
|
-
* The name will include the namespace if present.
|
|
356
|
-
*
|
|
357
|
-
* @return {string} the fully-qualified name of this class
|
|
358
|
-
*/
|
|
359
|
-
getFullyQualifiedName() {
|
|
360
|
-
return this.fqn;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
302
|
/**
|
|
364
303
|
* Returns true if this class declaration declares an identifying field
|
|
365
304
|
* (system or explicit)
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
* See the License for the specific language governing permissions and
|
|
12
|
+
* limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const Decorated = require('./decorated');
|
|
18
|
+
const ModelUtil = require('../modelutil');
|
|
19
|
+
const IllegalModelException = require('./illegalmodelexception');
|
|
20
|
+
|
|
21
|
+
// Types needed for TypeScript generation.
|
|
22
|
+
/* eslint-disable no-unused-vars */
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
if (global === undefined) {
|
|
25
|
+
const ModelFile = require('./modelfile');
|
|
26
|
+
}
|
|
27
|
+
/* eslint-enable no-unused-vars */
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Declaration defines the structure (model/schema) of composite data.
|
|
31
|
+
* It is composed of a set of Properties, may have an identifying field, and may
|
|
32
|
+
* have a super-type.
|
|
33
|
+
* A Declaration is conceptually owned by a ModelFile which
|
|
34
|
+
* defines all the classes that are part of a namespace.
|
|
35
|
+
*
|
|
36
|
+
* @abstract
|
|
37
|
+
* @class
|
|
38
|
+
* @memberof module:concerto-core
|
|
39
|
+
*/
|
|
40
|
+
class Declaration extends Decorated {
|
|
41
|
+
/**
|
|
42
|
+
* Create a Declaration from an Abstract Syntax Tree. The AST is the
|
|
43
|
+
* result of parsing.
|
|
44
|
+
*
|
|
45
|
+
* @param {ModelFile} modelFile - the ModelFile for this class
|
|
46
|
+
* @param {Object} ast - the AST created by the parser
|
|
47
|
+
* @throws {IllegalModelException}
|
|
48
|
+
*/
|
|
49
|
+
constructor(modelFile, ast) {
|
|
50
|
+
super(ast);
|
|
51
|
+
this.modelFile = modelFile;
|
|
52
|
+
this.process();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Process the AST and build the model
|
|
57
|
+
*
|
|
58
|
+
* @throws {IllegalModelException}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
process() {
|
|
62
|
+
super.process();
|
|
63
|
+
|
|
64
|
+
if (!ModelUtil.isValidIdentifier(this.ast.name)){
|
|
65
|
+
throw new IllegalModelException(`Invalid class name '${this.ast.name}'`, this.modelFile, this.ast.location);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.name = this.ast.name;
|
|
69
|
+
this.fqn = ModelUtil.getFullyQualifiedName(this.modelFile.getNamespace(), this.name);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns the ModelFile that defines this class.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
* @return {ModelFile} the owning ModelFile
|
|
77
|
+
*/
|
|
78
|
+
getModelFile() {
|
|
79
|
+
return this.modelFile;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns the short name of a class. This name does not include the
|
|
84
|
+
* namespace from the owning ModelFile.
|
|
85
|
+
*
|
|
86
|
+
* @return {string} the short name of this class
|
|
87
|
+
*/
|
|
88
|
+
getName() {
|
|
89
|
+
return this.name;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Return the namespace of this class.
|
|
94
|
+
* @return {string} namespace - a namespace.
|
|
95
|
+
*/
|
|
96
|
+
getNamespace() {
|
|
97
|
+
return this.modelFile.getNamespace();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns the fully qualified name of this class.
|
|
102
|
+
* The name will include the namespace if present.
|
|
103
|
+
*
|
|
104
|
+
* @return {string} the fully-qualified name of this class
|
|
105
|
+
*/
|
|
106
|
+
getFullyQualifiedName() {
|
|
107
|
+
return this.fqn;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns false as scalars are never identified.
|
|
112
|
+
* @returns {Boolean} false as scalars are never identified
|
|
113
|
+
*/
|
|
114
|
+
isIdentified() {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns false as scalars are never identified.
|
|
120
|
+
* @returns {Boolean} false as scalars are never identified
|
|
121
|
+
*/
|
|
122
|
+
isSystemIdentified() {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns the name of the identifying field for this class. Note
|
|
128
|
+
* that the identifying field may come from a super type.
|
|
129
|
+
*
|
|
130
|
+
* @return {string} the name of the id field for this class or null if it does not exist
|
|
131
|
+
*/
|
|
132
|
+
getIdentifierFieldName() {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Returns the FQN of the super type for this class or null if this
|
|
138
|
+
* class does not have a super type.
|
|
139
|
+
*
|
|
140
|
+
* @return {string} the FQN name of the super type or null
|
|
141
|
+
*/
|
|
142
|
+
getType() {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Returns the string representation of this class
|
|
148
|
+
* @return {String} the string representation of the class
|
|
149
|
+
*/
|
|
150
|
+
toString() {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Returns true if this class is the definition of an enum.
|
|
156
|
+
*
|
|
157
|
+
* @return {boolean} true if the class is an enum
|
|
158
|
+
*/
|
|
159
|
+
isEnum() {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Returns true if this class is the definition of a class declaration.
|
|
165
|
+
*
|
|
166
|
+
* @return {boolean} true if the class is a class
|
|
167
|
+
*/
|
|
168
|
+
isClassDeclaration() {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Returns true if this class is the definition of a scalar declaration.
|
|
174
|
+
*
|
|
175
|
+
* @return {boolean} true if the class is a scalar
|
|
176
|
+
*/
|
|
177
|
+
isScalarDeclaration() {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = Declaration;
|
|
@@ -36,6 +36,7 @@ const Decorated = require('./decorated');
|
|
|
36
36
|
if (global === undefined) {
|
|
37
37
|
const ClassDeclaration = require('./classdeclaration');
|
|
38
38
|
const ModelManager = require('../modelmanager');
|
|
39
|
+
const Declaration = require('./declaration');
|
|
39
40
|
}
|
|
40
41
|
/* eslint-enable no-unused-vars */
|
|
41
42
|
|
|
@@ -802,6 +803,35 @@ class ModelFile extends Decorated {
|
|
|
802
803
|
}
|
|
803
804
|
}
|
|
804
805
|
|
|
806
|
+
/**
|
|
807
|
+
* A function type definition for use as an argument to the filter function
|
|
808
|
+
* @callback FilterFunction
|
|
809
|
+
* @param {Declaration} declaration
|
|
810
|
+
* @returns {boolean} true, if the declaration satisfies the filter function
|
|
811
|
+
*/
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Returns a new ModelFile with only the types for which the
|
|
815
|
+
* filter function returns true.
|
|
816
|
+
*
|
|
817
|
+
* Will return null if the filtered ModelFile doesn't contain any declarations.
|
|
818
|
+
*
|
|
819
|
+
* @param {FilterFunction} predicate - the filter function over a Declaration object
|
|
820
|
+
* @param {ModelManager} modelManager - the target ModelManager for the filtered ModelFile
|
|
821
|
+
* @returns {ModelFile?} - the filtered ModelFile
|
|
822
|
+
* @private
|
|
823
|
+
*/
|
|
824
|
+
filter(predicate, modelManager){
|
|
825
|
+
const declarations = this.declarations?.filter(predicate).map(declaration => declaration.ast);
|
|
826
|
+
const ast = {
|
|
827
|
+
...this.ast,
|
|
828
|
+
declarations: declarations,
|
|
829
|
+
};
|
|
830
|
+
if (ast.declarations?.length > 0){
|
|
831
|
+
return new ModelFile(modelManager, ast, undefined, this.fileName);
|
|
832
|
+
}
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
805
835
|
}
|
|
806
836
|
|
|
807
837
|
module.exports = ModelFile;
|
|
@@ -16,9 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
const { MetaModelNamespace } = require('@accordproject/concerto-metamodel');
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const Declaration = require('./declaration');
|
|
20
20
|
const IllegalModelException = require('./illegalmodelexception');
|
|
21
|
-
const ModelUtil = require('../modelutil');
|
|
22
21
|
const NumberValidator = require('./numbervalidator');
|
|
23
22
|
const StringValidator = require('./stringvalidator');
|
|
24
23
|
|
|
@@ -26,8 +25,8 @@ const StringValidator = require('./stringvalidator');
|
|
|
26
25
|
/* eslint-disable no-unused-vars */
|
|
27
26
|
/* istanbul ignore next */
|
|
28
27
|
if (global === undefined) {
|
|
29
|
-
const ModelFile = require('./modelfile');
|
|
30
28
|
const Validator = require('./validator');
|
|
29
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
31
30
|
}
|
|
32
31
|
/* eslint-enable no-unused-vars */
|
|
33
32
|
|
|
@@ -42,31 +41,7 @@ if (global === undefined) {
|
|
|
42
41
|
* @class
|
|
43
42
|
* @memberof module:concerto-core
|
|
44
43
|
*/
|
|
45
|
-
class ScalarDeclaration extends
|
|
46
|
-
/**
|
|
47
|
-
* Create a ScalarDeclaration from an Abstract Syntax Tree. The AST is the
|
|
48
|
-
* result of parsing.
|
|
49
|
-
*
|
|
50
|
-
* @param {ModelFile} modelFile - the ModelFile for this class
|
|
51
|
-
* @param {Object} ast - the AST created by the parser
|
|
52
|
-
* @throws {IllegalModelException}
|
|
53
|
-
*/
|
|
54
|
-
constructor(modelFile, ast) {
|
|
55
|
-
super(ast);
|
|
56
|
-
this.modelFile = modelFile;
|
|
57
|
-
this.process();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Returns the ModelFile that defines this class.
|
|
62
|
-
*
|
|
63
|
-
* @public
|
|
64
|
-
* @return {ModelFile} the owning ModelFile
|
|
65
|
-
*/
|
|
66
|
-
getModelFile() {
|
|
67
|
-
return this.modelFile;
|
|
68
|
-
}
|
|
69
|
-
|
|
44
|
+
class ScalarDeclaration extends Declaration {
|
|
70
45
|
/**
|
|
71
46
|
* Process the AST and build the model
|
|
72
47
|
*
|
|
@@ -76,7 +51,6 @@ class ScalarDeclaration extends Decorated {
|
|
|
76
51
|
process() {
|
|
77
52
|
super.process();
|
|
78
53
|
|
|
79
|
-
this.name = this.ast.name;
|
|
80
54
|
this.superType = null;
|
|
81
55
|
this.superTypeDeclaration = null;
|
|
82
56
|
this.idField = null;
|
|
@@ -120,8 +94,6 @@ class ScalarDeclaration extends Decorated {
|
|
|
120
94
|
} else {
|
|
121
95
|
this.defaultValue = null;
|
|
122
96
|
}
|
|
123
|
-
|
|
124
|
-
this.fqn = ModelUtil.getFullyQualifiedName(this.modelFile.getNamespace(), this.name);
|
|
125
97
|
}
|
|
126
98
|
|
|
127
99
|
/**
|
|
@@ -151,37 +123,10 @@ class ScalarDeclaration extends Decorated {
|
|
|
151
123
|
}
|
|
152
124
|
}
|
|
153
125
|
|
|
154
|
-
/**
|
|
155
|
-
* Returns the short name of a class. This name does not include the
|
|
156
|
-
* namespace from the owning ModelFile.
|
|
157
|
-
*
|
|
158
|
-
* @return {string} the short name of this class
|
|
159
|
-
*/
|
|
160
|
-
getName() {
|
|
161
|
-
return this.name;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Return the namespace of this class.
|
|
166
|
-
* @return {string} namespace - a namespace.
|
|
167
|
-
*/
|
|
168
|
-
getNamespace() {
|
|
169
|
-
return this.modelFile.getNamespace();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Returns the fully qualified name of this class.
|
|
174
|
-
* The name will include the namespace if present.
|
|
175
|
-
*
|
|
176
|
-
* @return {string} the fully-qualified name of this class
|
|
177
|
-
*/
|
|
178
|
-
getFullyQualifiedName() {
|
|
179
|
-
return this.fqn;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
126
|
/**
|
|
183
127
|
* Returns false as scalars are never identified.
|
|
184
128
|
* @returns {Boolean} false as scalars are never identified
|
|
129
|
+
* @deprecated
|
|
185
130
|
*/
|
|
186
131
|
isIdentified() {
|
|
187
132
|
return false;
|
|
@@ -190,6 +135,7 @@ class ScalarDeclaration extends Decorated {
|
|
|
190
135
|
/**
|
|
191
136
|
* Returns false as scalars are never identified.
|
|
192
137
|
* @returns {Boolean} false as scalars are never identified
|
|
138
|
+
* @deprecated
|
|
193
139
|
*/
|
|
194
140
|
isSystemIdentified() {
|
|
195
141
|
return false;
|
|
@@ -197,13 +143,13 @@ class ScalarDeclaration extends Decorated {
|
|
|
197
143
|
|
|
198
144
|
/**
|
|
199
145
|
* Returns null as scalars are never identified.
|
|
200
|
-
* @return {
|
|
146
|
+
* @return {string} as scalars are never identified
|
|
147
|
+
* @deprecated
|
|
201
148
|
*/
|
|
202
149
|
getIdentifierFieldName() {
|
|
203
150
|
return null;
|
|
204
151
|
}
|
|
205
152
|
|
|
206
|
-
|
|
207
153
|
/**
|
|
208
154
|
* Returns the FQN of the super type for this class or null if this
|
|
209
155
|
* class does not have a super type.
|
|
@@ -215,15 +161,20 @@ class ScalarDeclaration extends Decorated {
|
|
|
215
161
|
}
|
|
216
162
|
|
|
217
163
|
/**
|
|
218
|
-
*
|
|
164
|
+
* Returns the FQN of the super type for this class or null if this
|
|
165
|
+
* class does not have a super type.
|
|
166
|
+
*
|
|
167
|
+
* @return {string} the FQN name of the super type or null
|
|
168
|
+
* @deprecated
|
|
219
169
|
*/
|
|
220
170
|
getSuperType() {
|
|
221
|
-
|
|
171
|
+
return null;
|
|
222
172
|
}
|
|
223
173
|
|
|
224
174
|
/**
|
|
225
175
|
* Get the super type class declaration for this class.
|
|
226
|
-
* @return {
|
|
176
|
+
* @return {ClassDeclaration} the super type declaration, or null if there is no super type.
|
|
177
|
+
* @deprecated
|
|
227
178
|
*/
|
|
228
179
|
getSuperTypeDeclaration() {
|
|
229
180
|
return null;
|
|
@@ -238,9 +189,9 @@ class ScalarDeclaration extends Decorated {
|
|
|
238
189
|
}
|
|
239
190
|
|
|
240
191
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
192
|
+
* Returns the default value for the field or null
|
|
193
|
+
* @return {string | number | null} the default value for the field or null
|
|
194
|
+
*/
|
|
244
195
|
getDefaultValue() {
|
|
245
196
|
if(this.defaultValue) {
|
|
246
197
|
return this.defaultValue;
|
|
@@ -262,15 +213,26 @@ class ScalarDeclaration extends Decorated {
|
|
|
262
213
|
* Returns true if this class is abstract.
|
|
263
214
|
*
|
|
264
215
|
* @return {boolean} true if the class is abstract
|
|
216
|
+
* @deprecated
|
|
265
217
|
*/
|
|
266
218
|
isAbstract() {
|
|
267
219
|
return true;
|
|
268
220
|
}
|
|
269
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Returns true if this class is the definition of a scalar declaration.
|
|
224
|
+
*
|
|
225
|
+
* @return {boolean} true if the class is a scalar
|
|
226
|
+
*/
|
|
227
|
+
isScalarDeclaration() {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
270
231
|
/**
|
|
271
232
|
* Returns true if this class is the definition of an asset.
|
|
272
233
|
*
|
|
273
234
|
* @return {boolean} true if the class is an asset
|
|
235
|
+
* @deprecated
|
|
274
236
|
*/
|
|
275
237
|
isAsset() {
|
|
276
238
|
return false;
|
|
@@ -280,6 +242,7 @@ class ScalarDeclaration extends Decorated {
|
|
|
280
242
|
* Returns true if this class is the definition of a participant.
|
|
281
243
|
*
|
|
282
244
|
* @return {boolean} true if the class is a participant
|
|
245
|
+
* @deprecated
|
|
283
246
|
*/
|
|
284
247
|
isParticipant() {
|
|
285
248
|
return false;
|
|
@@ -289,6 +252,7 @@ class ScalarDeclaration extends Decorated {
|
|
|
289
252
|
* Returns true if this class is the definition of a transaction.
|
|
290
253
|
*
|
|
291
254
|
* @return {boolean} true if the class is a transaction
|
|
255
|
+
* @deprecated
|
|
292
256
|
*/
|
|
293
257
|
isTransaction() {
|
|
294
258
|
return false;
|
|
@@ -298,6 +262,7 @@ class ScalarDeclaration extends Decorated {
|
|
|
298
262
|
* Returns true if this class is the definition of an event.
|
|
299
263
|
*
|
|
300
264
|
* @return {boolean} true if the class is an event
|
|
265
|
+
* @deprecated
|
|
301
266
|
*/
|
|
302
267
|
isEvent() {
|
|
303
268
|
return false;
|
|
@@ -307,37 +272,12 @@ class ScalarDeclaration extends Decorated {
|
|
|
307
272
|
* Returns true if this class is the definition of a concept.
|
|
308
273
|
*
|
|
309
274
|
* @return {boolean} true if the class is a concept
|
|
275
|
+
* @deprecated
|
|
310
276
|
*/
|
|
311
277
|
isConcept() {
|
|
312
278
|
return false;
|
|
313
279
|
}
|
|
314
280
|
|
|
315
|
-
/**
|
|
316
|
-
* Returns true if this class is the definition of an enum.
|
|
317
|
-
*
|
|
318
|
-
* @return {boolean} true if the class is an enum
|
|
319
|
-
*/
|
|
320
|
-
isEnum() {
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Returns true if this class is the definition of a class declaration.
|
|
326
|
-
*
|
|
327
|
-
* @return {boolean} true if the class is a class
|
|
328
|
-
*/
|
|
329
|
-
isClassDeclaration() {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Returns true if this class is the definition of a scalar declaration.
|
|
335
|
-
*
|
|
336
|
-
* @return {boolean} true if the class is a scalar
|
|
337
|
-
*/
|
|
338
|
-
isScalarDeclaration() {
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
281
|
}
|
|
342
282
|
|
|
343
283
|
module.exports = ScalarDeclaration;
|
package/lib/modelutil.js
CHANGED
|
@@ -174,13 +174,13 @@ class ModelUtil {
|
|
|
174
174
|
|
|
175
175
|
/**
|
|
176
176
|
* Returns the true if the given field is a Scalar type
|
|
177
|
-
* @param {
|
|
177
|
+
* @param {Field} field - the Field to test
|
|
178
178
|
* @return {boolean} true if the field is declared as an scalar
|
|
179
179
|
* @private
|
|
180
180
|
*/
|
|
181
|
-
static isScalar(
|
|
182
|
-
const modelFile =
|
|
183
|
-
const declaration = modelFile.getType(
|
|
181
|
+
static isScalar(field) {
|
|
182
|
+
const modelFile = field.getParent().getModelFile();
|
|
183
|
+
const declaration = modelFile.getType(field.getType());
|
|
184
184
|
return (declaration !== null && declaration.isScalarDeclaration?.());
|
|
185
185
|
}
|
|
186
186
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accordproject/concerto-core",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.1-20230308142539",
|
|
4
4
|
"description": "Core Implementation for the Concerto Modeling Language",
|
|
5
5
|
"homepage": "https://github.com/accordproject/concerto",
|
|
6
6
|
"engines": {
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"yargs": "17.3.1"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@accordproject/concerto-cto": "3.6.
|
|
75
|
-
"@accordproject/concerto-metamodel": "3.6.
|
|
76
|
-
"@accordproject/concerto-util": "3.6.
|
|
74
|
+
"@accordproject/concerto-cto": "3.6.1-20230308142539",
|
|
75
|
+
"@accordproject/concerto-metamodel": "3.6.1-20230308142539",
|
|
76
|
+
"@accordproject/concerto-util": "3.6.1-20230308142539",
|
|
77
77
|
"dayjs": "1.10.8",
|
|
78
78
|
"debug": "4.3.1",
|
|
79
79
|
"lorem-ipsum": "2.0.3",
|