From 43c9e0a9b607d46e0e2e2304340e76d005e9a9da Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 25 Jun 2021 18:34:21 +0100 Subject: [PATCH] Linting. --- .../src/api/controllers/row/external.js | 21 +++- .../src/integrations/base/definitions.ts | 114 +++++++++--------- packages/server/src/integrations/base/sql.ts | 24 +++- 3 files changed, 95 insertions(+), 64 deletions(-) diff --git a/packages/server/src/api/controllers/row/external.js b/packages/server/src/api/controllers/row/external.js index 79a347750f..a5180a1436 100644 --- a/packages/server/src/api/controllers/row/external.js +++ b/packages/server/src/api/controllers/row/external.js @@ -1,5 +1,10 @@ const { makeExternalQuery } = require("./utils") -const { DataSourceOperation, SortDirection, FieldTypes, RelationshipTypes } = require("../../../constants") +const { + DataSourceOperation, + SortDirection, + FieldTypes, + RelationshipTypes, +} = require("../../../constants") const { getAllExternalTables } = require("../table/utils") const { breakExternalTableId, @@ -69,7 +74,12 @@ function outputProcessing(rows, table, relationships, allTables) { row._id = generateIdForRow(row, table) // this is a relationship of some sort if (finalRows[row._id]) { - finalRows = updateRelationshipColumns(finalRows, row, relationships, allTables) + finalRows = updateRelationshipColumns( + finalRows, + row, + relationships, + allTables + ) continue } const thisRow = {} @@ -82,7 +92,12 @@ function outputProcessing(rows, table, relationships, allTables) { thisRow._rev = "rev" finalRows[thisRow._id] = thisRow // do this at end once its been added to the final rows - finalRows = updateRelationshipColumns(finalRows, row, relationships, allTables) + finalRows = updateRelationshipColumns( + finalRows, + row, + relationships, + allTables + ) } return Object.values(finalRows) } diff --git a/packages/server/src/integrations/base/definitions.ts b/packages/server/src/integrations/base/definitions.ts index 64663d073b..e8a5bfe10a 100644 --- a/packages/server/src/integrations/base/definitions.ts +++ b/packages/server/src/integrations/base/definitions.ts @@ -27,95 +27,95 @@ export enum DatasourceFieldTypes { } export interface QueryDefinition { - type: QueryTypes, - displayName?: string, - readable?: boolean, - customisable?: boolean, - fields?: object, - urlDisplay?: boolean, + type: QueryTypes + displayName?: string + readable?: boolean + customisable?: boolean + fields?: object + urlDisplay?: boolean } export interface Integration { - docs: string, - plus?: boolean, - description: string, - friendlyName: string, - datasource: {}, + docs: string + plus?: boolean + description: string + friendlyName: string + datasource: {} query: { - [key: string]: QueryDefinition, - }, + [key: string]: QueryDefinition + } } export interface SearchFilters { - allOr: boolean, + allOr: boolean string?: { - [key: string]: string, - }, + [key: string]: string + } fuzzy?: { - [key: string]: string, - }, + [key: string]: string + } range?: { [key: string]: { - high: number | string, - low: number | string, - }, - }, + high: number | string + low: number | string + } + } equal?: { - [key: string]: any, - }, + [key: string]: any + } notEqual?: { - [key: string]: any, - }, + [key: string]: any + } empty?: { - [key: string]: any, - }, + [key: string]: any + } notEmpty?: { - [key: string]: any, - }, + [key: string]: any + } } export interface RelationshipsJson { through?: { - from: string, - to: string, - tableName: string, - }, - from: string, - to: string, - tableName: string, + from: string + to: string + tableName: string + } + from: string + to: string + tableName: string } export interface QueryJson { endpoint: { - datasourceId: string, - entityId: string, - operation: Operation, - }, + datasourceId: string + entityId: string + operation: Operation + } resource: { - fields: string[], - }, - filters?: SearchFilters, + fields: string[] + } + filters?: SearchFilters sort?: { - [key: string]: SortDirection, - }, + [key: string]: SortDirection + } paginate?: { - limit: number, - page: string | number, - }, - body?: object, + limit: number + page: string | number + } + body?: object extra?: { - idFilter?: SearchFilters, - }, - relationships?: RelationshipsJson[], + idFilter?: SearchFilters + } + relationships?: RelationshipsJson[] } export interface SqlQuery { - sql: string, + sql: string bindings?: { - [key: string]: any, - }, + [key: string]: any + } } export interface QueryOptions { - disableReturning?: boolean, + disableReturning?: boolean } diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index dafbc2e6e1..60dfa84862 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -70,7 +70,11 @@ function addFilters( return query } -function addRelationships(query: KnexQuery, fromTable: string, relationships: RelationshipsJson[] | undefined): KnexQuery { +function addRelationships( + query: KnexQuery, + fromTable: string, + relationships: RelationshipsJson[] | undefined +): KnexQuery { if (!relationships) { return query } @@ -91,7 +95,11 @@ function addRelationships(query: KnexQuery, fromTable: string, relationships: Re return query } -function buildCreate(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery { +function buildCreate( + knex: Knex, + json: QueryJson, + opts: QueryOptions +): KnexQuery { const { endpoint, body } = json let query: KnexQuery = knex(endpoint.entityId) // mysql can't use returning @@ -141,7 +149,11 @@ function buildRead(knex: Knex, json: QueryJson, limit: number): KnexQuery { return query } -function buildUpdate(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery { +function buildUpdate( + knex: Knex, + json: QueryJson, + opts: QueryOptions +): KnexQuery { const { endpoint, body, filters } = json let query: KnexQuery = knex(endpoint.entityId) query = addFilters(query, filters) @@ -153,7 +165,11 @@ function buildUpdate(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery } } -function buildDelete(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery { +function buildDelete( + knex: Knex, + json: QueryJson, + opts: QueryOptions +): KnexQuery { const { endpoint, filters } = json let query: KnexQuery = knex(endpoint.entityId) query = addFilters(query, filters)