From 7a84a7afc7ed792f52076b0efedb7a407ed2c447 Mon Sep 17 00:00:00 2001 From: Seth Wiesman Date: Mon, 20 Mar 2023 13:57:52 -0500 Subject: [PATCH] Refactor: shadow name --- src/kafka/kafkaConfig.ts | 3 +-- src/schemas/parseAvroSchema.ts | 8 ++++---- src/schemas/parseSqlSchema.ts | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/kafka/kafkaConfig.ts b/src/kafka/kafkaConfig.ts index e307d91..46360c2 100644 --- a/src/kafka/kafkaConfig.ts +++ b/src/kafka/kafkaConfig.ts @@ -24,8 +24,7 @@ export default async function kafkaConfig() { connectionTimeout: 10_000, authenticationTimeout: 10_000 }; - const kafka = new Kafka(conf); - return kafka; + return new Kafka(conf); } if (sslCaLocation && sslCertLocation && sslKeyLocation) { diff --git a/src/schemas/parseAvroSchema.ts b/src/schemas/parseAvroSchema.ts index ea27f61..39f68d9 100644 --- a/src/schemas/parseAvroSchema.ts +++ b/src/schemas/parseAvroSchema.ts @@ -9,8 +9,8 @@ export async function parseAvroSchema(schemaFile: any) { }); if (global.debug) { - const parsed = avro.parse(schemaFile); - console.log(parsed); + const avroSchema = avro.parse(schemaFile); + console.log(avroSchema); } let schema = []; @@ -23,9 +23,9 @@ export async function parseAvroSchema(schemaFile: any) { } -async function convertAvroSchemaToJson(schema: any): Promise { +async function convertAvroSchemaToJson(schemas: any): Promise { const jsonSchema = []; - schema.forEach(table => { + schemas.forEach(table => { const schema = { _meta: { topic: table.name diff --git a/src/schemas/parseSqlSchema.ts b/src/schemas/parseSqlSchema.ts index 8d2262f..a7ac58a 100644 --- a/src/schemas/parseSqlSchema.ts +++ b/src/schemas/parseSqlSchema.ts @@ -20,17 +20,17 @@ export async function parseSqlSchema(schemaFile: any) { let tables = []; // @ts-ignore parsedSchema.ast.forEach((table: { table: ({ [s: string]: unknown; } | ArrayLike)[]; create_definitions: any[]; }) => { - const schema = { + const recordSchema = { tableName: Object.values(table.table[0]) .filter(x => x) .join('.'), columns: [] }; table.create_definitions.forEach(column => { - schema.columns.push(column); + recordSchema.columns.push(column); }); // @ts-ignore - tables.push(schema); + tables.push(recordSchema); }); // Convert the schema to JSON