@accordproject/concerto-core 2.0.0-alpha.2 → 2.0.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.
Files changed (68) hide show
  1. package/changelog.txt +2 -1
  2. package/index.js +73 -33
  3. package/lib/basemodelmanager.js +30 -4
  4. package/lib/decoratormanager.js +118 -0
  5. package/lib/factory.js +9 -1
  6. package/lib/introspect/assetdeclaration.js +8 -0
  7. package/lib/introspect/classdeclaration.js +10 -1
  8. package/lib/introspect/conceptdeclaration.js +8 -0
  9. package/lib/introspect/decorated.js +11 -2
  10. package/lib/introspect/decorator.js +9 -0
  11. package/lib/introspect/decoratorfactory.js +10 -0
  12. package/lib/introspect/enumdeclaration.js +8 -0
  13. package/lib/introspect/enumvaluedeclaration.js +8 -0
  14. package/lib/introspect/eventdeclaration.js +8 -0
  15. package/lib/introspect/field.js +8 -0
  16. package/lib/introspect/identifieddeclaration.js +8 -0
  17. package/lib/introspect/illegalmodelexception.js +9 -1
  18. package/lib/introspect/introspector.js +9 -0
  19. package/lib/introspect/metamodel.js +1 -1
  20. package/lib/introspect/modelfile.js +9 -0
  21. package/lib/introspect/numbervalidator.js +8 -0
  22. package/lib/introspect/participantdeclaration.js +8 -0
  23. package/lib/introspect/property.js +9 -1
  24. package/lib/introspect/relationshipdeclaration.js +9 -1
  25. package/lib/introspect/stringvalidator.js +8 -0
  26. package/lib/introspect/transactiondeclaration.js +8 -0
  27. package/lib/introspect/validator.js +8 -0
  28. package/lib/model/identifiable.js +1 -1
  29. package/lib/model/relationship.js +8 -0
  30. package/lib/model/typed.js +11 -2
  31. package/lib/rootmodel.js +3 -1
  32. package/lib/securityexception.js +1 -1
  33. package/lib/serializer.js +11 -1
  34. package/lib/typenotfoundexception.js +2 -2
  35. package/messages/en.json +48 -48
  36. package/package.json +7 -5
  37. package/types/index.d.ts +39 -33
  38. package/types/lib/basemodelmanager.d.ts +295 -0
  39. package/types/lib/decoratormanager.d.ts +41 -0
  40. package/types/lib/factory.d.ts +1 -0
  41. package/types/lib/introspect/assetdeclaration.d.ts +7 -0
  42. package/types/lib/introspect/classdeclaration.d.ts +11 -0
  43. package/types/lib/introspect/conceptdeclaration.d.ts +6 -0
  44. package/types/lib/introspect/decorated.d.ts +4 -2
  45. package/types/lib/introspect/decorator.d.ts +5 -3
  46. package/types/lib/introspect/decoratorfactory.d.ts +4 -1
  47. package/types/lib/introspect/enumdeclaration.d.ts +6 -0
  48. package/types/lib/introspect/eventdeclaration.d.ts +7 -0
  49. package/types/lib/introspect/illegalmodelexception.d.ts +3 -2
  50. package/types/lib/introspect/introspector.d.ts +2 -0
  51. package/types/lib/introspect/metamodel.d.ts +16 -50
  52. package/types/lib/introspect/modelfile.d.ts +2 -0
  53. package/types/lib/introspect/participantdeclaration.d.ts +7 -0
  54. package/types/lib/introspect/property.d.ts +8 -0
  55. package/types/lib/introspect/transactiondeclaration.d.ts +7 -0
  56. package/types/lib/introspect/validator.d.ts +1 -0
  57. package/types/lib/model/identifiable.d.ts +2 -2
  58. package/types/lib/model/relationship.d.ts +17 -0
  59. package/types/lib/model/resource.d.ts +7 -0
  60. package/types/lib/model/typed.d.ts +6 -4
  61. package/types/lib/modelmanager.d.ts +8 -230
  62. package/types/lib/rootmodel.d.ts +4 -0
  63. package/types/lib/securityexception.d.ts +2 -2
  64. package/types/lib/serializer/validationexception.d.ts +3 -2
  65. package/types/lib/serializer.d.ts +3 -0
  66. package/types/lib/typenotfoundexception.d.ts +4 -4
  67. package/umd/concerto.js +1 -1
  68. package/umd/concerto.js.LICENSE.txt +1 -1
