Skip to content

Commit

Permalink
Managed adapter lint fixes (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Oct 31, 2023
1 parent a0e9a01 commit 54c714c
Show file tree
Hide file tree
Showing 57 changed files with 73 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter) ).toEqual([{
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-airtable/tests/drivers/mock_air_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const batchRecordUpdate = [
const fields = req.body.typecast ? { typecasted: true } : record.fields
return {
id: record.id,
fields: fields,
fields,
}
}),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const connection = async() => {
const { connection, schemaProvider, cleanup } = await init(connectionConfig(),
{ requestTimeout: 1000 })

return { pool: connection, schemaProvider, cleanup: cleanup }
return { pool: connection, schemaProvider, cleanup }
}

export const cleanup = async() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter) ).toEqual([{
Expand Down
5 changes: 2 additions & 3 deletions libs/external-db-bigquery/src/sql_filter_transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class FilterParser {
fieldsStatement: filterColumnsStr.join(', '),
groupByColumns,
havingFilter: filterExpr,
parameters: parameters,
parameters,
}
}

Expand All @@ -74,8 +74,7 @@ export default class FilterParser {
}

extractFilterExprAndParams(havingFilter: any[]) {
return havingFilter.map(({ filterExpr, parameters }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '',
parameters: parameters }))
return havingFilter.map(({ filterExpr, parameters }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '', parameters }))
.concat(EmptyFilter)[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const dbOperationWithMisconfiguredDatabaseId = () => new DatabaseOperations(crea
export const dbOperationWithValidDB = () => {
const { connection, cleanup } = createPool({ databaseId: 'testDB' })
const dbOperations = new DatabaseOperations(connection)
return { dbOperations, cleanup: cleanup }
return { dbOperations, cleanup }
}

export const misconfiguredDbOperationOptions = () => ([ ['pool connection with wrong databaseId', () => dbOperationWithMisconfiguredDatabaseId()]])
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const givenAggregateQueryWith = (having: any, numericColumns: { name: any
when(filterParser.parseAggregation).calledWith({ postFilteringStep: filter, processingStep: having })
.mockReturnValue({
fieldsStatement: `${groupByColumns.map( escapeIdentifier ).join(', ')}, MAX(${escapeIdentifier(numericColumns[0].name)}) AS ${escapeIdentifier(columnAliases[0])}, SUM(${escapeIdentifier(numericColumns[1].name)}) AS ${escapeIdentifier(columnAliases[1])}`,
groupByColumns: groupByColumns,
groupByColumns,
offset: offest,
havingFilter: '',
parameters: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export default class AwsAuthorizationConfigReader implements IConfigReader {
const { externalConfig, secretMangerError }: {[key:string]: any} = await this.readExternalConfig()
const { PERMISSIONS }: { PERMISSIONS: any } = { ...process.env, ...externalConfig }
const config = { PERMISSIONS }
return { config, secretMangerError: secretMangerError }
return { config, secretMangerError }
}
}
6 changes: 3 additions & 3 deletions libs/external-db-config/src/readers/aws_config_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class AwsConfigReader implements IConfigReader {
async readConfig() {
const { config } = await this.readExternalAndLocalConfig()
const { host, username, password, DB, EXTERNAL_DATABASE_ID, ALLOWED_METASITES, DB_PORT } = config
return { host: host, user: username, password: password, db: DB, externalDatabaseId: EXTERNAL_DATABASE_ID, allowedMetasites: ALLOWED_METASITES, port: DB_PORT }
return { host, user: username, password, db: DB, externalDatabaseId: EXTERNAL_DATABASE_ID, allowedMetasites: ALLOWED_METASITES, port: DB_PORT }
}

async readExternalConfig() {
Expand Down Expand Up @@ -56,7 +56,7 @@ export class AwsDynamoConfigReader implements IConfigReader {
const { EXTERNAL_DATABASE_ID = undefined, ALLOWED_METASITES = undefined } = { ...process.env, ...externalConfig }
const config = { EXTERNAL_DATABASE_ID, ALLOWED_METASITES }

return { config, secretMangerError: secretMangerError }
return { config, secretMangerError }
}

async readExternalConfig() {
Expand Down Expand Up @@ -93,7 +93,7 @@ export class AwsMongoConfigReader implements IConfigReader {
const { EXTERNAL_DATABASE_ID, ALLOWED_METASITES, URI }: {EXTERNAL_DATABASE_ID: string, ALLOWED_METASITES: string, URI: string} = { ...process.env, ...externalConfig }
const config = { EXTERNAL_DATABASE_ID, ALLOWED_METASITES, URI }

return { config, secretMangerError: secretMangerError }
return { config, secretMangerError }
}

async readConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter) ).toEqual([{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * as capabilities from '../../src/dynamo_capabilities'
export const connection = async() => {
const { connection, schemaProvider, cleanup } = init(connectionConfig(), accessOptions())

return { pool: connection, schemaProvider, cleanup: cleanup }
return { pool: connection, schemaProvider, cleanup }
}

export const cleanup = async() => {
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-firestore/src/connection_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DbProviders } from '@wix-velo/velo-external-db-types'

export default ({ projectId }: firestoreConfig): DbProviders<Firestore> => {
const firestore = new Firestore({
projectId: projectId,
projectId,
})

const databaseOperations = new DatabaseOperations(firestore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('Fire Store Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter) ).toEqual([{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const connection = async() => {
apiPrivateKey: process.env['API_PRIVATE_KEY']
}
const { connection, schemaProvider, cleanup } = await init(googleSheetsConfig)
return { pool: connection, schemaProvider, cleanup: cleanup }
return { pool: connection, schemaProvider, cleanup }
}

export const cleanup = async() => {
Expand All @@ -37,7 +37,7 @@ export const setActive = () => {

export const enviormentVariables = {
TYPE: 'google-sheet',
SHEET_ID: SHEET_ID
SHEET_ID
}

export const name = 'google-sheets'
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class GoogleSpreadsheetDoc {
constructor(spreadsheetId, title) {
this.spreadsheetId = spreadsheetId
this.properties = {
title: title,
title,
}
this.sheets = []
this.namedRanges = []
Expand Down
4 changes: 2 additions & 2 deletions libs/external-db-google-sheets/tests/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const batchGetValuesResponse = (spreadsheetId, sheet, range, majorDimension, val
{
range: `${sheet}!${range}`,
majorDimension: `${majorDimension}`,
values: values
values
}
]
})
Expand All @@ -21,7 +21,7 @@ const spreadsheet = (spreadsheetId, title, sheets = []) => ({
properties: {
title: `${title}`
},
sheets: sheets
sheets
})

const updateValuesResponse = (spreadsheetId, sheet, range, updatedRows, updatedColumns, updatedCells) => ({
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-mongo/src/sql_filter_transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect(env.filterParser.parseFilter(filter)).toEqual([{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const givenAggregateQueryWith = (having: any, numericColumns: any[], colu
[columnAliases[0]]: { $max: `$${c[0]}` },
[columnAliases[1]]: { $sum: `$${c[1]}` }
} },
groupByColumns: groupByColumns,
groupByColumns,
havingFilter: { $match: {} },
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export * as capabilities from '../../src/mongo_capabilities'
export const connection = async() => {
const { connection, schemaProvider, cleanup } = await init({ connectionUri: 'mongodb://root:pass@localhost/testdb' })

return { pool: connection, schemaProvider, cleanup: cleanup }
return { pool: connection, schemaProvider, cleanup }
}

export const cleanup = async() => {
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-mssql/src/sql_filter_transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq as AdapterOperator,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter) ).toEqual([{
Expand Down
5 changes: 2 additions & 3 deletions libs/external-db-mssql/src/sql_filter_transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class FilterParser {
fieldsStatement: filterColumnsStr.join(', '),
groupByColumns,
havingFilter: filterExpr,
parameters: parameters,
parameters,
}
}

Expand All @@ -81,8 +81,7 @@ export default class FilterParser {
}

extractFilterExprAndParams(havingFilter: { filterExpr: any; parameters: any }[]) {
return havingFilter.map(({ filterExpr, parameters }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '',
parameters: parameters }))
return havingFilter.map(({ filterExpr, parameters }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '', parameters }))
.concat({ filterExpr: '', parameters: {} })[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const givenAggregateQueryWith = (having: any, numericColumns: any[], colu
when(filterParser.parseAggregation).calledWith({ postFilteringStep: filter, processingStep: having })
.mockReturnValue({
fieldsStatement: `${groupByColumns.map( escapeId )}, MAX(${escapeId(c[0])}) AS ${escapeId(columnAliases[0])}, SUM(${escapeId(c[1])}) AS ${escapeId(columnAliases[1])}`,
groupByColumns: groupByColumns,
groupByColumns,
havingFilter: '',
parameters: {},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const extraOptions = {
export const connection = async() => {
const { connection, schemaProvider, cleanup } = await init(testEnvConfig, extraOptions)

return { pool: connection, schemaProvider, cleanup: cleanup }
return { pool: connection, schemaProvider, cleanup }
}

export const cleanup = async() => {
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-mysql/src/sql_filter_transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter) ).toEqual([{
Expand Down
5 changes: 2 additions & 3 deletions libs/external-db-mysql/src/sql_filter_transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default class FilterParser implements IMySqlFilterParser {
fieldsStatement: filterColumnsStr.join(', '),
groupByColumns,
havingFilter: filterExpr,
parameters: parameters,
parameters,
}
}

Expand All @@ -225,8 +225,7 @@ export default class FilterParser implements IMySqlFilterParser {
}

extractFilterExprAndParams(havingFilter: { filterExpr: any; parameters: any }[]) {
return havingFilter.map(({ filterExpr, parameters }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '',
parameters: parameters }))
return havingFilter.map(({ filterExpr, parameters }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '', parameters }))
.concat(EmptyFilter)[0]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const givenAggregateQueryWith = (having: any, numericColumns: any[], colu
when(filterParser.parseAggregation).calledWith({ postFilteringStep: filter, processingStep: having })
.mockReturnValue({
fieldsStatement: `${groupByColumns.map( escapeId )}, MAX(${escapeId(c[0])}) AS ${escapeId(columnAliases[0])}, SUM(${escapeId(c[1])}) AS ${escapeId(columnAliases[1])}`,
groupByColumns: groupByColumns,
groupByColumns,
havingFilter: '',
parameters: [],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export * as capabilities from '../../src/mysql_capabilities'

export const connection = () => {
const { connection, schemaProvider, cleanup } = init({ host: 'localhost', user: 'test-user', password: 'password', db: 'test-db' }, { connectionLimit: 1, queueLimit: 0 })
return { pool: connection, schemaProvider, cleanup: cleanup }
return { pool: connection, schemaProvider, cleanup }
}

export const cleanup = async() => {
Expand Down
4 changes: 2 additions & 2 deletions libs/external-db-postgres/src/connection_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default (cfg: PostgresConfig, _poolOptions: postgresPoolOptions) => {
const schemaProvider = new SchemaProvider(pool)

return {
dataProvider: dataProvider,
schemaProvider: schemaProvider,
dataProvider,
schemaProvider,
databaseOperations,
connection: pool,
cleanup: async() => pool.end(() => {})
Expand Down
2 changes: 1 addition & 1 deletion libs/external-db-postgres/src/postgres_schema_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class SchemaProvider implements ISchemaProvider {
const fields = res.rows.map(r => ({ field: r.field, type: r.type })).map(r => this.appendAdditionalRowDetails(r))
return {
id: collectionName,
fields: fields,
fields,
capabilities: this.collectionCapabilities(res.rows.map(r => r.field))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('Sql Parser', () => {
const filter = {
operator: eq,
fieldName: ctx.fieldName,
value: value
value
}

expect( env.filterParser.parseFilter(filter, ctx.offset) ).toEqual([{
Expand Down
9 changes: 4 additions & 5 deletions libs/external-db-postgres/src/sql_filter_transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class FilterParser {
fieldsStatement: filterColumnsStr.join(', '),
groupByColumns,
havingFilter: filterExpr,
parameters: parameters,
parameters,
offset: offsetAfterAggregation
}
}
Expand All @@ -80,8 +80,7 @@ export default class FilterParser {
}

extractFilterExprAndParams(havingFilter: any[], offset: number) {
return havingFilter.map(({ filterExpr, parameters, offset }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '',
parameters: parameters, offset }))
return havingFilter.map(({ filterExpr, parameters, offset }) => ({ filterExpr: filterExpr !== '' ? `HAVING ${filterExpr}` : '', parameters, offset }))
.concat({ ...EmptyFilter, offset: offset ?? 1 })[0]
}

Expand All @@ -102,7 +101,7 @@ export default class FilterParser {
filter: [ ...o.filter, ...res],
offset: res.length === 1 ? res[0].offset : o.offset
}
}, { filter: [], offset: offset })
}, { filter: [], offset })

const op = operator === and ? ' AND ' : ' OR '
return [{
Expand Down Expand Up @@ -209,7 +208,7 @@ export default class FilterParser {
} else if ((operator === eq || operator === ne) && isNull(value)) {
return {
sql: '',
offset: offset
offset
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const dbOperationWithMisconfiguredHost = () => new DatabaseOperations(createPool
export const dbOperationWithValidDB = () => {
const { connection, cleanup } = createPool({ } )
const dbOperations = new DatabaseOperations(connection)
return { dbOperations, cleanup: cleanup }
return { dbOperations, cleanup }
}

export const misconfiguredDbOperationOptions = () => ([ ['pool connection with wrong password', () => dbOperationWithMisconfiguredPassword()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const givenAggregateQueryWith = (having: any, numericColumns: { name: str
when(filterParser.parseAggregation).calledWith({ postFilteringStep: filter, processingStep: having }, offest)
.mockReturnValue({
fieldsStatement: `${groupByColumns.map( escapeIdentifier ).join(', ')}, MAX(${escapeIdentifier(numericColumns[0].name)}) AS ${escapeIdentifier(columnAliases[0])}, SUM(${escapeIdentifier(numericColumns[1].name)}) AS ${escapeIdentifier(columnAliases[1])}`,
groupByColumns: groupByColumns,
groupByColumns,
offset: offest,
havingFilter: '',
parameters: [],
Expand Down
Loading

0 comments on commit 54c714c

Please sign in to comment.