You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					38 lines
				
				990 B
			
		
		
			
		
	
	
					38 lines
				
				990 B
			| 
								 
											3 years ago
										 
									 | 
							
								"use strict";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Object.defineProperty(exports, "__esModule", {
							 | 
						||
| 
								 | 
							
								  value: true
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								exports.convertNestedParam = void 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var _constants = require("./constants");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var _convertParam = require("./convert-param");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								const convertNestedParam = (parentValue, subProperty) => {
							 | 
						||
| 
								 | 
							
								  const path = subProperty.propertyPath.split(_constants.DELIMITER).slice(-1)[0];
							 | 
						||
| 
								 | 
							
								  const {
							 | 
						||
| 
								 | 
							
								    type = 'string'
							 | 
						||
| 
								 | 
							
								  } = subProperty;
							 | 
						||
| 
								 | 
							
								  let value = parentValue[path];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  if (type === 'mixed' && value) {
							 | 
						||
| 
								 | 
							
								    const nestedSubProperties = subProperty.subProperties;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    for (const nestedSubProperty of nestedSubProperties) {
							 | 
						||
| 
								 | 
							
								      if (subProperty.isArray) {
							 | 
						||
| 
								 | 
							
								        value = [...value].map(element => convertNestedParam(element, nestedSubProperty));
							 | 
						||
| 
								 | 
							
								      } else {
							 | 
						||
| 
								 | 
							
								        value = convertNestedParam(value, nestedSubProperty);
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								  } else {
							 | 
						||
| 
								 | 
							
								    value = (0, _convertParam.convertParam)(value, subProperty.type);
							 | 
						||
| 
								 | 
							
								  }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  return { ...parentValue,
							 | 
						||
| 
								 | 
							
								    [path]: value
							 | 
						||
| 
								 | 
							
								  };
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								exports.convertNestedParam = convertNestedParam;
							 |