Linting.
This commit is contained in:
parent
8bf22438fc
commit
43c9e0a9b6
|
@ -1,5 +1,10 @@
|
||||||
const { makeExternalQuery } = require("./utils")
|
const { makeExternalQuery } = require("./utils")
|
||||||
const { DataSourceOperation, SortDirection, FieldTypes, RelationshipTypes } = require("../../../constants")
|
const {
|
||||||
|
DataSourceOperation,
|
||||||
|
SortDirection,
|
||||||
|
FieldTypes,
|
||||||
|
RelationshipTypes,
|
||||||
|
} = require("../../../constants")
|
||||||
const { getAllExternalTables } = require("../table/utils")
|
const { getAllExternalTables } = require("../table/utils")
|
||||||
const {
|
const {
|
||||||
breakExternalTableId,
|
breakExternalTableId,
|
||||||
|
@ -69,7 +74,12 @@ function outputProcessing(rows, table, relationships, allTables) {
|
||||||
row._id = generateIdForRow(row, table)
|
row._id = generateIdForRow(row, table)
|
||||||
// this is a relationship of some sort
|
// this is a relationship of some sort
|
||||||
if (finalRows[row._id]) {
|
if (finalRows[row._id]) {
|
||||||
finalRows = updateRelationshipColumns(finalRows, row, relationships, allTables)
|
finalRows = updateRelationshipColumns(
|
||||||
|
finalRows,
|
||||||
|
row,
|
||||||
|
relationships,
|
||||||
|
allTables
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const thisRow = {}
|
const thisRow = {}
|
||||||
|
@ -82,7 +92,12 @@ function outputProcessing(rows, table, relationships, allTables) {
|
||||||
thisRow._rev = "rev"
|
thisRow._rev = "rev"
|
||||||
finalRows[thisRow._id] = thisRow
|
finalRows[thisRow._id] = thisRow
|
||||||
// do this at end once its been added to the final rows
|
// 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)
|
return Object.values(finalRows)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,95 +27,95 @@ export enum DatasourceFieldTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryDefinition {
|
export interface QueryDefinition {
|
||||||
type: QueryTypes,
|
type: QueryTypes
|
||||||
displayName?: string,
|
displayName?: string
|
||||||
readable?: boolean,
|
readable?: boolean
|
||||||
customisable?: boolean,
|
customisable?: boolean
|
||||||
fields?: object,
|
fields?: object
|
||||||
urlDisplay?: boolean,
|
urlDisplay?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Integration {
|
export interface Integration {
|
||||||
docs: string,
|
docs: string
|
||||||
plus?: boolean,
|
plus?: boolean
|
||||||
description: string,
|
description: string
|
||||||
friendlyName: string,
|
friendlyName: string
|
||||||
datasource: {},
|
datasource: {}
|
||||||
query: {
|
query: {
|
||||||
[key: string]: QueryDefinition,
|
[key: string]: QueryDefinition
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchFilters {
|
export interface SearchFilters {
|
||||||
allOr: boolean,
|
allOr: boolean
|
||||||
string?: {
|
string?: {
|
||||||
[key: string]: string,
|
[key: string]: string
|
||||||
},
|
}
|
||||||
fuzzy?: {
|
fuzzy?: {
|
||||||
[key: string]: string,
|
[key: string]: string
|
||||||
},
|
}
|
||||||
range?: {
|
range?: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
high: number | string,
|
high: number | string
|
||||||
low: number | string,
|
low: number | string
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
equal?: {
|
equal?: {
|
||||||
[key: string]: any,
|
[key: string]: any
|
||||||
},
|
}
|
||||||
notEqual?: {
|
notEqual?: {
|
||||||
[key: string]: any,
|
[key: string]: any
|
||||||
},
|
}
|
||||||
empty?: {
|
empty?: {
|
||||||
[key: string]: any,
|
[key: string]: any
|
||||||
},
|
}
|
||||||
notEmpty?: {
|
notEmpty?: {
|
||||||
[key: string]: any,
|
[key: string]: any
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RelationshipsJson {
|
export interface RelationshipsJson {
|
||||||
through?: {
|
through?: {
|
||||||
from: string,
|
from: string
|
||||||
to: string,
|
to: string
|
||||||
tableName: string,
|
tableName: string
|
||||||
},
|
}
|
||||||
from: string,
|
from: string
|
||||||
to: string,
|
to: string
|
||||||
tableName: string,
|
tableName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryJson {
|
export interface QueryJson {
|
||||||
endpoint: {
|
endpoint: {
|
||||||
datasourceId: string,
|
datasourceId: string
|
||||||
entityId: string,
|
entityId: string
|
||||||
operation: Operation,
|
operation: Operation
|
||||||
},
|
}
|
||||||
resource: {
|
resource: {
|
||||||
fields: string[],
|
fields: string[]
|
||||||
},
|
}
|
||||||
filters?: SearchFilters,
|
filters?: SearchFilters
|
||||||
sort?: {
|
sort?: {
|
||||||
[key: string]: SortDirection,
|
[key: string]: SortDirection
|
||||||
},
|
}
|
||||||
paginate?: {
|
paginate?: {
|
||||||
limit: number,
|
limit: number
|
||||||
page: string | number,
|
page: string | number
|
||||||
},
|
}
|
||||||
body?: object,
|
body?: object
|
||||||
extra?: {
|
extra?: {
|
||||||
idFilter?: SearchFilters,
|
idFilter?: SearchFilters
|
||||||
},
|
}
|
||||||
relationships?: RelationshipsJson[],
|
relationships?: RelationshipsJson[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SqlQuery {
|
export interface SqlQuery {
|
||||||
sql: string,
|
sql: string
|
||||||
bindings?: {
|
bindings?: {
|
||||||
[key: string]: any,
|
[key: string]: any
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryOptions {
|
export interface QueryOptions {
|
||||||
disableReturning?: boolean,
|
disableReturning?: boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,11 @@ function addFilters(
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
function addRelationships(query: KnexQuery, fromTable: string, relationships: RelationshipsJson[] | undefined): KnexQuery {
|
function addRelationships(
|
||||||
|
query: KnexQuery,
|
||||||
|
fromTable: string,
|
||||||
|
relationships: RelationshipsJson[] | undefined
|
||||||
|
): KnexQuery {
|
||||||
if (!relationships) {
|
if (!relationships) {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
@ -91,7 +95,11 @@ function addRelationships(query: KnexQuery, fromTable: string, relationships: Re
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildCreate(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery {
|
function buildCreate(
|
||||||
|
knex: Knex,
|
||||||
|
json: QueryJson,
|
||||||
|
opts: QueryOptions
|
||||||
|
): KnexQuery {
|
||||||
const { endpoint, body } = json
|
const { endpoint, body } = json
|
||||||
let query: KnexQuery = knex(endpoint.entityId)
|
let query: KnexQuery = knex(endpoint.entityId)
|
||||||
// mysql can't use returning
|
// mysql can't use returning
|
||||||
|
@ -141,7 +149,11 @@ function buildRead(knex: Knex, json: QueryJson, limit: number): KnexQuery {
|
||||||
return query
|
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
|
const { endpoint, body, filters } = json
|
||||||
let query: KnexQuery = knex(endpoint.entityId)
|
let query: KnexQuery = knex(endpoint.entityId)
|
||||||
query = addFilters(query, filters)
|
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
|
const { endpoint, filters } = json
|
||||||
let query: KnexQuery = knex(endpoint.entityId)
|
let query: KnexQuery = knex(endpoint.entityId)
|
||||||
query = addFilters(query, filters)
|
query = addFilters(query, filters)
|
||||||
|
|
Loading…
Reference in New Issue