Linting.
This commit is contained in:
parent
856be36d9e
commit
84ea655fd9
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue