From 20d3532c0f54a619e4b3b56883c4b30ba037a2e3 Mon Sep 17 00:00:00 2001 From: Rafael Date: Mon, 31 Aug 2026 16:09:25 -0300 Subject: [PATCH] FIX: address review round 2 on the CDC refactor - toCdcTable accepts the source table named either table_name (platform bodies) or name (create DTO), so call sites pass it point-free: body.tables.map(toCdcTable). The identity is still derived in one place. - PipelineTablesService declares its logger like every other maestro service (logger: DadosferaLogger assigned from the injected instance). Co-Authored-By: WOZCODE --- src/modules/inputs/cdc-table.mapper.ts | 13 +++++++++---- src/modules/inputs/inputs.service.ts | 4 +--- src/modules/platform-api/pipeline-tables.service.ts | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/modules/inputs/cdc-table.mapper.ts b/src/modules/inputs/cdc-table.mapper.ts index 491c8b8..3b179d9 100644 --- a/src/modules/inputs/cdc-table.mapper.ts +++ b/src/modules/inputs/cdc-table.mapper.ts @@ -3,11 +3,15 @@ import { CdcTable, } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities'; -/** What a caller knows about a CDC table before it is stored. */ +/** What a caller knows about a CDC table before it is stored. The source + * table is named `table_name` on the platform-facing bodies and `name` on + * the create DTO (CdcTableReq); either works — deriving one from the other + * happens only here. */ export interface CdcTableInput { // Optional on the create DTO (CdcTableReq); the platform validates it. table_schema?: string; - table_name: string; + table_name?: string; + name?: string; primary_keys?: string[]; iceberg_table_name?: string; iceberg_qualify_table_name?: string; @@ -25,10 +29,11 @@ export interface CdcTableInput { * `name ?? table_name`). */ export function toCdcTable(table: CdcTableInput): CdcTable { + const tableName = table.table_name ?? table.name; return { table_schema: table.table_schema, - table_name: table.table_name, - name: table.table_name, + table_name: tableName, + name: tableName, primary_keys: table.primary_keys ?? [], iceberg_table_name: table.iceberg_table_name, iceberg_qualify_table_name: table.iceberg_qualify_table_name, diff --git a/src/modules/inputs/inputs.service.ts b/src/modules/inputs/inputs.service.ts index 5e622e7..24fecba 100644 --- a/src/modules/inputs/inputs.service.ts +++ b/src/modules/inputs/inputs.service.ts @@ -196,9 +196,7 @@ export class InputsService { name: body.name, plugin: body.plugin, read_only: body.read_only ?? true, - tables: body.tables.map((t) => - toCdcTable({ ...t, table_name: t.name }), - ), + tables: body.tables.map(toCdcTable), destination: body.destination, }, info, diff --git a/src/modules/platform-api/pipeline-tables.service.ts b/src/modules/platform-api/pipeline-tables.service.ts index 1ac95a7..4d5eaed 100644 --- a/src/modules/platform-api/pipeline-tables.service.ts +++ b/src/modules/platform-api/pipeline-tables.service.ts @@ -30,7 +30,7 @@ interface PlatformPipeline { */ @Injectable() export class PipelineTablesService { - private logger: DadosferaLogger['logger']; + logger: DadosferaLogger; constructor( private readonly platformApiService: PlatformApiService,