From 7a50ed4bebb91c25e52408dd4598803f90c5d76c Mon Sep 17 00:00:00 2001 From: Jessica Rodrigues Date: Thu, 19 Jan 2023 15:39:43 -0300 Subject: [PATCH 1/5] Armazena_Resultado --- resultado/result.js | 6 ++++++ valida/validando.js | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 resultado/result.js diff --git a/resultado/result.js b/resultado/result.js new file mode 100644 index 0000000..89c868b --- /dev/null +++ b/resultado/result.js @@ -0,0 +1,6 @@ +import verifica from "../valida/validando.js" + +function result(){ + console.log(verifica()) +} +result() 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 From ed7cee2704ff1f3d780ffa92b3050933e40469b6 Mon Sep 17 00:00:00 2001 From: Jessica Rodrigues Date: Thu, 26 Jan 2023 14:31:12 -0300 Subject: [PATCH 2/5] Variavel para armazenar o export --- export/export.js | 7 +++++++ resultado/result.js | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 export/export.js diff --git a/export/export.js b/export/export.js new file mode 100644 index 0000000..2d794a8 --- /dev/null +++ b/export/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/resultado/result.js b/resultado/result.js index 89c868b..539c402 100644 --- a/resultado/result.js +++ b/resultado/result.js @@ -1,6 +1,8 @@ import verifica from "../valida/validando.js" function result(){ - console.log(verifica()) + return verifica() } result() + +export default result From 20be0976e810c3ade0689fa1893d89980d97bd3a Mon Sep 17 00:00:00 2001 From: Jessica Rodrigues Date: Fri, 3 Mar 2023 11:25:05 -0300 Subject: [PATCH 3/5] Export de Csv --- exportcsv/export_csv.js | 20 ++++++++++++++++++++ exportcsv/flattening.js | 27 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 exportcsv/export_csv.js create mode 100644 exportcsv/flattening.js diff --git a/exportcsv/export_csv.js b/exportcsv/export_csv.js new file mode 100644 index 0000000..fd07c97 --- /dev/null +++ b/exportcsv/export_csv.js @@ -0,0 +1,20 @@ +import fs from 'fs' +import dat from './flattening.js' + +const chaves = Object.keys(dat[0]) +const cabecalio = chaves.join( ',') +//console.log(cabecalio) +const data = dat.map((elemento) => Object.values(elemento).join(',')).join('\n') +//console.log(data) + +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..59baffd --- /dev/null +++ b/exportcsv/flattening.js @@ -0,0 +1,27 @@ +const data = +[ + { + dataLayer: 'dataLayer', + objectName: 'objectName', + keyName: 'keyName', + status: 'status', + message: 'message', + partialErrors: { ocurrences: 0, trace: '' } + } +] + +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 From 7b9dcb246084cec9845526eb01d4cafd721f8a39 Mon Sep 17 00:00:00 2001 From: Jessica Rodrigues Date: Fri, 3 Mar 2023 11:29:41 -0300 Subject: [PATCH 4/5] Export de Csv --- {export => exportjson}/export.js | 0 exportpdf/exportpdf.js | 3 +++ test.csv | 2 ++ 3 files changed, 5 insertions(+) rename {export => exportjson}/export.js (100%) create mode 100644 exportpdf/exportpdf.js create mode 100644 test.csv diff --git a/export/export.js b/exportjson/export.js similarity index 100% rename from export/export.js rename to exportjson/export.js 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/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 From 6808e194d9f70f6750c56bdf1ba0222480b1b57f Mon Sep 17 00:00:00 2001 From: Jessica Rodrigues Date: Fri, 3 Mar 2023 11:43:52 -0300 Subject: [PATCH 5/5] Export de csv --- exportcsv/export_csv.js | 3 +-- exportcsv/flattening.js | 14 +++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/exportcsv/export_csv.js b/exportcsv/export_csv.js index fd07c97..bcee1d5 100644 --- a/exportcsv/export_csv.js +++ b/exportcsv/export_csv.js @@ -3,9 +3,8 @@ import dat from './flattening.js' const chaves = Object.keys(dat[0]) const cabecalio = chaves.join( ',') -//console.log(cabecalio) + const data = dat.map((elemento) => Object.values(elemento).join(',')).join('\n') -//console.log(data) const conteudo = cabecalio + '\n' + data console.log(conteudo) diff --git a/exportcsv/flattening.js b/exportcsv/flattening.js index 59baffd..2f45bcc 100644 --- a/exportcsv/flattening.js +++ b/exportcsv/flattening.js @@ -1,14 +1,6 @@ -const data = -[ - { - dataLayer: 'dataLayer', - objectName: 'objectName', - keyName: 'keyName', - status: 'status', - message: 'message', - partialErrors: { ocurrences: 0, trace: '' } - } -] +import result from "../resultado/result.js" + +let data = result() let dt = (obj, arr = []) => { return Object.keys(obj).reduce((result, index) => {