Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release version to master #394

Merged
merged 12 commits into from
Aug 28, 2024
Merged
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-report",
"version": "4.10.6",
"version": "4.10.7",
"description": "Reporting tool",
"main": "worker.js",
"license": "Apache-2.0",
Expand Down
60 changes: 34 additions & 26 deletions test/helpers/helpers.core.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
'use strict'

const { promisify } = require('util')
const path = require('path')
const fs = require('fs')

const readdir = promisify(fs.readdir)
const unlink = promisify(fs.unlink)
const mkdir = promisify(fs.mkdir)
const {
readdir,
mkdir,
rm
} = require('node:fs/promises')

const rmDB = async (
dir,
exclude = ['.gitkeep'],
isThrownError
exclude = ['.gitkeep']
) => {
try {
const files = await readdir(dir)
const promisesArr = files.map((file) => {
if (exclude.every(exFile => exFile !== file)) {
return unlink(path.join(dir, file))
const files = await readdir(
dir,
{ withFileTypes: true }
)

for (const dirent of files) {
const { name } = dirent

if (
!dirent.isFile() ||
exclude.some((exFile) => exFile === name)
) {
continue
}

return null
})

const res = await Promise.all(promisesArr)

return res
} catch (err) {
if (!isThrownError) {
return
const filePath = path.join(dir, name)
await rm(
filePath,
{
force: true,
maxRetries: 5,
recursive: true,
retryDelay: 200
}
)
}

throw err
} catch (err) {
console.log(err)
}
}

const rmAllFiles = async (dir, exclude) => {
try {
await rmDB(dir, exclude, true)
await rmDB(dir, exclude)
await mkdir(dir, { recursive: true })
} catch (err) {
if (err.syscall === 'scandir') {
await mkdir(dir)
}
console.log(err)
}
}

Expand Down
9 changes: 0 additions & 9 deletions workers/api.service.report.wrk.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ class WrkReportServiceApi extends WrkApi {
loadDIConfig (cont = container) {
const conf = this.conf[this.group]

/**
* @deprecated isAddedUniqueEndingToCsvName
* Keep for back compatibility
*/
conf.isAddedUniqueEndingToReportFileName = (
conf.isAddedUniqueEndingToReportFileName ??
conf.isAddedUniqueEndingToCsvName
)

this.container = cont

diConfig(conf, this.ctx.root)
Expand Down
8 changes: 1 addition & 7 deletions workers/loc.api/generate-report-file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ const _getReportFileStoreStatus = async ({
return {
isSaveLocaly: true,
localReportFolderPath,
remoteReportUrn,

/**
* @deprecated fields
*/
localCsvFolderPath: localReportFolderPath,
remoteCsvUrn: remoteReportUrn
remoteReportUrn
}
}

Expand Down
16 changes: 14 additions & 2 deletions workers/loc.api/helpers/api-errors-testers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const isEAiAgainError = (err) => {
}

const isEConnRefusedError = (err) => {
return /ECONNREFUSED/i.test(_getErrorString(err))
return /(ECONNREFUSED)|(ERR_CONNECTION_REFUSED)/i.test(_getErrorString(err))
}

const isEConnClosedError = (err) => {
return /ERR_CONNECTION_CLOSED/i.test(_getErrorString(err))
}

const isENotFoundError = (err) => {
Expand All @@ -71,6 +75,10 @@ const isTempUnavailableError = (err) => {
return /temporarily_unavailable/i.test(_getErrorString(err))
}

const isBadGatewayError = (err) => {
return /Bad Gateway/i.test(_getErrorString(err))
}

const isForbiddenError = (err) => {
return /forbidden/i.test(_getErrorString(err))
}
Expand All @@ -87,11 +95,13 @@ const isENetError = (err) => (
isNodeFetchTimeoutError(err) ||
isEAiAgainError(err) ||
isEConnRefusedError(err) ||
isEConnClosedError(err) ||
isENotFoundError(err) ||
isESocketTimeoutError(err) ||
isEHostUnreachError(err) ||
isEProtoError(err) ||
isTempUnavailableError(err)
isTempUnavailableError(err) ||
isBadGatewayError(err)
)

module.exports = {
Expand All @@ -106,11 +116,13 @@ module.exports = {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError
Expand Down
10 changes: 10 additions & 0 deletions workers/loc.api/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ const {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError
Expand Down Expand Up @@ -81,8 +86,13 @@ module.exports = {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError,
Expand Down
Loading
Loading