@@ -251,50 +251,6 @@ function getParamTypes(id, methodName) {
251
251
return result ;
252
252
}
253
253
254
- /**
255
- * @method checkResult
256
- * @param {Object } params
257
- * @returns {Boolean } true if conditions on ouput are compliant with the metamodel
258
- * @private
259
- * @description Check if conditions on output are compliant with the metamodel
260
- */
261
- function checkResult ( params ) {
262
- params = params || { } ;
263
-
264
- var component = params . component || null ;
265
- var methodName = params . methodName || '' ;
266
- var methodResult = null ;
267
- var componentClassName = '' ;
268
- var returnType = null ;
269
- var result = true ;
270
-
271
- if ( typeof params . methodResult !== 'undefined' ) {
272
- methodResult = params . methodResult ;
273
- } else {
274
- methodResult = undefined ;
275
- }
276
-
277
- if ( component . constructor . name === 'Function' ) {
278
- componentClassName = component . name ;
279
- } else {
280
- componentClassName = component . constructor . name ;
281
- }
282
-
283
- returnType = getReturnType ( componentClassName , methodName ) ;
284
- if ( ! $metamodel . isValidType ( methodResult , returnType ) ) {
285
- result = false ;
286
- $log . invalidResultType (
287
- component . id ( ) ,
288
- component . constructor . name ,
289
- methodName ,
290
- JSON . stringify ( returnType ) ,
291
- Array . isArray ( methodResult ) ? 'array' : typeof methodResult
292
- ) ;
293
- }
294
-
295
- return result ;
296
- }
297
-
298
254
/**
299
255
* @method getActions
300
256
* @param {Object } component a System Runtime component
@@ -464,14 +420,14 @@ function action(component, state, action, params, isEvent) {
464
420
/* Public methods */
465
421
466
422
/**
467
- * @method validParamNumbers
423
+ * @method checkInputNumbers
468
424
* @param {String } className name the class
469
425
* @param {String } state state on which the action applied
470
426
* @param {Function } action action
471
427
* @returns {Boolean } true if the action is the valid number of parameters
472
428
* @description Check if an action has the valid number of parameter
473
429
*/
474
- exports . validParamNumbers = function validParamNumbers (
430
+ exports . checkInputNumbers = function checkInputNumbers (
475
431
className ,
476
432
state ,
477
433
action
@@ -545,12 +501,12 @@ exports.validParamNumbers = function validParamNumbers(
545
501
} ;
546
502
547
503
/**
548
- * @method checkParams
504
+ * @method checkInput
549
505
* @param {Object } params
550
506
* @returns {Boolean } true if condition on input are compliant with the model
551
507
* @description Check if conditions on input are compliant with the model before calling the action
552
508
*/
553
- exports . checkParams = function checkParams ( params ) {
509
+ exports . checkInput = function checkInput ( params ) {
554
510
params = params || { } ;
555
511
556
512
var component = params . component || null ;
@@ -668,6 +624,49 @@ exports.checkParams = function checkParams(params) {
668
624
return result ;
669
625
} ;
670
626
627
+ /**
628
+ * @method checkOutput
629
+ * @param {Object } params
630
+ * @returns {Boolean } true if conditions on ouput are compliant with the metamodel
631
+ * @description Check if conditions on output are compliant with the metamodel
632
+ */
633
+ exports . checkOutput = function checkOutput ( params ) {
634
+ params = params || { } ;
635
+
636
+ var component = params . component || null ;
637
+ var methodName = params . methodName || '' ;
638
+ var methodResult = null ;
639
+ var componentClassName = '' ;
640
+ var returnType = null ;
641
+ var result = true ;
642
+
643
+ if ( typeof params . methodResult !== 'undefined' ) {
644
+ methodResult = params . methodResult ;
645
+ } else {
646
+ methodResult = undefined ;
647
+ }
648
+
649
+ if ( component . constructor . name === 'Function' ) {
650
+ componentClassName = component . name ;
651
+ } else {
652
+ componentClassName = component . constructor . name ;
653
+ }
654
+
655
+ returnType = getReturnType ( componentClassName , methodName ) ;
656
+ if ( ! $metamodel . isValidType ( methodResult , returnType ) ) {
657
+ result = false ;
658
+ $log . invalidResultType (
659
+ component . id ( ) ,
660
+ component . constructor . name ,
661
+ methodName ,
662
+ JSON . stringify ( returnType ) ,
663
+ Array . isArray ( methodResult ) ? 'array' : typeof methodResult
664
+ ) ;
665
+ }
666
+
667
+ return result ;
668
+ } ;
669
+
671
670
/**
672
671
* @method process
673
672
* @param {Object } params params to process
@@ -768,7 +767,7 @@ exports.process = function process(params) {
768
767
769
768
if ( actions . length ) {
770
769
if (
771
- exports . checkParams ( {
770
+ exports . checkInput ( {
772
771
component : component ,
773
772
methodName : params . state ,
774
773
args : params . data
@@ -783,7 +782,7 @@ exports.process = function process(params) {
783
782
false
784
783
) ;
785
784
786
- checkResult ( {
785
+ exports . checkOutput ( {
787
786
component : component ,
788
787
methodName : params . state ,
789
788
methodResult : result
0 commit comments