@@ -0,0 +1,295 @@
1
+ export = BaseModelManager;
2
+ /**
3
+ * Manages the Concerto model files.
4
+ *
5
+ * The structure of {@link Resource}s (Assets, Transactions, Participants) is modelled
6
+ * in a set of Concerto files. The contents of these files are managed
7
+ * by the {@link ModelManager}. Each Concerto file has a single namespace and contains
8
+ * a set of asset, transaction and participant type definitions.
9
+ *
10
+ * Concerto applications load their Concerto files and then call the {@link ModelManager#addModelFile addModelFile}
11
+ * method to register the Concerto file(s) with the ModelManager.
12
+ *
13
+ * Use the {@link Concerto} class to validate instances.
14
+ *
15
+ * @memberof module:concerto-core
16
+ */
17
+ declare class BaseModelManager {
18
+ /**
19
+ * Create the ModelManager.
20
+ * @constructor
21
+ * @param {object} [options] - Serializer options
22
+ * @param {*} [processFile] - how to obtain a concerto AST from an input to the model manager
23
+ */
24
+ constructor(options?: object, processFile?: any);
25
+ processFile: any;
26
+ modelFiles: {};
27
+ factory: any;
28
+ serializer: any;
29
+ decoratorFactories: any[];
30
+ /**
31
+ * Returns true
32
+ * @returns {boolean} true
33
+ */
34
+ isModelManager(): boolean;
35
+ /**
36
+ * Adds root types
37
+ * @private
38
+ */
39
+ private addRootModel;
40
+ /**
41
+ * Visitor design pattern
42
+ * @param {Object} visitor - the visitor
43
+ * @param {Object} parameters - the parameter
44
+ * @return {Object} the result of visiting or null
45
+ */
46
+ accept(visitor: any, parameters: any): any;
47
+ /**
48
+ * Validates a Concerto file (as a string) to the ModelManager.
49
+ * Concerto files have a single namespace.
50
+ *
51
+ * Note that if there are dependencies between multiple files the files
52
+ * must be added in dependency order, or the addModelFiles method can be
53
+ * used to add a set of files irrespective of dependencies.
54
+ * @param {string|ModelFile} modelFile - The Concerto file as a string
55
+ * @param {string} [fileName] - a file name to associate with the model file
56
+ * @throws {IllegalModelException}
57
+ */
58
+ validateModelFile(modelFile: string | ModelFile, fileName?: string): void;
59
+ /**
60
+ * Throws an error with details about the existing namespace.
61
+ * @param {ModelFile} modelFile The model file that is trying to declare an existing namespace
62
+ * @private
63
+ */
64
+ private _throwAlreadyExists;
65
+ /**
66
+ * Adds a Concerto file (as an AST) to the ModelManager.
67
+ * Concerto files have a single namespace. If a Concerto file with the
68
+ * same namespace has already been added to the ModelManager then it
69
+ * will be replaced.
70
+ * Note that if there are dependencies between multiple files the files
71
+ * must be added in dependency order, or the addModelFiles method can be
72
+ * used to add a set of files irrespective of dependencies.
73
+ * @param {ModelFile} modelFile - Model as a ModelFile object
74
+ * @param {string} [cto] - an optional cto string
75
+ * @param {string} [fileName] - an optional file name to associate with the model file
76
+ * @param {boolean} [disableValidation] - If true then the model files are not validated
77
+ * @throws {IllegalModelException}
78
+ * @return {Object} The newly added model file (internal).
79
+ */
80
+ addModelFile(modelFile: ModelFile, cto?: string, fileName?: string, disableValidation?: boolean): any;
81
+ /**
82
+ * Adds a model to the ModelManager.
83
+ * Concerto files have a single namespace. If a Concerto file with the
84
+ * same namespace has already been added to the ModelManager then it
85
+ * will be replaced.
86
+ * Note that if there are dependencies between multiple files the files
87
+ * must be added in dependency order, or the addModel method can be
88
+ * used to add a set of files irrespective of dependencies.
89
+ * @param {*} modelInput - Model (as a string or object)
90
+ * @param {string} [cto] - an optional cto string
91
+ * @param {string} [fileName] - an optional file name to associate with the model file
92
+ * @param {boolean} [disableValidation] - If true then the model files are not validated
93
+ * @throws {IllegalModelException}
94
+ * @return {Object} The newly added model file (internal).
95
+ */
96
+ addModel(modelInput: any, cto?: string, fileName?: string, disableValidation?: boolean): any;
97
+ /**
98
+ * Updates a Concerto file (as a string) on the ModelManager.
99
+ * Concerto files have a single namespace. If a Concerto file with the
100
+ * same namespace has already been added to the ModelManager then it
101
+ * will be replaced.
102
+ * @param {string|ModelFile} modelFile - Model as a string or object
103
+ * @param {string} [fileName] - a file name to associate with the model file
104
+ * @param {boolean} [disableValidation] - If true then the model files are not validated
105
+ * @throws {IllegalModelException}
106
+ * @returns {Object} The newly added model file (internal).
107
+ */
108
+ updateModelFile(modelFile: string | ModelFile, fileName?: string, disableValidation?: boolean): any;
109
+ /**
110
+ * Remove the Concerto file for a given namespace
111
+ * @param {string} namespace - The namespace of the model file to delete.
112
+ */
113
+ deleteModelFile(namespace: string): void;
114
+ /**
115
+ * Add a set of Concerto files to the model manager.
116
+ * @param {string[]|ModelFile[]} modelFiles - An array of models as strings or ModelFile objects.
117
+ * @param {string[]} [fileNames] - A array of file names to associate with the model files
118
+ * @param {boolean} [disableValidation] - If true then the model files are not validated
119
+ * @returns {Object[]} The newly added model files (internal).
120
+ */
121
+ addModelFiles(modelFiles: string[] | ModelFile[], fileNames?: string[], disableValidation?: boolean): any[];
122
+ /**
123
+ * Validates all models files in this model manager
124
+ */
125
+ validateModelFiles(): void;
126
+ /**
127
+ * Downloads all ModelFiles that are external dependencies and adds or
128
+ * updates them in this ModelManager.
129
+ * @param {Object} [options] - Options object passed to ModelFileLoaders
130
+ * @param {FileDownloader} [fileDownloader] - an optional FileDownloader
131
+ * @throws {IllegalModelException} if the models fail validation
132
+ * @return {Promise} a promise when the download and update operation is completed.
133
+ */
134
+ updateExternalModels(options?: any, fileDownloader?: FileDownloader): Promise<any>;
135
+ /**
136
+ * Write all models in this model manager to the specified path in the file system
137
+ *
138
+ * @param {string} path to a local directory
139
+ * @param {Object} [options] - Options object
140
+ * @param {boolean} options.includeExternalModels -
141
+ * If true, external models are written to the file system. Defaults to true
142
+ */
143
+ writeModelsToFileSystem(path: string, options?: {
144
+ includeExternalModels: boolean;
145
+ }): void;
146
+ /**
147
+ * Get the array of model file instances
148
+ * @param {Boolean} [includeConcertoNamespace] - whether to include the concerto namespace
149
+ * (default to false)
150
+ * @return {ModelFile[]} The ModelFiles registered
151
+ * @private
152
+ */
153
+ private getModelFiles;
154
+ /**
155
+ * Gets all the Concerto models
156
+ * @param {Object} [options] - Options object
157
+ * @param {boolean} options.includeExternalModels -
158
+ * If true, external models are written to the file system. Defaults to true
159
+ * @return {Array<{name:string, content:string}>} the name and content of each CTO file
160
+ */
161
+ getModels(options?: {
162
+ includeExternalModels: boolean;
163
+ }): Array<{
164
+ name: string;
165
+ content: string;
166
+ }>;
167
+ /**
168
+ * Check that the type is valid and returns the FQN of the type.
169
+ * @param {string} context - error reporting context
170
+ * @param {string} type - fully qualified type name
171
+ * @return {string} - the resolved type name (fully qualified)
172
+ * @throws {IllegalModelException} - if the type is not defined
173
+ * @private
174
+ */
175
+ private resolveType;
176
+ /**
177
+ * Remove all registered Concerto files
178
+ */
179
+ clearModelFiles(): void;
180
+ /**
181
+ * Get the ModelFile associated with a namespace
182
+ *
183
+ * @param {string} namespace - the namespace containing the ModelFile
184
+ * @return {ModelFile} registered ModelFile for the namespace or null
185
+ */
186
+ getModelFile(namespace: string): ModelFile;
187
+ /**
188
+ * Get the ModelFile associated with a file name
189
+ *
190
+ * @param {string} fileName - the fileName associated with the ModelFile
191
+ * @return {ModelFile} registered ModelFile for the namespace or null
192
+ * @private
193
+ */
194
+ private getModelFileByFileName;
195
+ /**
196
+ * Get the namespaces registered with the ModelManager.
197
+ * @return {string[]} namespaces - the namespaces that have been registered.
198
+ */
199
+ getNamespaces(): string[];
200
+ /**
201
+ * Look up a type in all registered namespaces.
202
+ *
203
+ * @param {string} qualifiedName - fully qualified type name.
204
+ * @return {ClassDeclaration} - the class declaration for the specified type.
205
+ * @throws {TypeNotFoundException} - if the type cannot be found or is a primitive type.
206
+ */
207
+ getType(qualifiedName: string): ClassDeclaration;
208
+ /**
209
+ * Get the AssetDeclarations defined in this model manager
210
+ * @return {AssetDeclaration[]} the AssetDeclarations defined in the model manager
211
+ */
212
+ getAssetDeclarations(): AssetDeclaration[];
213
+ /**
214
+ * Get the TransactionDeclarations defined in this model manager
215
+ * @return {TransactionDeclaration[]} the TransactionDeclarations defined in the model manager
216
+ */
217
+ getTransactionDeclarations(): TransactionDeclaration[];
218
+ /**
219
+ * Get the EventDeclarations defined in this model manager
220
+ * @return {EventDeclaration[]} the EventDeclaration defined in the model manager
221
+ */
222
+ getEventDeclarations(): EventDeclaration[];
223
+ /**
224
+ * Get the ParticipantDeclarations defined in this model manager
225
+ * @return {ParticipantDeclaration[]} the ParticipantDeclaration defined in the model manager
226
+ */
227
+ getParticipantDeclarations(): ParticipantDeclaration[];
228
+ /**
229
+ * Get the EnumDeclarations defined in this model manager
230
+ * @return {EnumDeclaration[]} the EnumDeclaration defined in the model manager
231
+ */
232
+ getEnumDeclarations(): EnumDeclaration[];
233
+ /**
234
+ * Get the Concepts defined in this model manager
235
+ * @return {ConceptDeclaration[]} the ConceptDeclaration defined in the model manager
236
+ */
237
+ getConceptDeclarations(): ConceptDeclaration[];
238
+ /**
239
+ * Get a factory for creating new instances of types defined in this model manager.
240
+ * @return {Factory} A factory for creating new instances of types defined in this model manager.
241
+ */
242
+ getFactory(): Factory;
243
+ /**
244
+ * Get a serializer for serializing instances of types defined in this model manager.
245
+ * @return {Serializer} A serializer for serializing instances of types defined in this model manager.
246
+ */
247
+ getSerializer(): Serializer;
248
+ /**
249
+ * Get the decorator factories for this model manager.
250
+ * @return {DecoratorFactory[]} The decorator factories for this model manager.
251
+ */
252
+ getDecoratorFactories(): DecoratorFactory[];
253
+ /**
254
+ * Add a decorator factory to this model manager.
255
+ * @param {DecoratorFactory} factory The decorator factory to add to this model manager.
256
+ */
257
+ addDecoratorFactory(factory: DecoratorFactory): void;
258
+ /**
259
+ * Checks if this fully qualified type name is derived from another.
260
+ * @param {string} fqt1 The fully qualified type name to check.
261
+ * @param {string} fqt2 The fully qualified type name it is may be derived from.
262
+ * @returns {boolean} True if this instance is an instance of the specified fully
263
+ * qualified type name, false otherwise.
264
+ */
265
+ derivesFrom(fqt1: string, fqt2: string): boolean;
266
+ /**
267
+ * Resolve the namespace for names in the metamodel
268
+ * @param {object} metaModel - the MetaModel
269
+ * @return {object} the resolved metamodel
270
+ */
271
+ resolveMetaModel(metaModel: object): object;
272
+ /**
273
+ * Populates the model manager from a models metamodel AST
274
+ * @param {*} ast the metamodel
275
+ */
276
+ fromAst(ast: any): void;
277
+ /**
278
+ * Get the full ast (metamodel instances) for a modelmanager
279
+ * @param {boolean} [resolve] - whether to resolve names
280
+ * @returns {*} the metamodel
281
+ */
282
+ getAst(resolve?: boolean): any;
283
+ }
284
+ import ModelFile = require("./introspect/modelfile");
285
+ import { FileDownloader } from "@accordproject/concerto-util";
286
+ import ClassDeclaration = require("./introspect/classdeclaration");
287
+ import AssetDeclaration = require("./introspect/assetdeclaration");
288
+ import TransactionDeclaration = require("./introspect/transactiondeclaration");
289
+ import EventDeclaration = require("./introspect/eventdeclaration");
290
+ import ParticipantDeclaration = require("./introspect/participantdeclaration");
291
+ import EnumDeclaration = require("./introspect/enumdeclaration");
292
+ import ConceptDeclaration = require("./introspect/conceptdeclaration");
293
+ import Factory = require("./factory");
294
+ import Serializer = require("./serializer");
295
+ import DecoratorFactory = require("./introspect/decoratorfactory");
@@ -0,0 +1,41 @@
1
+ export = DecoratorManager;
2
+ /**
3
+ * Utility functions to work with
4
+ * [DecoratorCommandSet](https://models.accordproject.org/concerto/decorators.cto)
5
+ * @memberof module:concerto-core
6
+ */
7
+ declare class DecoratorManager {
8
+ /**
9
+ * Applies all the decorator commands from the DecoratorCommandSet
10
+ * to the ModelManager.
11
+ * @param {ModelManager} modelManager the input model manager
12
+ * @param {*} decoratorCommandSet the DecoratorCommandSet object
13
+ * @returns {ModelManager} a new model manager with the decorations applied
14
+ */
15
+ static decorateModels(modelManager: ModelManager, decoratorCommandSet: any): ModelManager;
16
+ /**
17
+ * Compares two values. If the first argument is falsy
18
+ * the function returns true.
19
+ * @param {string | null} test the value to test (lhs)
20
+ * @param {string} value the value to compare (rhs)
21
+ * @returns {Boolean} true if the lhs is falsy or test === value
22
+ */
23
+ static falsyOrEqual(test: string | null, value: string): boolean;
24
+ /**
25
+ * Applies a decorator to a decorated model element.
26
+ * @param {*} decorated the type to apply the decorator to
27
+ * @param {string} type the command type
28
+ * @param {*} newDecorator the decorator to add
29
+ */
30
+ static applyDecorator(decorated: any, type: string, newDecorator: any): void;
31
+ /**
32
+ * Executes a Command against a ClassDeclaration, adding
33
+ * decorators to the ClassDeclaration, or its properties, as required.
34
+ * @param {string} namespace the namespace for the declaration
35
+ * @param {*} declaration the class declaration
36
+ * @param {*} command the Command object from the
37
+ * org.accordproject.decoratorcommands model
38
+ */
39
+ static executeCommand(namespace: string, declaration: any, command: any): void;
40
+ }
41
+ import ModelManager = require("./modelmanager");
@@ -131,5 +131,6 @@ declare class Factory {
131
131
  */
132
132
  private parseGenerateOptions;
133
133
  }
