Formatting.
This commit is contained in:
parent
ce8d06df06
commit
4950db460c
|
@ -29,7 +29,7 @@
|
||||||
integration = {
|
integration = {
|
||||||
type: integrationType,
|
type: integrationType,
|
||||||
plus: selected.plus,
|
plus: selected.plus,
|
||||||
...schema
|
...schema,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
name,
|
name,
|
||||||
source: type,
|
source: type,
|
||||||
config,
|
config,
|
||||||
plus
|
plus,
|
||||||
})
|
})
|
||||||
notifications.success(`Datasource ${name} created successfully.`)
|
notifications.success(`Datasource ${name} created successfully.`)
|
||||||
analytics.captureEvent("Datasource Created", { name, type })
|
analytics.captureEvent("Datasource Created", { name, type })
|
||||||
|
|
|
@ -69,7 +69,7 @@ export const deleteRow = async ({ tableId, rowId, revId }) => {
|
||||||
body: {
|
body: {
|
||||||
_id: rowId,
|
_id: rowId,
|
||||||
_rev: revId,
|
_rev: revId,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
res.error
|
res.error
|
||||||
? notificationStore.danger("An error has occurred")
|
? notificationStore.danger("An error has occurred")
|
||||||
|
|
|
@ -10,11 +10,16 @@ async function buildIDFilter(id) {
|
||||||
return {
|
return {
|
||||||
equal: {
|
equal: {
|
||||||
id: id,
|
id: id,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRequest(appId, operation, tableId, { id, row, filters, sort, paginate }) {
|
async function handleRequest(
|
||||||
|
appId,
|
||||||
|
operation,
|
||||||
|
tableId,
|
||||||
|
{ id, row, filters, sort, paginate }
|
||||||
|
) {
|
||||||
let [datasourceId, tableName] = tableId.split("/")
|
let [datasourceId, tableName] = tableId.split("/")
|
||||||
let idFilter = buildIDFilter(id)
|
let idFilter = buildIDFilter(id)
|
||||||
let json = {
|
let json = {
|
||||||
|
@ -34,49 +39,56 @@ async function handleRequest(appId, operation, tableId, { id, row, filters, sort
|
||||||
return makeExternalQuery(appId, json)
|
return makeExternalQuery(appId, json)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.patch = async (ctx) => {
|
exports.patch = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const inputs = ctx.request.body
|
const inputs = ctx.request.body
|
||||||
const tableId = ctx.params.tableId
|
const tableId = ctx.params.tableId
|
||||||
const id = inputs._id
|
const id = inputs._id
|
||||||
// don't save the ID to db
|
// don't save the ID to db
|
||||||
delete inputs._id
|
delete inputs._id
|
||||||
ctx.body = await handleRequest(appId, DataSourceOperation.UPDATE, tableId, { id, row: inputs })
|
ctx.body = await handleRequest(appId, DataSourceOperation.UPDATE, tableId, {
|
||||||
|
id,
|
||||||
|
row: inputs,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.save = async (ctx) => {
|
exports.save = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const inputs = ctx.request.body
|
const inputs = ctx.request.body
|
||||||
if (inputs._id) {
|
if (inputs._id) {
|
||||||
return exports.patch(ctx)
|
return exports.patch(ctx)
|
||||||
}
|
}
|
||||||
const tableId = ctx.params.tableId
|
const tableId = ctx.params.tableId
|
||||||
ctx.body = await handleRequest(appId, DataSourceOperation.CREATE, tableId, { row: inputs })
|
ctx.body = await handleRequest(appId, DataSourceOperation.CREATE, tableId, {
|
||||||
|
row: inputs,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fetchView = async (ctx) => {
|
exports.fetchView = async ctx => {
|
||||||
// TODO: don't know what this does for external
|
// TODO: don't know what this does for external
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fetchTableRows = async (ctx) => {
|
exports.fetchTableRows = async ctx => {
|
||||||
// TODO: this is a basic read?
|
// TODO: this is a basic read?
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.find = async (ctx) => {
|
exports.find = async ctx => {
|
||||||
// TODO: single find
|
// TODO: single find
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.destroy = async (ctx) => {
|
exports.destroy = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const tableId = ctx.params.tableId
|
const tableId = ctx.params.tableId
|
||||||
ctx.body = await handleRequest(appId, DataSourceOperation.DELETE, tableId, { id: ctx.request.body._id })
|
ctx.body = await handleRequest(appId, DataSourceOperation.DELETE, tableId, {
|
||||||
|
id: ctx.request.body._id,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.bulkDestroy = async (ctx) => {
|
exports.bulkDestroy = async ctx => {
|
||||||
// TODO: iterate through rows, build a large OR filter?
|
// TODO: iterate through rows, build a large OR filter?
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.search = async (ctx) => {
|
exports.search = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const tableId = ctx.params.tableId
|
const tableId = ctx.params.tableId
|
||||||
const { paginate, query, ...params } = ctx.request.body
|
const { paginate, query, ...params } = ctx.request.body
|
||||||
|
@ -90,25 +102,27 @@ exports.search = async (ctx) => {
|
||||||
}
|
}
|
||||||
let sort
|
let sort
|
||||||
if (params.sort) {
|
if (params.sort) {
|
||||||
|
const direction =
|
||||||
|
params.sortOrder === "descending"
|
||||||
|
? SortDirection.DESCENDING
|
||||||
|
: SortDirection.ASCENDING
|
||||||
sort = {
|
sort = {
|
||||||
[params.sort]: params.sortOrder === "descending" ? SortDirection.DESCENDING : SortDirection.ASCENDING
|
[params.sort]: direction,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.body = await handleRequest(appId, DataSourceOperation.READ, tableId,
|
ctx.body = await handleRequest(appId, DataSourceOperation.READ, tableId, {
|
||||||
{
|
filters: query,
|
||||||
filters: query,
|
sort,
|
||||||
sort,
|
paginate: paginateObj,
|
||||||
paginate: paginateObj,
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.validate = async (ctx) => {
|
exports.validate = async ctx => {
|
||||||
// can't validate external right now - maybe in future
|
// can't validate external right now - maybe in future
|
||||||
ctx.body = { valid: true }
|
ctx.body = { valid: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fetchEnrichedRow = async (ctx) => {
|
exports.fetchEnrichedRow = async ctx => {
|
||||||
// TODO: should this join?
|
// TODO: should this join?
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
ctx.body = {}
|
ctx.body = {}
|
||||||
|
|
|
@ -23,7 +23,8 @@ exports.patch = async ctx => {
|
||||||
const tableId = getTableId(ctx)
|
const tableId = getTableId(ctx)
|
||||||
try {
|
try {
|
||||||
const { row, table } = await pickApi(tableId).patch(ctx)
|
const { row, table } = await pickApi(tableId).patch(ctx)
|
||||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
ctx.eventEmitter &&
|
||||||
|
ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
||||||
ctx.message = `${table.name} updated successfully`
|
ctx.message = `${table.name} updated successfully`
|
||||||
ctx.body = row
|
ctx.body = row
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -104,7 +105,6 @@ exports.search = async ctx => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.validate = async function (ctx) {
|
exports.validate = async function (ctx) {
|
||||||
const tableId = getTableId(ctx)
|
const tableId = getTableId(ctx)
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -135,7 +135,7 @@ exports.save = async function (ctx) {
|
||||||
return { row, table }
|
return { row, table }
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fetchView = async (ctx) => {
|
exports.fetchView = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const viewName = ctx.params.viewName
|
const viewName = ctx.params.viewName
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ exports.fetchView = async (ctx) => {
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fetchTableRows = async (ctx) => {
|
exports.fetchTableRows = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ exports.fetchTableRows = async (ctx) => {
|
||||||
return outputProcessing(appId, table, rows)
|
return outputProcessing(appId, table, rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.find = async (ctx) => {
|
exports.find = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
const table = await db.get(ctx.params.tableId)
|
const table = await db.get(ctx.params.tableId)
|
||||||
|
@ -246,7 +246,7 @@ exports.destroy = async function (ctx) {
|
||||||
await userController.destroyMetadata(ctx)
|
await userController.destroyMetadata(ctx)
|
||||||
return { response: ctx.body, row }
|
return { response: ctx.body, row }
|
||||||
} else {
|
} else {
|
||||||
const response = await db.remove(_id, _rev)
|
const response = await db.remove(_id, _rev)
|
||||||
return { response, row }
|
return { response, row }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ exports.search = async ctx => {
|
||||||
ctx.body = response
|
ctx.body = response
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.validate = async (ctx) => {
|
exports.validate = async ctx => {
|
||||||
return validate({
|
return validate({
|
||||||
appId: ctx.appId,
|
appId: ctx.appId,
|
||||||
tableId: ctx.params.tableId,
|
tableId: ctx.params.tableId,
|
||||||
|
@ -312,7 +312,7 @@ exports.validate = async (ctx) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.fetchEnrichedRow = async (ctx) => {
|
exports.fetchEnrichedRow = async ctx => {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
const tableId = ctx.params.tableId
|
const tableId = ctx.params.tableId
|
||||||
|
|
|
@ -43,7 +43,6 @@ exports.SortDirection = {
|
||||||
DESCENDING: "DESCENDING",
|
DESCENDING: "DESCENDING",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.USERS_TABLE_SCHEMA = {
|
exports.USERS_TABLE_SCHEMA = {
|
||||||
_id: "ta_users",
|
_id: "ta_users",
|
||||||
type: "table",
|
type: "table",
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
const {
|
const { DataSourceOperation, SortDirection } = require("../../constants")
|
||||||
DataSourceOperation,
|
|
||||||
SortDirection,
|
|
||||||
} = require("../../constants")
|
|
||||||
|
|
||||||
const BASE_LIMIT = 5000
|
const BASE_LIMIT = 5000
|
||||||
|
|
||||||
|
@ -50,9 +47,7 @@ function addFilters(query, filters) {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRelationships() {
|
function buildRelationships() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildCreate(knex, json) {
|
function buildCreate(knex, json) {
|
||||||
const { endpoint, body } = json
|
const { endpoint, body } = json
|
||||||
|
|
|
@ -59,7 +59,6 @@ async function internalQuery(client, sql) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SqlServerIntegration extends Sql {
|
class SqlServerIntegration extends Sql {
|
||||||
static pool
|
static pool
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ async function internalQuery(client, sql) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class PostgresIntegration extends Sql {
|
class PostgresIntegration extends Sql {
|
||||||
static pool
|
static pool
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue