diff --git a/exportcsv/export_csv.js b/exportcsv/export_csv.js new file mode 100644 index 0000000..bcee1d5 --- /dev/null +++ b/exportcsv/export_csv.js @@ -0,0 +1,19 @@ +import fs from 'fs' +import dat from './flattening.js' + +const chaves = Object.keys(dat[0]) +const cabecalio = chaves.join( ',') + +const data = dat.map((elemento) => Object.values(elemento).join(',')).join('\n') + +const conteudo = cabecalio + '\n' + data +console.log(conteudo) + + + +try { + fs.writeFileSync('test.csv', conteudo); + // file written successfully + } catch (err) { + console.error(err); + } \ No newline at end of file diff --git a/exportcsv/flattening.js b/exportcsv/flattening.js new file mode 100644 index 0000000..2f45bcc --- /dev/null +++ b/exportcsv/flattening.js @@ -0,0 +1,19 @@ +import result from "../resultado/result.js" + +let data = result() + +let dt = (obj, arr = []) => { + return Object.keys(obj).reduce((result, index) => { + if (typeof obj[index] !== "object") { + result[arr.concat(index).join("_")] = obj[index]; + return result; + } + return Object.assign(result, dt(obj[index], arr.concat(index), result)); + }, {}); +} + + +let dat = [] +dat.push(dt(data[0])) +//console.log(dat) +export default dat \ No newline at end of file diff --git a/exportjson/export.js b/exportjson/export.js new file mode 100644 index 0000000..2d794a8 --- /dev/null +++ b/exportjson/export.js @@ -0,0 +1,7 @@ +import result from "../resultado/result.js" + +function teste(){ + const schema = JSON.stringify(result()) + console.log(schema) +} +teste() diff --git a/exportpdf/exportpdf.js b/exportpdf/exportpdf.js new file mode 100644 index 0000000..bd351af --- /dev/null +++ b/exportpdf/exportpdf.js @@ -0,0 +1,3 @@ +import result from "../resultado/result"; + + diff --git a/resultado/result.js b/resultado/result.js new file mode 100644 index 0000000..539c402 --- /dev/null +++ b/resultado/result.js @@ -0,0 +1,8 @@ +import verifica from "../valida/validando.js" + +function result(){ + return verifica() +} +result() + +export default result diff --git a/test.csv b/test.csv new file mode 100644 index 0000000..95a5b60 --- /dev/null +++ b/test.csv @@ -0,0 +1,2 @@ +dataLayer,objectName,keyName,status,message,partialErrors_ocurrences,partialErrors_trace +dataLayer,objectName,keyName,status,message,0, \ No newline at end of file diff --git a/valida/validando.js b/valida/validando.js index f6a9ffa..9f5b2fa 100644 --- a/valida/validando.js +++ b/valida/validando.js @@ -1,10 +1,8 @@ import validationResult from "../js/validation.js"; function verifica() { - console.log(validationResult) + return validationResult() } verifica() - - export default verifica \ No newline at end of file