@accordproject/concerto-core 2.0.0-alpha.1 → 2.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/changelog.txt +2 -1
- package/index.js +73 -33
- package/lib/basemodelmanager.js +35 -8
- package/lib/decoratormanager.js +118 -0
- package/lib/factory.js +9 -1
- package/lib/introspect/assetdeclaration.js +8 -0
- package/lib/introspect/classdeclaration.js +10 -1
- package/lib/introspect/conceptdeclaration.js +8 -0
- package/lib/introspect/decorated.js +11 -2
- package/lib/introspect/decorator.js +9 -0
- package/lib/introspect/decoratorfactory.js +10 -0
- package/lib/introspect/enumdeclaration.js +8 -0
- package/lib/introspect/enumvaluedeclaration.js +8 -0
- package/lib/introspect/eventdeclaration.js +8 -0
- package/lib/introspect/field.js +8 -0
- package/lib/introspect/identifieddeclaration.js +8 -0
- package/lib/introspect/illegalmodelexception.js +9 -1
- package/lib/introspect/introspector.js +9 -0
- package/lib/introspect/metamodel.js +1 -1
- package/lib/introspect/modelfile.js +9 -0
- package/lib/introspect/numbervalidator.js +8 -0
- package/lib/introspect/participantdeclaration.js +8 -0
- package/lib/introspect/property.js +9 -1
- package/lib/introspect/relationshipdeclaration.js +9 -1
- package/lib/introspect/stringvalidator.js +8 -0
- package/lib/introspect/transactiondeclaration.js +8 -0
- package/lib/introspect/validator.js +8 -0
- package/lib/model/identifiable.js +1 -1
- package/lib/model/relationship.js +8 -0
- package/lib/model/typed.js +11 -2
- package/lib/rootmodel.js +3 -1
- package/lib/securityexception.js +1 -1
- package/lib/serializer.js +11 -1
- package/lib/typenotfoundexception.js +2 -2
- package/messages/en.json +48 -48
- package/package.json +7 -5
- package/types/index.d.ts +39 -33
- package/types/lib/basemodelmanager.d.ts +295 -0
- package/types/lib/decoratormanager.d.ts +41 -0
- package/types/lib/factory.d.ts +1 -0
- package/types/lib/introspect/assetdeclaration.d.ts +7 -0
- package/types/lib/introspect/classdeclaration.d.ts +11 -0
- package/types/lib/introspect/conceptdeclaration.d.ts +6 -0
- package/types/lib/introspect/decorated.d.ts +4 -2
- package/types/lib/introspect/decorator.d.ts +5 -3
- package/types/lib/introspect/decoratorfactory.d.ts +4 -1
- package/types/lib/introspect/enumdeclaration.d.ts +6 -0
- package/types/lib/introspect/eventdeclaration.d.ts +7 -0
- package/types/lib/introspect/illegalmodelexception.d.ts +3 -2
- package/types/lib/introspect/introspector.d.ts +2 -0
- package/types/lib/introspect/metamodel.d.ts +16 -50
- package/types/lib/introspect/modelfile.d.ts +2 -0
- package/types/lib/introspect/participantdeclaration.d.ts +7 -0
- package/types/lib/introspect/property.d.ts +8 -0
- package/types/lib/introspect/transactiondeclaration.d.ts +7 -0
- package/types/lib/introspect/validator.d.ts +1 -0
- package/types/lib/model/identifiable.d.ts +2 -2
- package/types/lib/model/relationship.d.ts +17 -0
- package/types/lib/model/resource.d.ts +7 -0
- package/types/lib/model/typed.d.ts +6 -4
- package/types/lib/modelmanager.d.ts +8 -230
- package/types/lib/rootmodel.d.ts +4 -0
- package/types/lib/securityexception.d.ts +2 -2
- package/types/lib/serializer/validationexception.d.ts +3 -2
- package/types/lib/serializer.d.ts +3 -0
- package/types/lib/typenotfoundexception.d.ts +4 -4
- package/umd/concerto.js +1 -1
- package/umd/concerto.js.LICENSE.txt +1 -1
package/changelog.txt
CHANGED
|
@@ -24,13 +24,14 @@
|
|
|
24
24
|
# Note that the latest public API is documented using JSDocs and is available in api.txt.
|
|
25
25
|
#
|
|
26
26
|
|
|
27
|
-
Version
|
|
27
|
+
Version 2.0.0-alpha.1 {292b93fc879d3b0c3969711b24312ffd} 2022-03-30
|
|
28
28
|
- Remove custom instanceof and add methods to check runtime type
|
|
29
29
|
- Remove support for Node 12
|
|
30
30
|
- Generate Typescript definitions from JSDoc
|
|
31
31
|
- Parser directly constructs metamodel instance
|
|
32
32
|
- Convert MetaModel to a class for Typescript + Webpack compatability
|
|
33
33
|
- Update Acorn to latest and refactor the JavaScript parser so we can use static class members
|
|
34
|
+
- Add DecoratorManager
|
|
34
35
|
- New packages for parsing and metamodel, distinct from core
|
|
35
36
|
- Revisions to model manager API to support various inputs (e.g., CTO or AST)
|
|
36
37
|
- New vocabulary package for handling model vocabularies
|
package/index.js
CHANGED
|
@@ -22,71 +22,111 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
// Exceptions
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const SecurityException = require('./lib/securityexception');
|
|
26
|
+
const IllegalModelException = require('./lib/introspect/illegalmodelexception');
|
|
27
|
+
const TypeNotFoundException = require('./lib/typenotfoundexception');
|
|
28
28
|
|
|
29
29
|
// Decorated
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const Decorator = require('./lib/introspect/decorator');
|
|
31
|
+
const DecoratorFactory = require('./lib/introspect/decoratorfactory');
|
|
32
32
|
|
|
33
33
|
// ClassDeclarations
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
const ClassDeclaration = require('./lib/introspect/classdeclaration');
|
|
35
|
+
const IdentifiedDeclaration = require('./lib/introspect/identifieddeclaration');
|
|
36
|
+
const AssetDeclaration = require('./lib/introspect/assetdeclaration');
|
|
37
|
+
const ConceptDeclaration = require('./lib/introspect/conceptdeclaration');
|
|
38
|
+
const EnumValueDeclaration = require('./lib/introspect/enumvaluedeclaration');
|
|
39
|
+
const EventDeclaration = require('./lib/introspect/eventdeclaration');
|
|
40
|
+
const ParticipantDeclaration = require('./lib/introspect/participantdeclaration');
|
|
41
|
+
const TransactionDeclaration = require('./lib/introspect/transactiondeclaration');
|
|
42
42
|
|
|
43
43
|
// Properties
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const Property = require('./lib/introspect/property');
|
|
45
|
+
const Field = require('./lib/introspect/field');
|
|
46
|
+
const EnumDeclaration = require('./lib/introspect/enumdeclaration');
|
|
47
|
+
const RelationshipDeclaration = require('./lib/introspect/relationshipdeclaration');
|
|
48
48
|
|
|
49
49
|
// Typed
|
|
50
|
-
|
|
50
|
+
const Typed = require('./lib/model/typed');
|
|
51
51
|
|
|
52
52
|
// Identifiables
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const Identifiable = require('./lib/model/identifiable');
|
|
54
|
+
const Relationship = require('./lib/model/relationship');
|
|
55
|
+
const Resource = require('./lib/model/resource');
|
|
56
56
|
|
|
57
57
|
// Factory
|
|
58
|
-
|
|
58
|
+
const Factory = require('./lib/factory');
|
|
59
59
|
|
|
60
60
|
// Globalize
|
|
61
|
-
|
|
61
|
+
const Globalize = require('./lib/globalize');
|
|
62
62
|
|
|
63
63
|
// Introspector
|
|
64
|
-
|
|
64
|
+
const Introspector = require('./lib/introspect/introspector');
|
|
65
65
|
|
|
66
66
|
// ModelFile
|
|
67
|
-
|
|
67
|
+
const ModelFile = require('./lib/introspect/modelfile');
|
|
68
68
|
|
|
69
69
|
// ModelManager
|
|
70
|
-
|
|
70
|
+
const ModelManager = require('./lib/modelmanager');
|
|
71
71
|
|
|
72
72
|
// Serializer
|
|
73
|
-
|
|
73
|
+
const Serializer = require('./lib/serializer');
|
|
74
74
|
|
|
75
75
|
// ModelUtil
|
|
76
|
-
|
|
76
|
+
const ModelUtil = require('./lib/modelutil');
|
|
77
77
|
|
|
78
78
|
// ModelLoader
|
|
79
|
-
|
|
79
|
+
const ModelLoader = require('./lib/modelloader');
|
|
80
80
|
|
|
81
|
+
// DecoratorManager
|
|
82
|
+
const DecoratorManager = require('./lib/decoratormanager');
|
|
81
83
|
|
|
82
84
|
// DateTimeUtil
|
|
83
|
-
|
|
85
|
+
const DateTimeUtil = require('./lib/datetimeutil');
|
|
84
86
|
|
|
85
87
|
// Concerto
|
|
86
|
-
|
|
88
|
+
const Concerto = require('./lib/concerto');
|
|
87
89
|
|
|
88
90
|
// MetaModel
|
|
89
|
-
|
|
91
|
+
const MetaModel = require('./lib/introspect/metamodel');
|
|
90
92
|
|
|
91
93
|
// Version
|
|
92
|
-
|
|
94
|
+
/** @type {{ name: string, version: string }} */
|
|
95
|
+
const version = require('./package.json');
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
SecurityException,
|
|
99
|
+
IllegalModelException,
|
|
100
|
+
TypeNotFoundException,
|
|
101
|
+
Decorator,
|
|
102
|
+
DecoratorFactory,
|
|
103
|
+
DecoratorManager,
|
|
104
|
+
ClassDeclaration,
|
|
105
|
+
IdentifiedDeclaration,
|
|
106
|
+
AssetDeclaration,
|
|
107
|
+
ConceptDeclaration,
|
|
108
|
+
EnumValueDeclaration,
|
|
109
|
+
EventDeclaration,
|
|
110
|
+
ParticipantDeclaration,
|
|
111
|
+
TransactionDeclaration,
|
|
112
|
+
Property,
|
|
113
|
+
Field,
|
|
114
|
+
EnumDeclaration,
|
|
115
|
+
RelationshipDeclaration,
|
|
116
|
+
Typed,
|
|
117
|
+
Identifiable,
|
|
118
|
+
Relationship,
|
|
119
|
+
Resource,
|
|
120
|
+
Factory,
|
|
121
|
+
Globalize,
|
|
122
|
+
Introspector,
|
|
123
|
+
ModelFile,
|
|
124
|
+
ModelManager,
|
|
125
|
+
Serializer,
|
|
126
|
+
ModelUtil,
|
|
127
|
+
ModelLoader,
|
|
128
|
+
DateTimeUtil,
|
|
129
|
+
Concerto,
|
|
130
|
+
MetaModel,
|
|
131
|
+
version
|
|
132
|
+
};
|
package/lib/basemodelmanager.js
CHANGED
|
@@ -16,10 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
const fsPath = require('path');
|
|
18
18
|
|
|
19
|
-
const DefaultFileLoader = require('@accordproject/concerto-util')
|
|
20
|
-
const
|
|
21
|
-
const ModelWriter = require('@accordproject/concerto-util').ModelWriter;
|
|
22
|
-
const MetaModelUtil = require('@accordproject/concerto-metamodel').MetaModelUtil;
|
|
19
|
+
const { DefaultFileLoader, FileDownloader, ModelWriter } = require('@accordproject/concerto-util');
|
|
20
|
+
const { MetaModelUtil } = require('@accordproject/concerto-metamodel');
|
|
23
21
|
|
|
24
22
|
const Factory = require('./factory');
|
|
25
23
|
const Globalize = require('./globalize');
|
|
@@ -30,6 +28,21 @@ const Serializer = require('./serializer');
|
|
|
30
28
|
const TypeNotFoundException = require('./typenotfoundexception');
|
|
31
29
|
const { rootModelFile, rootModelCto, rootModelAst } = require('./rootmodel');
|
|
32
30
|
|
|
31
|
+
// Types needed for TypeScript generation.
|
|
32
|
+
/* eslint-disable no-unused-vars */
|
|
33
|
+
/* istanbul ignore next */
|
|
34
|
+
if (global === undefined) {
|
|
35
|
+
const AssetDeclaration = require('./introspect/assetdeclaration');
|
|
36
|
+
const ClassDeclaration = require('./introspect/classdeclaration');
|
|
37
|
+
const ConceptDeclaration = require('./introspect/conceptdeclaration');
|
|
38
|
+
const DecoratorFactory = require('./introspect/decoratorfactory');
|
|
39
|
+
const EnumDeclaration = require('./introspect/enumdeclaration');
|
|
40
|
+
const EventDeclaration = require('./introspect/eventdeclaration');
|
|
41
|
+
const ParticipantDeclaration = require('./introspect/participantdeclaration');
|
|
42
|
+
const TransactionDeclaration = require('./introspect/transactiondeclaration');
|
|
43
|
+
}
|
|
44
|
+
/* eslint-enable no-unused-vars */
|
|
45
|
+
|
|
33
46
|
const debug = require('debug')('concerto:BaseModelManager');
|
|
34
47
|
|
|
35
48
|
// How to create a modelfile from the external content
|
|
@@ -315,19 +328,20 @@ class BaseModelManager {
|
|
|
315
328
|
fileDownloader = new FileDownloader(new DefaultFileLoader(this.processFile), (file) => MetaModelUtil.getExternalImports(file.ast));
|
|
316
329
|
}
|
|
317
330
|
|
|
318
|
-
const
|
|
331
|
+
const externalModels = await fileDownloader.downloadExternalDependencies(this.getModelFiles(), options);
|
|
319
332
|
const originalModelFiles = {};
|
|
320
333
|
Object.assign(originalModelFiles, this.modelFiles);
|
|
321
334
|
|
|
322
335
|
try {
|
|
323
|
-
externalModelFiles
|
|
336
|
+
const externalModelFiles = [];
|
|
337
|
+
externalModels.forEach((file) => {
|
|
324
338
|
const mf = new ModelFile(this, file.ast, file.definitions, file.fileName);
|
|
325
339
|
const existing = this.modelFiles[mf.getNamespace()];
|
|
326
340
|
|
|
327
341
|
if (existing) {
|
|
328
|
-
this.updateModelFile(mf, mf.getName(), true); // disable validation
|
|
342
|
+
externalModelFiles.push(this.updateModelFile(mf, mf.getName(), true)); // disable validation
|
|
329
343
|
} else {
|
|
330
|
-
this.addModelFile(mf, null, mf.getName(), true); // disable validation
|
|
344
|
+
externalModelFiles.push(this.addModelFile(mf, null, mf.getName(), true)); // disable validation
|
|
331
345
|
}
|
|
332
346
|
});
|
|
333
347
|
|
|
@@ -629,6 +643,19 @@ class BaseModelManager {
|
|
|
629
643
|
return MetaModelUtil.resolveLocalNames(priorModels, metaModel);
|
|
630
644
|
}
|
|
631
645
|
|
|
646
|
+
/**
|
|
647
|
+
* Populates the model manager from a models metamodel AST
|
|
648
|
+
* @param {*} ast the metamodel
|
|
649
|
+
*/
|
|
650
|
+
fromAst(ast) {
|
|
651
|
+
this.clearModelFiles();
|
|
652
|
+
ast.models.forEach( model => {
|
|
653
|
+
const modelFile = new ModelFile( this, model );
|
|
654
|
+
this.addModelFile( modelFile, null, null, true );
|
|
655
|
+
});
|
|
656
|
+
this.validateModelFiles();
|
|
657
|
+
}
|
|
658
|
+
|
|
632
659
|
/**
|
|
633
660
|
* Get the full ast (metamodel instances) for a modelmanager
|
|
634
661
|
* @param {boolean} [resolve] - whether to resolve names
|
|
@@ -0,0 +1,118 @@
|
|
|
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 ModelManager = require('./modelmanager');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Utility functions to work with
|
|
21
|
+
* [DecoratorCommandSet](https://models.accordproject.org/concerto/decorators.cto)
|
|
22
|
+
* @memberof module:concerto-core
|
|
23
|
+
*/
|
|
24
|
+
class DecoratorManager {
|
|
25
|
+
/**
|
|
26
|
+
* Applies all the decorator commands from the DecoratorCommandSet
|
|
27
|
+
* to the ModelManager.
|
|
28
|
+
* @param {ModelManager} modelManager the input model manager
|
|
29
|
+
* @param {*} decoratorCommandSet the DecoratorCommandSet object
|
|
30
|
+
* @returns {ModelManager} a new model manager with the decorations applied
|
|
31
|
+
*/
|
|
32
|
+
static decorateModels(modelManager, decoratorCommandSet) {
|
|
33
|
+
const ast = modelManager.getAst(true);
|
|
34
|
+
const decoratedAst = JSON.parse(JSON.stringify(ast));
|
|
35
|
+
decoratedAst.models.forEach(model => {
|
|
36
|
+
model.declarations.forEach(decl => {
|
|
37
|
+
decoratorCommandSet.commands.forEach(command => {
|
|
38
|
+
this.executeCommand(model.namespace, decl, command);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
const newModelManager = new ModelManager();
|
|
43
|
+
newModelManager.fromAst(decoratedAst);
|
|
44
|
+
return newModelManager;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Compares two values. If the first argument is falsy
|
|
49
|
+
* the function returns true.
|
|
50
|
+
* @param {string | null} test the value to test (lhs)
|
|
51
|
+
* @param {string} value the value to compare (rhs)
|
|
52
|
+
* @returns {Boolean} true if the lhs is falsy or test === value
|
|
53
|
+
*/
|
|
54
|
+
static falsyOrEqual(test, value) {
|
|
55
|
+
return test ? test === value : true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Applies a decorator to a decorated model element.
|
|
60
|
+
* @param {*} decorated the type to apply the decorator to
|
|
61
|
+
* @param {string} type the command type
|
|
62
|
+
* @param {*} newDecorator the decorator to add
|
|
63
|
+
*/
|
|
64
|
+
static applyDecorator(decorated, type, newDecorator) {
|
|
65
|
+
if (type === 'UPSERT') {
|
|
66
|
+
let updated = false;
|
|
67
|
+
if(decorated.decorators) {
|
|
68
|
+
for (let n = 0; n < decorated.decorators.length; n++) {
|
|
69
|
+
let decorator = decorated.decorators[n];
|
|
70
|
+
if (decorator.name === newDecorator.name) {
|
|
71
|
+
decorated.decorators[n] = newDecorator;
|
|
72
|
+
updated = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!updated) {
|
|
78
|
+
decorated.decorators ? decorated.decorators.push(newDecorator)
|
|
79
|
+
: decorated.decorators = [newDecorator];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (type === 'APPEND') {
|
|
83
|
+
decorated.decorators ? decorated.decorators.push(newDecorator)
|
|
84
|
+
: decorated.decorators = [newDecorator];
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error(`Unknown command type ${type}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Executes a Command against a ClassDeclaration, adding
|
|
93
|
+
* decorators to the ClassDeclaration, or its properties, as required.
|
|
94
|
+
* @param {string} namespace the namespace for the declaration
|
|
95
|
+
* @param {*} declaration the class declaration
|
|
96
|
+
* @param {*} command the Command object from the
|
|
97
|
+
* org.accordproject.decoratorcommands model
|
|
98
|
+
*/
|
|
99
|
+
static executeCommand(namespace, declaration, command) {
|
|
100
|
+
const { target, decorator, type } = command;
|
|
101
|
+
if (this.falsyOrEqual(target.namespace, namespace) &&
|
|
102
|
+
this.falsyOrEqual(target.declaration, declaration.name)) {
|
|
103
|
+
if (!target.property && !target.type) {
|
|
104
|
+
this.applyDecorator(declaration, type, decorator);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
declaration.properties.forEach(property => {
|
|
108
|
+
if (this.falsyOrEqual(target.property, property.name) &&
|
|
109
|
+
this.falsyOrEqual(target.type, property.$class)) {
|
|
110
|
+
this.applyDecorator(property, type, decorator);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = DecoratorManager;
|
package/lib/factory.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const TypedStack = require('@accordproject/concerto-util')
|
|
17
|
+
const { TypedStack } = require('@accordproject/concerto-util');
|
|
18
18
|
|
|
19
19
|
const debug = require('debug')('concerto:Factory');
|
|
20
20
|
const Globalize = require('./globalize');
|
|
@@ -35,6 +35,14 @@ const dayjs = require('dayjs');
|
|
|
35
35
|
const utc = require('dayjs/plugin/utc');
|
|
36
36
|
dayjs.extend(utc);
|
|
37
37
|
|
|
38
|
+
// Types needed for TypeScript generation.
|
|
39
|
+
/* eslint-disable no-unused-vars */
|
|
40
|
+
/* istanbul ignore next */
|
|
41
|
+
if (global === undefined) {
|
|
42
|
+
const ModelManager = require('./modelmanager');
|
|
43
|
+
}
|
|
44
|
+
/* eslint-enable no-unused-vars */
|
|
45
|
+
|
|
38
46
|
/**
|
|
39
47
|
* Use the Factory to create instances of Resource: transactions, participants
|
|
40
48
|
* and assets.
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const IdentifiedDeclaration = require('./identifieddeclaration');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ModelFile = require('./modelfile');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* AssetDeclaration defines the schema (aka model or class) for
|
|
21
29
|
* an Asset. It extends ClassDeclaration which manages a set of
|
|
@@ -23,6 +23,15 @@ const Introspector = require('./introspector');
|
|
|
23
23
|
const ModelUtil = require('../modelutil');
|
|
24
24
|
const RelationshipDeclaration = require('./relationshipdeclaration');
|
|
25
25
|
|
|
26
|
+
// Types needed for TypeScript generation.
|
|
27
|
+
/* eslint-disable no-unused-vars */
|
|
28
|
+
/* istanbul ignore next */
|
|
29
|
+
if (global === undefined) {
|
|
30
|
+
const ModelFile = require('./modelfile');
|
|
31
|
+
const Property = require('./property');
|
|
32
|
+
}
|
|
33
|
+
/* eslint-enable no-unused-vars */
|
|
34
|
+
|
|
26
35
|
/**
|
|
27
36
|
* ClassDeclaration defines the structure (model/schema) of composite data.
|
|
28
37
|
* It is composed of a set of Properties, may have an identifying field, and may
|
|
@@ -184,7 +193,7 @@ class ClassDeclaration extends Decorated {
|
|
|
184
193
|
* contents/relations of fields.
|
|
185
194
|
*
|
|
186
195
|
* @throws {IllegalModelException}
|
|
187
|
-
* @
|
|
196
|
+
* @protected
|
|
188
197
|
*/
|
|
189
198
|
validate() {
|
|
190
199
|
super.validate();
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const ClassDeclaration = require('./classdeclaration');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ModelFile = require('./modelfile');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* ConceptDeclaration defines the schema (aka model or class) for
|
|
21
29
|
* an Concept. It extends ClassDeclaration which manages a set of
|
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
const Decorator = require('./decorator');
|
|
18
18
|
const IllegalModelException = require('./illegalmodelexception');
|
|
19
19
|
|
|
20
|
+
// Types needed for TypeScript generation.
|
|
21
|
+
/* eslint-disable no-unused-vars */
|
|
22
|
+
/* istanbul ignore next */
|
|
23
|
+
if (global === undefined) {
|
|
24
|
+
const ModelFile = require('./modelfile');
|
|
25
|
+
}
|
|
26
|
+
/* eslint-enable no-unused-vars */
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
29
|
* Decorated defines a model element that may have decorators attached.
|
|
22
30
|
*
|
|
@@ -99,10 +107,11 @@ class Decorated {
|
|
|
99
107
|
* override this method to impose additional semantic constraints on the
|
|
100
108
|
* contents/relations of fields.
|
|
101
109
|
*
|
|
110
|
+
* @param {...*} args the validation arguments
|
|
102
111
|
* @throws {IllegalModelException}
|
|
103
|
-
* @
|
|
112
|
+
* @protected
|
|
104
113
|
*/
|
|
105
|
-
validate() {
|
|
114
|
+
validate(...args) {
|
|
106
115
|
for(let n=0; n < this.decorators.length; n++) {
|
|
107
116
|
let decorator = this.decorators[n];
|
|
108
117
|
decorator.validate();
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
+
// Types needed for TypeScript generation.
|
|
18
|
+
/* eslint-disable no-unused-vars */
|
|
19
|
+
/* istanbul ignore next */
|
|
20
|
+
if (global === undefined) {
|
|
21
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
22
|
+
const Property = require('./property');
|
|
23
|
+
}
|
|
24
|
+
/* eslint-enable no-unused-vars */
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Decorator encapsulates a decorator (annotation) on a class or property.
|
|
19
28
|
* @class
|
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
+
// Types needed for TypeScript generation.
|
|
18
|
+
/* eslint-disable no-unused-vars */
|
|
19
|
+
/* istanbul ignore next */
|
|
20
|
+
if (global === undefined) {
|
|
21
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
22
|
+
const Decorator = require('./decorator');
|
|
23
|
+
const Property = require('./property');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* An interface for a class that processes a decorator and returns a specific
|
|
19
29
|
* implementation class for that decorator.
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const ClassDeclaration = require('./classdeclaration');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ModelFile = require('./modelfile');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* EnumDeclaration defines an enumeration of static values.
|
|
21
29
|
*
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const Property = require('./property');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* Class representing a value from a set of enumerated values
|
|
21
29
|
*
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const IdentifiedDeclaration = require('./identifieddeclaration');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ModelFile = require('./modelfile');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/** Class representing the definition of an Event.
|
|
20
28
|
* @extends ClassDeclaration
|
|
21
29
|
* @see See {@link ClassDeclaration}
|
package/lib/introspect/field.js
CHANGED
|
@@ -18,6 +18,14 @@ const Property = require('./property');
|
|
|
18
18
|
const NumberValidator = require('./numbervalidator');
|
|
19
19
|
const StringValidator = require('./stringvalidator');
|
|
20
20
|
|
|
21
|
+
// Types needed for TypeScript generation.
|
|
22
|
+
/* eslint-disable no-unused-vars */
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
if (global === undefined) {
|
|
25
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
26
|
+
}
|
|
27
|
+
/* eslint-enable no-unused-vars */
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* Class representing the definition of a Field. A Field is owned
|
|
23
31
|
* by a ClassDeclaration and has a name, type and additional metadata
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const ClassDeclaration = require('./classdeclaration');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ModelFile = require('./modelfile');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* IdentifiedDeclaration
|
|
21
29
|
*
|
|
@@ -14,7 +14,15 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const BaseFileException = require('@accordproject/concerto-util')
|
|
17
|
+
const { BaseFileException } = require('@accordproject/concerto-util');
|
|
18
|
+
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const ModelFile = require('./modelfile');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
18
26
|
|
|
19
27
|
/**
|
|
20
28
|
* Exception throws when a composer file is semantically invalid
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
+
// Types needed for TypeScript generation.
|
|
18
|
+
/* eslint-disable no-unused-vars */
|
|
19
|
+
/* istanbul ignore next */
|
|
20
|
+
if (global === undefined) {
|
|
21
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
22
|
+
const ModelManager = require('../modelmanager');
|
|
23
|
+
}
|
|
24
|
+
/* eslint-enable no-unused-vars */
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
*
|
|
19
28
|
* Provides access to the structure of transactions, assets and participants.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const MetaModelUtil = require('@accordproject/concerto-metamodel')
|
|
17
|
+
const { MetaModelUtil } = require('@accordproject/concerto-metamodel');
|
|
18
18
|
|
|
19
19
|
const ModelManager = require('../modelmanager');
|
|
20
20
|
const Factory = require('../factory');
|
|
@@ -26,6 +26,15 @@ const IllegalModelException = require('./illegalmodelexception');
|
|
|
26
26
|
const ModelUtil = require('../modelutil');
|
|
27
27
|
const Globalize = require('../globalize');
|
|
28
28
|
|
|
29
|
+
// Types needed for TypeScript generation.
|
|
30
|
+
/* eslint-disable no-unused-vars */
|
|
31
|
+
/* istanbul ignore next */
|
|
32
|
+
if (global === undefined) {
|
|
33
|
+
const ClassDeclaration = require('./classdeclaration');
|
|
34
|
+
const ModelManager = require('../modelmanager');
|
|
35
|
+
}
|
|
36
|
+
/* eslint-enable no-unused-vars */
|
|
37
|
+
|
|
29
38
|
/**
|
|
30
39
|
* Class representing a Model File. A Model File contains a single namespace
|
|
31
40
|
* and a set of model elements: assets, transactions etc.
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
const Validator = require('./validator');
|
|
18
18
|
|
|
19
|
+
// Types needed for TypeScript generation.
|
|
20
|
+
/* eslint-disable no-unused-vars */
|
|
21
|
+
/* istanbul ignore next */
|
|
22
|
+
if (global === undefined) {
|
|
23
|
+
const Field = require('./field');
|
|
24
|
+
}
|
|
25
|
+
/* eslint-enable no-unused-vars */
|
|
26
|
+
|
|
19
27
|
/**
|
|
20
28
|
* A Validator to enforce that non null numeric values are between two values.
|
|
21
29
|
* @private
|