134
+ import ModelManager = require("./modelmanager");
134
135
  import Resource = require("./model/resource");
135
136
  import Relationship = require("./model/relationship");
@@ -18,4 +18,11 @@ declare class AssetDeclaration {
18
18
  * @throws {IllegalModelException}
19
19
  */
20
20
  constructor(modelFile: ModelFile, ast: any);
21
+ /**
22
+ * Returns the kind of declaration
23
+ *
24
+ * @return {string} what kind of declaration this is
25
+ */
26
+ declarationKind(): string;
21
27
  }
28
+ import ModelFile = require("./modelfile");
@@ -47,6 +47,15 @@ declare class ClassDeclaration extends Decorated {
47
47
  * @return {ClassDeclaration} The super type, or null if non specified.
48
48
  */
49
49
  _resolveSuperType(): ClassDeclaration;
50
+ /**
51
+ * Semantic validation of the structure of this class. Subclasses should
52
+ * override this method to impose additional semantic constraints on the
53
+ * contents/relations of fields.
54
+ *
55
+ * @throws {IllegalModelException}
56
+ * @protected
57
+ */
58
+ protected validate(): void;
50
59
  /**
51
60
  * Returns true if this class is declared as abstract in the model file
52
61
  *
@@ -198,3 +207,5 @@ declare class ClassDeclaration extends Decorated {
198
207
  isClassDeclaration(): boolean;
199
208
  }
200
209
  import Decorated = require("./decorated");
210
+ import Property = require("./property");
211
+ import ModelFile = require("./modelfile");
@@ -11,5 +11,11 @@ export = ConceptDeclaration;
11
11
  * @memberof module:concerto-core
12
12
  */
13
13
  declare class ConceptDeclaration extends ClassDeclaration {
14
+ /**
15
+ * Returns the kind of declaration
16
+ *
17
+ * @return {string} what kind of declaration this is
18
+ */
19
+ declarationKind(): string;
14
20
  }
15
21
  import ClassDeclaration = require("./classdeclaration");
@@ -46,10 +46,11 @@ declare class Decorated {
46
46
  * override this method to impose additional semantic constraints on the
47
47
  * contents/relations of fields.
48
48
  *
49
+ * @param {...*} args the validation arguments
49
50
  * @throws {IllegalModelException}
50
- * @private
51
+ * @protected
51
52
  */
52
- private validate;
53
+ protected validate(...args: any[]): void;
53
54
  /**
54
55
  * Returns the decorators for this class.
55
56
  *
@@ -63,4 +64,5 @@ declare class Decorated {
63
64
  */
64
65
  getDecorator(name: string): Decorator;
65
66
  }
67
+ import ModelFile = require("./modelfile");
66
68
  import Decorator = require("./decorator");
@@ -11,9 +11,9 @@ declare class Decorator {
11
11
  * @param {Object} ast - The AST created by the parser
12
12
  * @throws {IllegalModelException}
13
13
  */
14
- constructor(parent: ClassDeclaration | Property, ast: any);
14
+ constructor(parent: Property | ClassDeclaration, ast: any);
15
15
  ast: any;
16
- parent: any;
16
+ parent: Property | ClassDeclaration;
17
17
  arguments: any[];
18
18
  /**
19
19
  * Visitor design pattern
@@ -27,7 +27,7 @@ declare class Decorator {
27
27
  * Returns the owner of this property
28
28
  * @return {ClassDeclaration|Property} the parent class or property declaration
29
29
  */
30
- getParent(): ClassDeclaration | Property;
30
+ getParent(): Property | ClassDeclaration;
31
31
  /**
32
32
  * Process the AST and build the model
33
33
  * @throws {IllegalModelException}
@@ -52,3 +52,5 @@ declare class Decorator {
52
52
  */
53
53
  getArguments(): object[];
54
54
  }
55
+ import Property = require("./property");
56
+ import ClassDeclaration = require("./classdeclaration");
@@ -14,5 +14,8 @@ declare class DecoratorFactory {
14
14
  * @param {Object} ast - The AST created by the parser
15
15
  * @return {Decorator} The decorator.
16
16
  */
17
- newDecorator(parent: ClassDeclaration | Property, ast: any): Decorator;
17
+ newDecorator(parent: Property | ClassDeclaration, ast: any): Decorator;
18
18
  }
19
+ import Property = require("./property");
20
+ import ClassDeclaration = require("./classdeclaration");
21
+ import Decorator = require("./decorator");
@@ -8,5 +8,11 @@ export = EnumDeclaration;
8
8
  * @memberof module:concerto-core
9
9
  */
10
10
  declare class EnumDeclaration extends ClassDeclaration {
11
+ /**
12
+ * Returns the kind of declaration
13
+ *
14
+ * @return {string} what kind of declaration this is
15
+ */
16
+ declarationKind(): string;
11
17
  }
12
18
  import ClassDeclaration = require("./classdeclaration");
@@ -20,4 +20,11 @@ declare class EventDeclaration {
20
20
  * @private
21
21
  */
22
22
  private process;
23
+ /**
24
+ * Returns the kind of declaration
25
+ *
26
+ * @return {string} what kind of declaration this is
27
+ */
28
+ declarationKind(): string;
23
29
  }
30
+ import ModelFile = require("./modelfile");
@@ -1,5 +1,4 @@
1
1
  export = IllegalModelException;
2
- declare const IllegalModelException_base: typeof import("@accordproject/concerto-cto/types/lib/basefileexception");
3
2
  /**
4
3
  * Exception throws when a composer file is semantically invalid
5
4
  * @extends BaseFileException
@@ -7,7 +6,7 @@ declare const IllegalModelException_base: typeof import("@accordproject/concerto
7
6
  * @class
8
7
  * @memberof module:concerto-core
9
8
  */
10
- declare class IllegalModelException extends IllegalModelException_base {
9
+ declare class IllegalModelException extends BaseFileException {
11
10
  /**
12
11
  * Create an IllegalModelException.
13
12
  * @param {string} message - the message for the exception
@@ -21,3 +20,5 @@ declare class IllegalModelException extends IllegalModelException_base {
21
20
  */
22
21
  constructor(message: string, modelFile?: ModelFile, fileLocation?: any, component?: string);
23
22
  }
23
+ import { BaseFileException } from "@accordproject/concerto-util";
24
+ import ModelFile = require("./modelfile");
@@ -41,3 +41,5 @@ declare class Introspector {
41
41
  */
42
42
  private getModelManager;
43
43
  }
44
+ import ModelManager = require("../modelmanager");
45
+ import ClassDeclaration = require("./classdeclaration");
@@ -1,52 +1,18 @@
1
- export = MetaModel;
2
1
  /**
3
- * Class to work with the Concerto metamodel
2
+ * Create a metamodel manager (for validation against the metamodel)
3
+ * @return {*} the metamodel manager
4
4
  */
5
- declare class MetaModel {
6
- /**
7
- * Returns the metamodel CTO
8
- * @returns {string} the metamodel as a CTO string
9
- */
10
- static getMetaModelCto(): string;
11
- /**
12
- * Create a metamodel manager (for validation against the metamodel)
13
- * @return {*} the metamodel manager
14
- */
15
- static createMetaModelManager(): any;
16
- /**
17
- * Validate against the metamodel
18
- * @param {object} input - the metamodel in JSON
19
- * @return {object} the validated metamodel in JSON
20
- */
21
- static validateMetaModel(input: object): object;
22
- /**
23
- * Resolve the namespace for names in the metamodel
24
- * @param {object} modelManager - the ModelManager
25
- * @param {object} metaModel - the MetaModel
26
- * @param {boolean} [validate] - whether to perform validation
27
- * @return {object} the resolved metamodel
28
- */
29
- static resolveMetaModel(modelManager: object, metaModel: object, validate?: boolean): object;
30
- /**
31
- * Export metamodel from a model file
32
- * @param {object} modelFile - the ModelFile
33
- * @param {boolean} [validate] - whether to perform validation
34
- * @return {object} the metamodel for this model
35
- */
36
- static modelFileToMetaModel(modelFile: object, validate?: boolean): object;
37
- /**
38
- * Export metamodel from a model manager
39
- * @param {object} modelManager - the ModelManager
40
- * @param {boolean} [resolve] - whether to resolve names
41
- * @param {boolean} [validate] - whether to perform validation
42
- * @return {object} the metamodel for this model manager
43
- */
44
- static modelManagerToMetaModel(modelManager: object, resolve?: boolean, validate?: boolean): object;
45
- /**
46
- * Import metamodel to a model manager
47
- * @param {object} metaModel - the metamodel
48
- * @param {boolean} [validate] - whether to perform validation
49
- * @return {object} the metamodel for this model manager
50
- */
51
- static modelManagerFromMetaModel(metaModel: object, validate?: boolean): object;
52
- }
5
+ export function newMetaModelManager(): any;
6
+ /**
7
+ * Validate metamodel instance against the metamodel
8
+ * @param {object} input - the metamodel instance in JSON
9
+ * @return {object} the validated metamodel instance in JSON
10
+ */
11
+ export function validateMetaModel(input: object): object;
12
+ /**
13
+ * Import metamodel to a model manager
14
+ * @param {object} metaModel - the metamodel
15
+ * @param {boolean} [validate] - whether to perform validation
16
+ * @return {object} the metamodel for this model manager
17
+ */
18
+ export function modelManagerFromMetaModel(metaModel: object, validate?: boolean): object;
@@ -250,6 +250,8 @@ declare class ModelFile {
250
250
  private fromAst;
251
251
  namespace: any;
252
252
  }
253
+ import ModelManager = require("../modelmanager");
254
+ import ClassDeclaration = require("./classdeclaration");
253
255
  import AssetDeclaration = require("./assetdeclaration");
254
256
  import TransactionDeclaration = require("./transactiondeclaration");
255
257
  import EventDeclaration = require("./eventdeclaration");
@@ -14,4 +14,11 @@ declare class ParticipantDeclaration {
14
14
  * @throws {IllegalModelException}
15
15
  */
16
16
  constructor(modelFile: ModelFile, ast: any);
17
+ /**
18
+ * Returns the kind of declaration
19
+ *
20
+ * @return {string} what kind of declaration this is
21
+ */
22
+ declarationKind(): string;
17
23
  }
24
+ import ModelFile = require("./modelfile");
@@ -25,6 +25,13 @@ declare class Property extends Decorated {
25
25
  type: any;
26
26
  array: boolean;
27
27
  optional: boolean;
28
+ /**
29
+ * Validate the property
30
+ * @param {ClassDeclaration} classDecl the class declaration of the property
31
+ * @throws {IllegalModelException}
32
+ * @protected
33
+ */
34
+ protected validate(classDecl: ClassDeclaration): void;
28
35
  /**
29
36
  * Returns the name of a property
30
37
  * @return {string} the name of this field
@@ -72,3 +79,4 @@ declare class Property extends Decorated {
72
79
  isPrimitive(): boolean;
73
80
  }
74
81
  import Decorated = require("./decorated");
82
+ import ClassDeclaration = require("./classdeclaration");
@@ -14,4 +14,11 @@ declare class TransactionDeclaration {
14
14
  * @throws {IllegalModelException}
15
15
  */
16
16
  constructor(modelFile: ModelFile, ast: any);
17
+ /**
18
+ * Returns the kind of declaration
19
+ *
20
+ * @return {string} what kind of declaration this is
21
+ */
22
+ declarationKind(): string;
17
23
  }
24
+ import ModelFile = require("./modelfile");
@@ -45,3 +45,4 @@ declare class Validator {
45
45
  */
46
46
  private validate;
47
47
  }
48
+ import Field = require("./field");
@@ -22,9 +22,9 @@ declare class Identifiable extends Typed {
22
22
  * @param {string} type - The type this instance.
23
23
  * @param {string} id - The identifier of this instance.
24
24
  * @param {string} timestamp - The timestamp of this instance
25
- * @private
25
+ * @protected
26
26
  */
27
- private constructor();
27
+ protected constructor();
28
28
  $identifier: string;
29
29
  $timestamp: string;
30
30
  /**