@accordproject/concerto-core 3.1.0 → 3.2.0
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 +1 -1
- package/dist/concerto-core.js +1 -1
- package/dist/concerto-core.js.LICENSE.txt +1 -1
- package/lib/introspect/classdeclaration.js +6 -1
- package/lib/introspect/field.js +91 -10
- package/lib/introspect/introspector.js +5 -1
- package/lib/introspect/modelfile.js +30 -6
- package/lib/introspect/numbervalidator.js +2 -1
- package/lib/introspect/property.js +22 -14
- package/lib/introspect/scalardeclaration.js +341 -0
- package/lib/introspect/stringvalidator.js +2 -1
- package/lib/introspect/validator.js +6 -6
- package/lib/model/typed.js +25 -20
- package/lib/modelutil.js +12 -0
- package/lib/serializer/instancegenerator.js +15 -11
- package/lib/serializer/jsongenerator.js +2 -0
- package/lib/serializer/jsonpopulator.js +3 -2
- package/lib/serializer/objectvalidator.js +2 -0
- package/lib/serializer/resourcevalidator.js +2 -0
- package/package.json +9 -7
- package/types/lib/introspect/field.d.ts +15 -2
- package/types/lib/introspect/modelfile.d.ts +8 -2
- package/types/lib/introspect/scalardeclaration.d.ts +162 -0
- package/types/lib/introspect/validator.d.ts +6 -7
- package/types/lib/modelutil.d.ts +7 -0
|
@@ -21,6 +21,7 @@ const Validator = require('./validator');
|
|
|
21
21
|
/* istanbul ignore next */
|
|
22
22
|
if (global === undefined) {
|
|
23
23
|
const Field = require('./field');
|
|
24
|
+
const ScalarDeclaration = require('./scalardeclaration');
|
|
24
25
|
}
|
|
25
26
|
/* eslint-enable no-unused-vars */
|
|
26
27
|
|
|
@@ -34,7 +35,7 @@ class StringValidator extends Validator{
|
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Create a StringValidator.
|
|
37
|
-
* @param {
|
|
38
|
+
* @param {Object} field - the field or scalar declaration this validator is attached to
|
|
38
39
|
* @param {Object} validator - The validation string. This must be a regex
|
|
39
40
|
*
|
|
40
41
|
* @throws {IllegalModelException}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
/* istanbul ignore next */
|
|
20
20
|
if (global === undefined) {
|
|
21
21
|
const Field = require('./field');
|
|
22
|
+
const ScalarDeclaration = require('./scalardeclaration');
|
|
22
23
|
}
|
|
23
24
|
/* eslint-enable no-unused-vars */
|
|
24
25
|
|
|
@@ -31,10 +32,9 @@ if (global === undefined) {
|
|
|
31
32
|
* @memberof module:concerto-core
|
|
32
33
|
*/
|
|
33
34
|
class Validator {
|
|
34
|
-
|
|
35
35
|
/**
|
|
36
36
|
* Create a Property.
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {Object} field - the field or scalar declaration this validator is attached to
|
|
38
38
|
* @param {Object} validator - The validation string
|
|
39
39
|
* @throws {IllegalModelException}
|
|
40
40
|
*/
|
|
@@ -49,7 +49,7 @@ class Validator {
|
|
|
49
49
|
* @throws {Error} throws an error to report the message
|
|
50
50
|
*/
|
|
51
51
|
reportError(id, msg) {
|
|
52
|
-
throw new Error( 'Validator error for field `' + id + '`. ' + this.
|
|
52
|
+
throw new Error( 'Validator error for field `' + id + '`. ' + this.getFieldOrScalarDeclaration().getFullyQualifiedName() + ': ' + msg );
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -64,10 +64,10 @@ class Validator {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* Returns the field that this validator applies to
|
|
68
|
-
* @return {
|
|
67
|
+
* Returns the field or scalar declaration that this validator applies to
|
|
68
|
+
* @return {Object} the field
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
getFieldOrScalarDeclaration() {
|
|
71
71
|
return this.field;
|
|
72
72
|
}
|
|
73
73
|
|
package/lib/model/typed.js
CHANGED
|
@@ -143,27 +143,32 @@ class Typed {
|
|
|
143
143
|
|
|
144
144
|
for (let n = 0; n < fields.length; n++) {
|
|
145
145
|
let field = fields[n];
|
|
146
|
+
if(field.isTypeScalar?.()) {
|
|
147
|
+
field = field.getScalarField();
|
|
148
|
+
}
|
|
149
|
+
let defaultValue;
|
|
150
|
+
let type;
|
|
146
151
|
if (field.isField?.()) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
152
|
+
defaultValue = field.getDefaultValue();
|
|
153
|
+
type = field.getType();
|
|
154
|
+
}
|
|
155
|
+
if (defaultValue) {
|
|
156
|
+
if (type === 'String') {
|
|
157
|
+
this.setPropertyValue(field.getName(), defaultValue);
|
|
158
|
+
} else if (type === 'Integer') {
|
|
159
|
+
this.setPropertyValue(field.getName(), parseInt(defaultValue));
|
|
160
|
+
} else if (type === 'Long') {
|
|
161
|
+
this.setPropertyValue(field.getName(), parseInt(defaultValue));
|
|
162
|
+
} else if (type === 'Double') {
|
|
163
|
+
this.setPropertyValue(field.getName(), parseFloat(defaultValue));
|
|
164
|
+
} else if (type === 'Boolean') {
|
|
165
|
+
this.setPropertyValue(field.getName(), (defaultValue === true));
|
|
166
|
+
} else if (type === 'DateTime') {
|
|
167
|
+
const dateTime = dayjs.utc(defaultValue);
|
|
168
|
+
this.setPropertyValue(field.getName(), dateTime);
|
|
169
|
+
} else {
|
|
170
|
+
// following precident set in jsonpopulator.js - if we get this far the field should be an enum
|
|
171
|
+
this.setPropertyValue(field.getName(), defaultValue);
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
}
|
package/lib/modelutil.js
CHANGED
|
@@ -172,6 +172,18 @@ class ModelUtil {
|
|
|
172
172
|
return (typeDeclaration !== null && typeDeclaration.isEnum());
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Returns the true if the given field is a Scalar type
|
|
177
|
+
* @param {Scalar} scalar - the string
|
|
178
|
+
* @return {boolean} true if the field is declared as an scalar
|
|
179
|
+
* @private
|
|
180
|
+
*/
|
|
181
|
+
static isScalar(scalar) {
|
|
182
|
+
const modelFile = scalar.getParent().getModelFile();
|
|
183
|
+
const declaration = modelFile.getType(scalar.getType());
|
|
184
|
+
return (declaration !== null && declaration.isScalarDeclaration?.());
|
|
185
|
+
}
|
|
186
|
+
|
|
175
187
|
/**
|
|
176
188
|
* Get the fully qualified name of a type.
|
|
177
189
|
* @param {string} namespace - namespace of the type.
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const ModelUtil = require('../modelutil');
|
|
18
17
|
const Util = require('../util');
|
|
19
18
|
const Globalize = require('../globalize');
|
|
20
19
|
|
|
@@ -40,6 +39,8 @@ class InstanceGenerator {
|
|
|
40
39
|
return this.visitClassDeclaration(thing, parameters);
|
|
41
40
|
} else if (thing.isRelationship?.()) {
|
|
42
41
|
return this.visitRelationshipDeclaration(thing, parameters);
|
|
42
|
+
} else if (thing.isTypeScalar?.()) {
|
|
43
|
+
return this.visitField(thing.getScalarField(), parameters);
|
|
43
44
|
} else if (thing.isField?.()) {
|
|
44
45
|
return this.visitField(thing, parameters);
|
|
45
46
|
} else {
|
|
@@ -114,32 +115,35 @@ class InstanceGenerator {
|
|
|
114
115
|
* @return {*} A value for the specified field.
|
|
115
116
|
*/
|
|
116
117
|
getFieldValue(field, parameters) {
|
|
118
|
+
let fieldOrScalarDeclaration = field;
|
|
119
|
+
if (field.isTypeScalar?.()){
|
|
120
|
+
fieldOrScalarDeclaration = field.getScalarField();
|
|
121
|
+
}
|
|
117
122
|
let type = field.getFullyQualifiedTypeName();
|
|
118
|
-
|
|
119
|
-
if (ModelUtil.isPrimitiveType(type)) {
|
|
123
|
+
if (field.isPrimitive()) {
|
|
120
124
|
switch(type) {
|
|
121
125
|
case 'DateTime':
|
|
122
126
|
return parameters.valueGenerator.getDateTime();
|
|
123
127
|
case 'Integer':
|
|
124
|
-
if(
|
|
125
|
-
return parameters.valueGenerator.getRange(
|
|
128
|
+
if(fieldOrScalarDeclaration.validator){
|
|
129
|
+
return parameters.valueGenerator.getRange(fieldOrScalarDeclaration.validator.lowerBound, fieldOrScalarDeclaration.validator.upperBound, type);
|
|
126
130
|
}
|
|
127
131
|
return parameters.valueGenerator.getInteger();
|
|
128
132
|
case 'Long':
|
|
129
|
-
if(
|
|
130
|
-
return parameters.valueGenerator.getRange(
|
|
133
|
+
if(fieldOrScalarDeclaration.validator){
|
|
134
|
+
return parameters.valueGenerator.getRange(fieldOrScalarDeclaration.validator.lowerBound, fieldOrScalarDeclaration.validator.upperBound, type);
|
|
131
135
|
}
|
|
132
136
|
return parameters.valueGenerator.getLong();
|
|
133
137
|
case 'Double':
|
|
134
|
-
if(
|
|
135
|
-
return parameters.valueGenerator.getRange(
|
|
138
|
+
if(fieldOrScalarDeclaration.validator){
|
|
139
|
+
return parameters.valueGenerator.getRange(fieldOrScalarDeclaration.validator.lowerBound, fieldOrScalarDeclaration.validator.upperBound, type);
|
|
136
140
|
}
|
|
137
141
|
return parameters.valueGenerator.getDouble();
|
|
138
142
|
case 'Boolean':
|
|
139
143
|
return parameters.valueGenerator.getBoolean();
|
|
140
144
|
default:
|
|
141
|
-
if(
|
|
142
|
-
return parameters.valueGenerator.getRegex(
|
|
145
|
+
if(fieldOrScalarDeclaration.validator){
|
|
146
|
+
return parameters.valueGenerator.getRegex(fieldOrScalarDeclaration.validator.regex);
|
|
143
147
|
}
|
|
144
148
|
return parameters.valueGenerator.getString();
|
|
145
149
|
}
|
|
@@ -66,6 +66,8 @@ class JSONGenerator {
|
|
|
66
66
|
return this.visitClassDeclaration(thing, parameters);
|
|
67
67
|
} else if (thing.isRelationship?.()) {
|
|
68
68
|
return this.visitRelationshipDeclaration(thing, parameters);
|
|
69
|
+
} else if (thing.isTypeScalar?.()) {
|
|
70
|
+
return this.visitField(thing.getScalarField(), parameters);
|
|
69
71
|
} else if (thing.isField?.()) {
|
|
70
72
|
return this.visitField(thing, parameters);
|
|
71
73
|
} else {
|
|
@@ -108,6 +108,8 @@ class JSONPopulator {
|
|
|
108
108
|
return this.visitClassDeclaration(thing, parameters);
|
|
109
109
|
} else if (thing.isRelationship?.()) {
|
|
110
110
|
return this.visitRelationshipDeclaration(thing, parameters);
|
|
111
|
+
} else if (thing.isTypeScalar?.()) {
|
|
112
|
+
return this.visitField(thing.getScalarField(), parameters);
|
|
111
113
|
} else if (thing.isField?.()) {
|
|
112
114
|
return this.visitField(thing, parameters);
|
|
113
115
|
} else {
|
|
@@ -175,8 +177,7 @@ class JSONPopulator {
|
|
|
175
177
|
result.push(this.convertItem(field,jsonItem, parameters));
|
|
176
178
|
parameters.path.pop();
|
|
177
179
|
}
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
+
} else {
|
|
180
181
|
result = this.convertItem(field,jsonObj, parameters);
|
|
181
182
|
}
|
|
182
183
|
|
|
@@ -74,6 +74,8 @@ class ObjectValidator {
|
|
|
74
74
|
return this.visitClassDeclaration(thing, parameters);
|
|
75
75
|
} else if (thing.isRelationship?.()) {
|
|
76
76
|
return this.visitRelationshipDeclaration(thing, parameters);
|
|
77
|
+
} else if (thing.isTypeScalar?.()) {
|
|
78
|
+
return this.visitField(thing.getScalarField(), parameters);
|
|
77
79
|
} else if (thing.isField?.()) {
|
|
78
80
|
return this.visitField(thing, parameters);
|
|
79
81
|
}
|
|
@@ -69,6 +69,8 @@ class ResourceValidator {
|
|
|
69
69
|
return this.visitClassDeclaration(thing, parameters);
|
|
70
70
|
} else if (thing.isRelationship?.()) {
|
|
71
71
|
return this.visitRelationshipDeclaration(thing, parameters);
|
|
72
|
+
} else if (thing.isTypeScalar?.()) {
|
|
73
|
+
return this.visitField(thing.getScalarField(), parameters);
|
|
72
74
|
} else if (thing.isField?.()) {
|
|
73
75
|
return this.visitField(thing, parameters);
|
|
74
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accordproject/concerto-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Core Implementation for the Concerto Modeling Language",
|
|
5
5
|
"homepage": "https://github.com/accordproject/concerto",
|
|
6
6
|
"engines": {
|
|
@@ -11,18 +11,20 @@
|
|
|
11
11
|
"browser": "dist/concerto-core.js",
|
|
12
12
|
"typings": "types/index.d.ts",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"prepublishOnly": "
|
|
14
|
+
"prepublishOnly": "npm run webpack",
|
|
15
15
|
"pretest": "npm run lint",
|
|
16
16
|
"lint": "eslint .",
|
|
17
17
|
"postlint": "npm run licchk",
|
|
18
18
|
"licchk": "license-check-and-add",
|
|
19
19
|
"postlicchk": "npm run doc",
|
|
20
20
|
"doc": "jsdoc --pedantic --recurse -c jsdoc.json",
|
|
21
|
-
"postdoc": "npm run build:types",
|
|
22
21
|
"test": "node ./scripts/api-changelog.js && nyc mocha --recursive -t 10000",
|
|
23
22
|
"test:watch": "nyc mocha --watch --recursive -t 10000",
|
|
24
23
|
"mocha": "mocha --recursive -t 10000",
|
|
25
24
|
"nyc": "nyc mocha --recursive -t 10000",
|
|
25
|
+
"build": "npm run build:types",
|
|
26
|
+
"postbuild": "npm run webpack",
|
|
27
|
+
"webpack": "webpack --config webpack.config.js --mode production",
|
|
26
28
|
"build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types"
|
|
27
29
|
},
|
|
28
30
|
"repository": {
|
|
@@ -68,9 +70,9 @@
|
|
|
68
70
|
"yargs": "17.3.1"
|
|
69
71
|
},
|
|
70
72
|
"dependencies": {
|
|
71
|
-
"@accordproject/concerto-cto": "3.
|
|
72
|
-
"@accordproject/concerto-metamodel": "3.
|
|
73
|
-
"@accordproject/concerto-util": "3.
|
|
73
|
+
"@accordproject/concerto-cto": "3.2.0",
|
|
74
|
+
"@accordproject/concerto-metamodel": "3.2.0",
|
|
75
|
+
"@accordproject/concerto-util": "3.2.0",
|
|
74
76
|
"dayjs": "1.10.8",
|
|
75
77
|
"debug": "4.3.1",
|
|
76
78
|
"lorem-ipsum": "2.0.3",
|
|
@@ -140,7 +142,7 @@
|
|
|
140
142
|
"all": true,
|
|
141
143
|
"check-coverage": true,
|
|
142
144
|
"statements": 99,
|
|
143
|
-
"branches":
|
|
145
|
+
"branches": 97,
|
|
144
146
|
"functions": 98,
|
|
145
147
|
"lines": 99
|
|
146
148
|
}
|
|
@@ -10,7 +10,8 @@ export = Field;
|
|
|
10
10
|
* @memberof module:concerto-core
|
|
11
11
|
*/
|
|
12
12
|
declare class Field extends Property {
|
|
13
|
-
|
|
13
|
+
scalarField: any;
|
|
14
|
+
validator: StringValidator | NumberValidator;
|
|
14
15
|
defaultValue: any;
|
|
15
16
|
/**
|
|
16
17
|
* Returns the validator string for this field
|
|
@@ -28,8 +29,20 @@ declare class Field extends Property {
|
|
|
28
29
|
* @return {boolean} true if the class is a field
|
|
29
30
|
*/
|
|
30
31
|
isField(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if the field's type is a scalar
|
|
34
|
+
* @returns {boolean} true if the field is a scalar type
|
|
35
|
+
*/
|
|
36
|
+
isTypeScalar(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Unboxes a field that references a scalar type to an
|
|
39
|
+
* underlying Field definition.
|
|
40
|
+
* @throws {Error} throws an error if this field is not a scalar type.
|
|
41
|
+
* @returns {Field} the primitive field for this scalar
|
|
42
|
+
*/
|
|
43
|
+
getScalarField(): Field;
|
|
31
44
|
}
|
|
32
45
|
import Property = require("./property");
|
|
33
|
-
import NumberValidator = require("./numbervalidator");
|
|
34
46
|
import StringValidator = require("./stringvalidator");
|
|
47
|
+
import NumberValidator = require("./numbervalidator");
|
|
35
48
|
import Validator = require("./validator");
|
|
@@ -211,12 +211,17 @@ declare class ModelFile extends Decorated {
|
|
|
211
211
|
* @return {EnumDeclaration[]} the EnumDeclaration defined in the model file
|
|
212
212
|
*/
|
|
213
213
|
getEnumDeclarations(): EnumDeclaration[];
|
|
214
|
+
/**
|
|
215
|
+
* Get the ScalarDeclaration defined in this ModelFile
|
|
216
|
+
* @return {ScalarDeclaration[]} the ScalarDeclaration defined in the model file
|
|
217
|
+
*/
|
|
218
|
+
getScalarDeclarations(): ScalarDeclaration[];
|
|
214
219
|
/**
|
|
215
220
|
* Get the instances of a given type in this ModelFile
|
|
216
221
|
* @param {Function} type - the type of the declaration
|
|
217
|
-
* @return {
|
|
222
|
+
* @return {Object[]} the ClassDeclaration defined in the model file
|
|
218
223
|
*/
|
|
219
|
-
getDeclarations(type: Function):
|
|
224
|
+
getDeclarations(type: Function): any[];
|
|
220
225
|
/**
|
|
221
226
|
* Get all declarations in this ModelFile
|
|
222
227
|
* @return {ClassDeclaration[]} the ClassDeclarations defined in the model file
|
|
@@ -264,3 +269,4 @@ import EventDeclaration = require("./eventdeclaration");
|
|
|
264
269
|
import ParticipantDeclaration = require("./participantdeclaration");
|
|
265
270
|
import ConceptDeclaration = require("./conceptdeclaration");
|
|
266
271
|
import EnumDeclaration = require("./enumdeclaration");
|
|
272
|
+
import ScalarDeclaration = require("./scalardeclaration");
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export = ScalarDeclaration;
|
|
2
|
+
/**
|
|
3
|
+
* ScalarDeclaration defines the structure (model/schema) of composite data.
|
|
4
|
+
* It is composed of a set of Properties, may have an identifying field, and may
|
|
5
|
+
* have a super-type.
|
|
6
|
+
* A ScalarDeclaration is conceptually owned by a ModelFile which
|
|
7
|
+
* defines all the classes that are part of a namespace.
|
|
8
|
+
*
|
|
9
|
+
* @abstract
|
|
10
|
+
* @class
|
|
11
|
+
* @memberof module:concerto-core
|
|
12
|
+
*/
|
|
13
|
+
declare class ScalarDeclaration extends Decorated {
|
|
14
|
+
/**
|
|
15
|
+
* Create a ScalarDeclaration from an Abstract Syntax Tree. The AST is the
|
|
16
|
+
* result of parsing.
|
|
17
|
+
*
|
|
18
|
+
* @param {ModelFile} modelFile - the ModelFile for this class
|
|
19
|
+
* @param {Object} ast - the AST created by the parser
|
|
20
|
+
* @throws {IllegalModelException}
|
|
21
|
+
*/
|
|
22
|
+
constructor(modelFile: ModelFile, ast: any);
|
|
23
|
+
modelFile: ModelFile;
|
|
24
|
+
name: any;
|
|
25
|
+
superType: any;
|
|
26
|
+
superTypeDeclaration: any;
|
|
27
|
+
idField: any;
|
|
28
|
+
timestamped: boolean;
|
|
29
|
+
abstract: boolean;
|
|
30
|
+
validator: StringValidator | NumberValidator;
|
|
31
|
+
type: string;
|
|
32
|
+
defaultValue: any;
|
|
33
|
+
fqn: string;
|
|
34
|
+
/**
|
|
35
|
+
* Semantic validation of the structure of this class. Subclasses should
|
|
36
|
+
* override this method to impose additional semantic constraints on the
|
|
37
|
+
* contents/relations of fields.
|
|
38
|
+
*
|
|
39
|
+
* @throws {IllegalModelException}
|
|
40
|
+
* @protected
|
|
41
|
+
*/
|
|
42
|
+
protected validate(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the short name of a class. This name does not include the
|
|
45
|
+
* namespace from the owning ModelFile.
|
|
46
|
+
*
|
|
47
|
+
* @return {string} the short name of this class
|
|
48
|
+
*/
|
|
49
|
+
getName(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Return the namespace of this class.
|
|
52
|
+
* @return {string} namespace - a namespace.
|
|
53
|
+
*/
|
|
54
|
+
getNamespace(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the fully qualified name of this class.
|
|
57
|
+
* The name will include the namespace if present.
|
|
58
|
+
*
|
|
59
|
+
* @return {string} the fully-qualified name of this class
|
|
60
|
+
*/
|
|
61
|
+
getFullyQualifiedName(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Returns false as scalars are never identified.
|
|
64
|
+
* @returns {Boolean} false as scalars are never identified
|
|
65
|
+
*/
|
|
66
|
+
isIdentified(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Returns false as scalars are never identified.
|
|
69
|
+
* @returns {Boolean} false as scalars are never identified
|
|
70
|
+
*/
|
|
71
|
+
isSystemIdentified(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Returns null as scalars are never identified.
|
|
74
|
+
* @return {null} null, as scalars are never identified
|
|
75
|
+
*/
|
|
76
|
+
getIdentifierFieldName(): null;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the FQN of the super type for this class or null if this
|
|
79
|
+
* class does not have a super type.
|
|
80
|
+
*
|
|
81
|
+
* @return {string} the FQN name of the super type or null
|
|
82
|
+
*/
|
|
83
|
+
getType(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Throws an error as scalars do not have supertypes.
|
|
86
|
+
*/
|
|
87
|
+
getSuperType(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Get the super type class declaration for this class.
|
|
90
|
+
* @return {ScalarDeclaration | null} the super type declaration, or null if there is no super type.
|
|
91
|
+
*/
|
|
92
|
+
getSuperTypeDeclaration(): ScalarDeclaration | null;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the validator string for this scalar definition
|
|
95
|
+
* @return {Validator} the validator for the field or null
|
|
96
|
+
*/
|
|
97
|
+
getValidator(): Validator;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the default value for the field or null
|
|
100
|
+
* @return {string | number | null} the default value for the field or null
|
|
101
|
+
*/
|
|
102
|
+
getDefaultValue(): string | number | null;
|
|
103
|
+
/**
|
|
104
|
+
* Returns true if this class is abstract.
|
|
105
|
+
*
|
|
106
|
+
* @return {boolean} true if the class is abstract
|
|
107
|
+
*/
|
|
108
|
+
isAbstract(): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Returns true if this class is the definition of an asset.
|
|
111
|
+
*
|
|
112
|
+
* @return {boolean} true if the class is an asset
|
|
113
|
+
*/
|
|
114
|
+
isAsset(): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Returns true if this class is the definition of a participant.
|
|
117
|
+
*
|
|
118
|
+
* @return {boolean} true if the class is a participant
|
|
119
|
+
*/
|
|
120
|
+
isParticipant(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Returns true if this class is the definition of a transaction.
|
|
123
|
+
*
|
|
124
|
+
* @return {boolean} true if the class is a transaction
|
|
125
|
+
*/
|
|
126
|
+
isTransaction(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Returns true if this class is the definition of an event.
|
|
129
|
+
*
|
|
130
|
+
* @return {boolean} true if the class is an event
|
|
131
|
+
*/
|
|
132
|
+
isEvent(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Returns true if this class is the definition of a concept.
|
|
135
|
+
*
|
|
136
|
+
* @return {boolean} true if the class is a concept
|
|
137
|
+
*/
|
|
138
|
+
isConcept(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Returns true if this class is the definition of an enum.
|
|
141
|
+
*
|
|
142
|
+
* @return {boolean} true if the class is an enum
|
|
143
|
+
*/
|
|
144
|
+
isEnum(): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Returns true if this class is the definition of a class declaration.
|
|
147
|
+
*
|
|
148
|
+
* @return {boolean} true if the class is a class
|
|
149
|
+
*/
|
|
150
|
+
isClassDeclaration(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Returns true if this class is the definition of a scalar declaration.
|
|
153
|
+
*
|
|
154
|
+
* @return {boolean} true if the class is a scalar
|
|
155
|
+
*/
|
|
156
|
+
isScalarDeclaration(): boolean;
|
|
157
|
+
}
|
|
158
|
+
import Decorated = require("./decorated");
|
|
159
|
+
import ModelFile = require("./modelfile");
|
|
160
|
+
import StringValidator = require("./stringvalidator");
|
|
161
|
+
import NumberValidator = require("./numbervalidator");
|
|
162
|
+
import Validator = require("./validator");
|
|
@@ -10,13 +10,13 @@ export = Validator;
|
|
|
10
10
|
declare class Validator {
|
|
11
11
|
/**
|
|
12
12
|
* Create a Property.
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {Object} field - the field or scalar declaration this validator is attached to
|
|
14
14
|
* @param {Object} validator - The validation string
|
|
15
15
|
* @throws {IllegalModelException}
|
|
16
16
|
*/
|
|
17
|
-
constructor(field:
|
|
17
|
+
constructor(field: any, validator: any);
|
|
18
18
|
validator: any;
|
|
19
|
-
field:
|
|
19
|
+
field: any;
|
|
20
20
|
/**
|
|
21
21
|
* @param {string} id the identifier of the instance
|
|
22
22
|
* @param {string} msg the exception message
|
|
@@ -32,10 +32,10 @@ declare class Validator {
|
|
|
32
32
|
*/
|
|
33
33
|
private accept;
|
|
34
34
|
/**
|
|
35
|
-
* Returns the field that this validator applies to
|
|
36
|
-
* @return {
|
|
35
|
+
* Returns the field or scalar declaration that this validator applies to
|
|
36
|
+
* @return {Object} the field
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
getFieldOrScalarDeclaration(): any;
|
|
39
39
|
/**
|
|
40
40
|
* Validate the property against a value
|
|
41
41
|
* @param {string} identifier the identifier of the instance being validated
|
|
@@ -54,4 +54,3 @@ declare class Validator {
|
|
|
54
54
|
*/
|
|
55
55
|
compatibleWith(other: Validator): boolean;
|
|
56
56
|
}
|
|
57
|
-
import Field = require("./field");
|
package/types/lib/modelutil.d.ts
CHANGED
|
@@ -91,6 +91,13 @@ declare class ModelUtil {
|
|
|
91
91
|
* @private
|
|
92
92
|
*/
|
|
93
93
|
private static isEnum;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the true if the given field is a Scalar type
|
|
96
|
+
* @param {Scalar} scalar - the string
|
|
97
|
+
* @return {boolean} true if the field is declared as an scalar
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
private static isScalar;
|
|
94
101
|
/**
|
|
95
102
|
* Get the fully qualified name of a type.
|
|
96
103
|
* @param {string} namespace - namespace of the type.
|