@@ -11,8 +11,6 @@ const Utils = require('./utils');
1111class BaseProcess {
1212
1313 constructor ( spec ) {
14- this . spec = spec ; // Keep original specification data
15-
1614 // Make properties easily accessible
1715 Object . assign ( this , spec ) ;
1816
@@ -25,7 +23,7 @@ class BaseProcess {
2523 }
2624
2725 toJSON ( ) {
28- return this . spec ;
26+ return Utils . omitFromObject ( this , [ "validate" , "validateArgument" , "execute" , "test" ] ) ;
2927 }
3028
3129 async validate ( node ) {
@@ -34,6 +32,7 @@ class BaseProcess {
3432 if ( unsupportedArgs . length > 0 ) {
3533 throw new ProcessGraphError ( 'ProcessArgumentUnsupported' , {
3634 process : this . id ,
35+ namespace : this . namespace || 'n/a' ,
3736 arguments : unsupportedArgs
3837 } ) ;
3938 }
@@ -46,6 +45,7 @@ class BaseProcess {
4645 if ( ! param . optional ) {
4746 throw new ProcessGraphError ( 'ProcessArgumentRequired' , {
4847 process : this . id ,
48+ namespace : this . namespace || 'n/a' ,
4949 argument : param . name
5050 } ) ;
5151 }
@@ -73,6 +73,7 @@ class BaseProcess {
7373 if ( ! JsonSchemaValidator . isSchemaCompatible ( param . schema , callbackParam . schema ) ) {
7474 throw new ProcessGraphError ( 'ProcessArgumentInvalid' , {
7575 process : this . id ,
76+ namespace : this . namespace || 'n/a' ,
7677 argument : path ,
7778 reason : "Schema for parameter '" + arg . from_parameter + "' not compatible with reference"
7879 } ) ;
@@ -86,7 +87,8 @@ class BaseProcess {
8687 throw new ProcessGraphError ( 'ProcessGraphParameterMissing' , {
8788 argument : arg . from_parameter ,
8889 node_id : node . id ,
89- process_id : node . process_id
90+ process_id : node . process_id ,
91+ namespace : node . namespace || 'n/a'
9092 } ) ;
9193 }
9294
@@ -98,6 +100,7 @@ class BaseProcess {
98100 if ( ! JsonSchemaValidator . isSchemaCompatible ( param . schema , parameter . schema ) ) {
99101 throw new ProcessGraphError ( 'ProcessArgumentInvalid' , {
100102 process : this . id ,
103+ namespace : this . namespace || 'n/a' ,
101104 argument : path ,
102105 reason : "Schema for parameter '" + arg . from_parameter + "' not compatible"
103106 } ) ;
@@ -111,6 +114,7 @@ class BaseProcess {
111114 if ( ! JsonSchemaValidator . isSchemaCompatible ( param . schema , process . returns . schema ) ) {
112115 throw new ProcessGraphError ( 'ProcessArgumentInvalid' , {
113116 process : this . id ,
117+ namespace : this . namespace || 'n/a' ,
114118 argument : path ,
115119 reason : "Schema for result '" + arg . from_node + "' not compatible"
116120 } ) ;
@@ -155,6 +159,7 @@ class BaseProcess {
155159 if ( errors . length > 0 ) {
156160 throw new ProcessGraphError ( 'ProcessArgumentInvalid' , {
157161 process : this . id ,
162+ namespace : this . namespace || 'n/a' ,
158163 argument : path ,
159164 reason : errors
160165 } ) ;
@@ -164,13 +169,13 @@ class BaseProcess {
164169
165170 /* istanbul ignore next */
166171 async execute ( /*node*/ ) {
167- throw " execute not implemented yet" ;
172+ throw new Error ( ` execute not implemented yet for process ' ${ this . id } ' (namespace: ${ this . namespace || 'n/a' } )` ) ;
168173 }
169174
170175 /* istanbul ignore next */
171176 test ( ) {
172177 // Run the tests from the examples
173- throw " test not implemented yet" ;
178+ throw new Error ( ` test not implemented yet for process ' ${ this . id } ' (namespace: ${ this . namespace || 'n/a' } )` ) ;
174179 }
175180
176181}
0 commit comments