diff --git a/docsfera.json b/docsfera.json index a26d359..9c47172 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3277,9 +3277,9 @@ } }, "info": { - "title": "Maestro - fix/customer-modules", + "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 14:29", + "version": "9.11.2022 - 17:34", "contact": {} }, "tags": [], diff --git a/src/modules/pipelinesV2/pipelines.service.ts b/src/modules/pipelinesV2/pipelines.service.ts index cdaac50..f4d0f4f 100644 --- a/src/modules/pipelinesV2/pipelines.service.ts +++ b/src/modules/pipelinesV2/pipelines.service.ts @@ -22,6 +22,7 @@ import { ConnectorClientService } from '../connector/client.service'; import { InputsService } from '../inputs/inputs.service'; import { RequestUser } from 'src/authentication/user.decorator'; import { TransformationsService } from '../transformations/transformations.service'; +import { getObjValueFromPath } from 'src/utils/ObjValueFromPath'; export class PipelinesService implements OnModuleInit { logger: DadosferaLogger; @@ -213,16 +214,13 @@ export class PipelinesService implements OnModuleInit { const connector = JSON.parse(res.connector); const config_controls = connector.config_controls || []; - for (const key in pipelineProperties) { - const i = config_controls - .map((cc) => cc.name) - .indexOf(`properties.${key}`); - if (i > -1) { - config_controls[i] = { - ...config_controls[i], - default_value: pipelineProperties[key], - }; - } + for (const config_control of config_controls) { + const path: string = config_control.name; + const default_value = getObjValueFromPath({ + object: { properties: pipelineProperties }, + path, + }); + if (default_value) config_control.default_value = default_value; } return { diff --git a/src/utils/ObjValueFromPath.ts b/src/utils/ObjValueFromPath.ts new file mode 100644 index 0000000..1ea24fb --- /dev/null +++ b/src/utils/ObjValueFromPath.ts @@ -0,0 +1,10 @@ +export function getObjValueFromPath(data: { object: T; path: string }): T { + const { object, path } = data; + const keys = path.split('.'); + + let value = JSON.parse(JSON.stringify(object)); + for (const key of keys) { + if (value) value = value[key]; + } + return value; +}